By Daniel · January 1, 2009
Returns whether some square matrix M is a diagonal matrix. M should be a ds_grid filled with real entries.
/* matrix_is_diagonal(M)
*
* Returns whether some square matrix M is a diagonal matrix. M should
* be a ds_grid filled with real entries.
*/
var size, xx, yy;
size = ds_grid_width(argument0);
for (xx = 0; xx < size; xx += 1)
for (yy = 0; yy < size; yy += 1)
if (ds_grid_get(argument0, xx, yy) != 0 && xx != yy)
return false;
return true;
Categories: Mathematics
There are no comments to display.
You must be signed in to post comments.