Fork me on GitHub
#uncomplicate
<
2017-07-05
>
rrottier02:07:35

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.

blueberry05:07:13

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 🙂

blueberry05:07:52

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.

blueberry05:07:42

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

blueberry05:07:56

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))

blueberry05:07:12

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

blueberry05:07:00

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

blueberry05:07:20

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