flymis/WebRoot/dojojs/src/math/matrix.js

(开头部分) 9KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*
	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!)
//
// 2006-06-25: Some enhancements submitted by Erel Segal:
// * addition: a tolerance constant for determinant calculations.
// * performance fix: removed unnecessary argument copying.
// * addition: function "product" for multiplying more than 2 matrices
// * addition: function "sum" for adding any number of matrices
// * bug fix: inversion of a 1x1 matrix without using the adjoint
// * performance fixes: upperTriangle
// * addition: argument "value" to function create, to initialize the matrix with a custom val
// * addition: functions "ones" and "zeros" - like Matlab[TM] functions with the same name.
// * addition: function "identity" for creating an identity matrix of a given size.
// * addition: argument "decimal_points" to function format
// * bug fix: adjoint of a 0-size matrix
// * performance fixes: adjoint
//

dojo.math.matrix.iDF = 0;

// Erel: values lower than this value are considered zero (in detereminant calculations).
// It is analogous to Maltab[TM]'s "eps".
dojo.math.matrix.ALMOST_ZERO = 1e-10;
dojo.math.matrix.multiply = function(a, b){
	var ay = a.length;
	var ax = a[0].length;
	var by = b.length;
	var bx = b[0].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<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];
			}
后面还有 317 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。