预订演示

请注意 : 本帮助页面不适用于最新版本的Enterprise Architect. 最新的帮助文档在这里.

前页 后页

minv

Matrix inversion.

SYNOPSIS:

int n, errcod;
double A[n*n], X[n*n];
double B[n];
int IPS[n];
int minv();

errcod = minv(A, X, n, B, IPS);

DESCRIPTION:

Finds the inverse of the n by n matrix A. The result goes to X.  B and IPS are scratch-pad arrays of length n. The contents of matrix A are destroyed.

The routine returns nonzero on error; error messages are printed by the subroutine simq().

JavaScript:

function test_minv()
{
/*
* Finds the inverse of the n by n matrix A.  The result goes
* to X.   B and IPS are scratch pad arrays of length n.
* The contents of matrix A are destroyed
*/
Session.Output("calling cephes.minv( A,X,n,B,IPS) where:");
var n = 10; // n x n matrix A (10x10)
var A = [
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],
[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
];

var X = new Array(10); // output
var B = new Array(10); // scratch pad
var IPS = new Array(10); // scratch pad

Session.Output("  n = " + n);
Session.Output("  length of A is" + n*n);
Session.Output("A is matrix of " + dimensionsOfArray(A));
var ir = cephes.minv(A,X,n,B,IPS);

var s = cephes.geterrormsg();
if(s.length>0)
{
Session.Output("error output by minv: " + s);
}
else
{
Session.Output("minv returned " + ir);
Session.Output("X is matrix of " + dimensionsOfArray(X));
printMatrix("X",X,10,10);
}
}