Matrix.Identity

This static method returns a new identity matrix of the requested size.  The first overload takes a single integer n and returns an n by n matrix.  The second overload takes two integers (n,d) and returns a Matrix object with n rows and d columns.

An identity matrix is an {m, n} matrix with all values where m != n are zero and all values where m == n are one. For example:

var identity = Matrix.Identity(3);
// identity is
// {{1, 0, 0},
//  {0, 1, 0},
//  {0, 0, 1}}
//
// notice that all values are zero except identity[0,0], identity[1,1] and identity[2,2].

Last edited Feb 8, 2011 at 3:43 AM by TimNelson, version 2

Comments

No comments yet.