本文整理汇总了C#中DoubleMatrix.GetColumn方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleMatrix.GetColumn方法的具体用法?C# DoubleMatrix.GetColumn怎么用?C# DoubleMatrix.GetColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.GetColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetColumn
public void GetColumn()
{
DoubleMatrix a = new DoubleMatrix(2,2);
a[0,0] = 1;
a[0,1] = 2;
a[1,0] = 3;
a[1,1] = 4;
DoubleVector b = a.GetColumn(0);
Assert.AreEqual(b[0], a[0,0]);
Assert.AreEqual(b[1], a[1,0]);
}
示例2: GetColumnOutOfRange
public void GetColumnOutOfRange()
{
DoubleMatrix a = new DoubleMatrix(2,2);
DoubleVector b = a.GetColumn(3);
}
示例3: Solve
//.........这里部分代码省略.........
}
// check if leading diagonal is zero
if (col[0] == 0.0)
{
throw new SingularMatrixException("One of the leading sub-matrices is singular.");
}
// decompose matrix
int order = col.Length;
double[] A = new double[order];
double[] B = new double[order];
double[] Z = new double[order];
DoubleMatrix X = new DoubleMatrix(order);
double Q, S, Ke, Kr, e;
double Inner;
int i, j, l;
// setup the zero order solution
A[0] = 1.0;
B[0] = 1.0;
e = 1.0 / col[0];
X.SetRow(0, e * DoubleVector.GetRow(Y,0));
for (i = 1; i < order; i++)
{
// calculate inner products
Q = 0.0;
for ( j = 0, l = 1; j < i; j++, l++)
{
Q += col[l] * A[j];
}
S = 0.0;
for ( j = 0, l = 1; j < i; j++, l++)
{
S += row[l] * B[j];
}
// reflection coefficients
Kr = -S * e;
Ke = -Q * e;
// update lower triangle (in temporary storage)
Z[0] = 0.0;
Array.Copy(A, 0, Z, 1, i);
for (j = 0, l = i - 1; j < i; j++, l--)
{
Z[j] += Ke * B[l];
}
// update upper triangle
for (j = i; j > 0; j--)
{
B[j] = B[j-1];
}
B[0] = 0.0;
for (j = 0, l = i - 1; j < i; j++, l--)
{
B[j] += Kr * A[l];
}
// copy from temporary storage to lower triangle
Array.Copy(Z, 0, A, 0, i + 1);
// check for singular sub-matrix)
if (Ke * Kr == 1.0)
{
throw new SingularMatrixException("One of the leading sub-matrices is singular.");
}
// update diagonal
e = e / (1.0 - Ke * Kr);
for (l = 0; l < Y.Rows; l++)
{
DoubleVector W = X.GetColumn(l);
DoubleVector M = DoubleVector.GetColumn(Y,l);
Inner = M[i];
for (j = 0; j < i; j++)
{
Inner += A[j] * M[j];
}
Inner *= e;
W[i] = Inner;
for (j = 0; j < i; j++)
{
W[j] += Inner * B[j];
}
X.SetColumn(l, W);
}
}
return X;
}