Fork me on GitHub

Not yet, I was simply playing along with the linear algebra book and they point it out as one of the special matrixes that are quite useful.


That's the catch: The identity element is the most important element when you develop algebra theory (thus also linear algebra theory). It is special because it doesn't change anything under the algebraic operation at hand. So, in computing, if you don't want to change anything, simply don't run the computation 🙂


With matrices, additional thing that you need to consider is that for each dimension n, you can make nxn identity matrix to be used in computations where nxn dimension needs to be fitted.


Also, Neanderthal supports several different data structure formats for special kinds of matrices. Each of those formats can also hold an identity matrix.


You can create an identity matrix with certain dimensions by creating a zero matrix and setting its diagonal to 1.0:

(let [a (some-matrix-that-you-provide)]
  (entry! (dia (zero a)) 1.0))


Or, if you need a triangular identity matrix, you can use a special case where :diag is :unit: (dtr n {:diag :unit})


But, again, most of the time, why would you create identity matrix instances? They do not change anything.


And I suppose you'd want to use your code to compute some data...