Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

matrix_is_diagonal

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

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement