/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.math.matrix"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.math.matrix"]){_4._hasResource["dojox.math.matrix"]=true;_4.provide("dojox.math.matrix");_4.getObject("math.matrix",true,_6);_4.mixin(_6.math.matrix,{iDF:0,ALMOST_ZERO:1e-10,multiply:function(a,b){var ay=a.length,ax=a[0].length,by=b.length,bx=b[0].length;if(ax!=by){console.warn("Can't multiply matricies of sizes "+ax+","+ay+" and "+bx+","+by);return [[0]];}var c=[];for(var k=0;k<ay;k++){c[k]=[];for(var i=0;i<bx;i++){c[k][i]=0;for(var m=0;m<ax;m++){c[k][i]+=a[k][m]*b[m][i];}}}return c;},product:function(){if(arguments.length==0){console.warn("can't multiply 0 matrices!");return 1;}var m=arguments[0];for(var i=1;i<arguments.length;i++){m=this.multiply(m,arguments[i]);}return m;},sum:function(){if(arguments.length==0){console.warn("can't sum 0 matrices!");return 0;}var m=this.copy(arguments[0]);var _7=m.length;if(_7==0){console.warn("can't deal with matrices of 0 rows!");return 0;}var _8=m[0].length;if(_8==0){console.warn("can't deal with matrices of 0 cols!");return 0;}for(var i=1;i<arguments.length;++i){var _9=arguments[i];if(_9.length!=_7||_9[0].length!=_8){console.warn("can't add matrices of different dimensions: first dimensions were "+_7+"x"+_8+", current dimensions are "+_9.length+"x"+_9[0].length);return 0;}for(var r=0;r<_7;r++){for(var c=0;c<_8;c++){m[r][c]+=_9[r][c];}}}return m;},inverse:function(a){if(a.length==1&&a[0].length==1){return [[1/a[0][0]]];}var _a=a.length,m=this.create(_a,_a),mm=this.adjoint(a),_b=this.determinant(a),dd=0;if(_b==0){console.warn("Determinant Equals 0, Not Invertible.");return [[0]];}else{dd=1/_b;}for(var i=0;i<_a;i++){for(var j=0;j<_a;j++){m[i][j]=dd*mm[i][j];}}return m;},determinant:function(a){if(a.length!=a[0].length){console.warn("Can't calculate the determinant of a non-squre matrix!");return 0;}var _c=a.length,_d=1,b=this.upperTriangle(a);for(var i=0;i<_c;i++){var _e=b[i][i];if(Math.abs(_e)<this.ALMOST_ZERO){return 0;}_d*=_e;}_d*=this.iDF;return _d;},upperTriangle:function(m){m=this.copy(m);var f1=0,_f=0,tms=m.length,v=1;this.iDF=1;for(var col=0;col<tms-1;col++){if(typeof m[col][col]!="number"){console.warn("non-numeric entry found in a numeric matrix: m["+col+"]["+col+"]="+m[col][col]);}v=1;var _10=0;while((m[col][col]==0)&&!_10){if(col+v>=tms){this.iDF=0;_10=1;}else{for(var r=0;r<tms;r++){_f=m[col][r];m[col][r]=m[col+v][r];m[col+v][r]=_f;}v++;this.iDF*=-1;}}for(var row=col+1;row<tms;row++){if(typeof m[row][col]!="number"){console.warn("non-numeric entry found in a numeric matrix: m["+row+"]["+col+"]="+m[row][col]);}if(typeof m[col][row]!="number"){console.warn("non-numeric entry found in a numeric matrix: m["+col+"]["+row+"]="+m[col][row]);}if(m[col][col]!=0){var 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;},create:function(a,b,_11){_11=_11||0;var m=[];for(var i=0;i<b;i++){m[i]=[];for(var j=0;j<a;j++){m[i][j]=_11;}}return m;},ones:function(a,b){return this.create(a,b,1);},zeros:function(a,b){return this.create(a,b);},identity:function(_12,_13){_13=_13||1;var m=[];for(var i=0;i<_12;i++){m[i]=[];for(var j=0;j<_12;j++){m[i][j]=(i==j?_13:0);}}return m;},adjoint:function(a){var tms=a.length;if(tms<=1){console.warn("Can't find the adjoint of a matrix with a dimension less than 2");return [[0]];}if(a.length!=a[0].length){console.warn("Can't find the adjoint of a non-square matrix");return [[0]];}var m=this.create(tms,tms),ap=this.create(tms-1,tms-1);var ii=0,jj=0,ia=0,ja=0,det=0;for(var i=0;i<tms;i++){for(var j=0;j<tms;j++){ia=0;for(ii=0;ii<tms;ii++){if(ii==i){continue;}ja=0;for(jj=0;jj<tms;jj++){if(jj==j){continue;}ap[ia][ja]=a[ii][jj];ja++;}ia++;}det=this.determinant(ap);m[i][j]=Math.pow(-1,(i+j))*det;}}return this.transpose(m);},transpose:function(a){var m=this.create(a.length,a[0].length);for(var i=0;i<a.length;i++){for(var j=0;j<a[i].length;j++){m[j][i]=a[i][j];}}return m;},format:function(a,_14){_14=_14||5;function _15(x,dp){var fac=Math.pow(10,dp);var a=Math.round(x*fac)/fac;var b=a.toString();if(b.charAt(0)!="-"){b=" "+b;}if(b.indexOf(".")>-1){b+=".";}while(b.length<dp+3){b+="0";}return b;};var ya=a.length;var xa=ya>0?a[0].length:0;var _16="";for(var y=0;y<ya;y++){_16+="| ";for(var x=0;x<xa;x++){_16+=_15(a[y][x],_14)+" ";}_16+="|\n";}return _16;},copy:function(a){var ya=a.length,xa=a[0].length,m=this.create(xa,ya);for(var y=0;y<ya;y++){for(var x=0;x<xa;x++){m[y][x]=a[y][x];}}return m;},scale:function(a,_17){a=this.copy(a);var ya=a.length,xa=a[0].length;for(var y=0;y<ya;y++){for(var x=0;x<xa;x++){a[y][x]*=_17;}}return a;}});}}};});