本文整理汇总了C#中System.Matrix.getArray方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.getArray方法的具体用法?C# Matrix.getArray怎么用?C# Matrix.getArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.getArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CholeskyDecomposition
/* ------------------------
Constructor
* ------------------------ */
/** Cholesky algorithm for symmetric and positive definite matrix.
@param A Square, symmetric matrix.
@return Structure to access L and isspd flag.
*/
public CholeskyDecomposition(Matrix Arg)
{
// Initialize.
double[][] A = Arg.getArray();
n = Arg.getRowDimension();
L = new double[n][];
for(int i = 0; i < n; i++)
{
L[n] = new double[n];
}
isspd = (Arg.getColumnDimension() == n);
// Main loop.
for (int j = 0; j < n; j++) {
double[] Lrowj = L[j];
double d = 0.0;
for (int k = 0; k < j; k++) {
double[] Lrowk = L[k];
double s = 0.0;
for (int i = 0; i < k; i++) {
s += Lrowk[i]*Lrowj[i];
}
Lrowj[k] = s = (A[j][k] - s)/L[k][k];
d = d + s*s;
isspd = isspd & (A[k][j] == A[j][k]);
}
d = A[j][j] - d;
isspd = isspd & (d > 0.0);
L[j][j] = Math.Sqrt(Math.Max(d,0.0));
for (int k = j+1; k < n; k++) {
L[j][k] = 0.0;
}
}
}
示例2: EigenvalueDecomposition
/* ------------------------
Constructor
* ------------------------ */
/** Check for symmetry, then construct the eigenvalue decomposition
@param A Square matrix
@return Structure to access D and V.
*/
public EigenvalueDecomposition(Matrix Arg)
{
double[][] A = Arg.getArray();
n = Arg.getColumnDimension();
V = new double[n][];
for(int i = 0; i < n ; i++)
{
V[i]= new double [n];
}
d = new double[n];
e = new double[n];
issymmetric = true;
for (int j = 0; (j < n) & issymmetric; j++) {
for (int i = 0; (i < n) & issymmetric; i++) {
issymmetric = (A[i][j] == A[j][i]);
}
}
if (issymmetric) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
V[i][j] = A[i][j];
}
}
// Tridiagonalize.
tred2();
// Diagonalize.
tql2();
} else {
H = new double[n][];
for(int i = 0; i < n ; i++)
{
H[i]= new double [n];
}
ort = new double[n];
for (int j = 0; j < n; j++) {
for (int i = 0; i < n; i++) {
H[i][j] = A[i][j];
}
}
// Reduce to Hessenberg form.
orthes();
// Reduce Hessenberg to real Schur form.
hqr2();
}
}
示例3: getS
/** Return the diagonal matrix of singular values
@return S
*/
public Matrix getS()
{
Matrix X = new Matrix(n, n);
double[][] S = X.getArray();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
S[i][j] = 0.0;
}
S[i][i] = this.s[i];
}
return X;
}
示例4: getD
/** Return the block diagonal eigenvalue matrix
@return D
*/
public Matrix getD()
{
Matrix X = new Matrix(n,n);
double[][] D = X.getArray();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
D[i][j] = 0.0;
}
D[i][i] = d[i];
if (e[i] > 0) {
D[i][i+1] = e[i];
} else if (e[i] < 0) {
D[i][i-1] = e[i];
}
}
return X;
}
示例5: getU
/** Return upper triangular factor
@return U
*/
public Matrix getU()
{
Matrix X = new Matrix(n, n);
double[][] U = X.getArray();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (i <= j)
{
U[i][j] = LU[i][j];
}
else
{
U[i][j] = 0.0;
}
}
}
return X;
}
示例6: getL
/** Return lower triangular factor
@return L
*/
public Matrix getL()
{
Matrix X = new Matrix(m, n);
double[][] L = X.getArray();
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if (i > j)
{
L[i][j] = LU[i][j];
}
else if (i == j)
{
L[i][j] = 1.0;
}
else
{
L[i][j] = 0.0;
}
}
}
return X;
}