/* Copyright (c) 2004-2006, The Dojo Foundation All Rights Reserved. Licensed under the Academic Free License version 2.1 or above OR the modified BSD license. For more information on Dojo licensing, see: http://dojotoolkit.org/community/licensing.shtml */ dojo.provide("dojo.math.matrix"); // // some of this code is based on // http://www.mkaz.com/math/MatrixCalculator.java // (published under a BSD Open Source License) // // the rest is from my vague memory of matricies in school [cal] // // the copying of arguments is a little excessive, and could be trimmed back in // the case where a function doesn't modify them at all (but some do!) // dojo.math.matrix.iDF = 0; dojo.math.matrix.multiply = function(a, b){ a = dojo.math.matrix.copy(a); b = dojo.math.matrix.copy(b); var ax = a[0].length; var ay = a.length; var bx = b[0].length; var by = b.length; if (ax != by){ dojo.debug("Can't multiply matricies of sizes "+ax+','+ay+' and '+bx+','+by); return [[0]]; } var c = []; for(var k=0; k= tms){ // check if switched all rows dojo.math.matrix.iDF = 0; stop_loop = 1; }else{ for (var c = 0; c < tms; c++) { temp = m[col][c]; m[col][c] = m[col + v][c]; // switch rows m[col + v][c] = temp; } v++; // count row switchs dojo.math.matrix.iDF *= -1; // each switch changes determinant factor } } if (m[col][col] != 0) { f1 = (-1) * m[row][col] / m[col][col]; for (var i = col; i < tms; i++) { m[row][i] = f1 * m[col][i] + m[row][i]; } } } } return m; } dojo.math.matrix.create = function(a, b){ var m = []; for(var i=0; i