Game Maker Games, Articles, Tutorials & More

Game Maker Network


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

Print

matrix_transpose

By Daniel · January 1, 2009

Returns the transpose of some matrix M. This should be a ds_grid filled with real entries.

/* matrix_transpose(M)
 *
 * Returns the transpose of some matrix M. This should be a ds_grid filled
 * with real entries.
 */

var w, h, T, xx, yy;

w = ds_grid_height(argument0);
h = ds_grid_width(argument0);
T = ds_grid_create(w, h);

for (xx = 0; xx < w; xx += 1)
  for (yy = 0; yy < h; yy += 1)
    ds_grid_set(T, xx, yy, ds_grid_get(argument0, yy, xx));

return T;

Categories: Mathematics

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement