本文整理汇总了C#中YAMP.MatrixValue.GetRealMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# MatrixValue.GetRealMatrix方法的具体用法?C# MatrixValue.GetRealMatrix怎么用?C# MatrixValue.GetRealMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YAMP.MatrixValue
的用法示例。
在下文中一共展示了MatrixValue.GetRealMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Eigenvalues
/// <summary>
/// Check for symmetry, then construct the eigenvalue decomposition
/// </summary>
/// <param name="Arg">Square matrix</param>
/// <returns>Structure to access D and V.</returns>
public Eigenvalues(MatrixValue Arg)
{
var A = Arg.GetRealMatrix();
n = Arg.DimensionX;
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 i2 = 0; i2 < n; i2++)
H[i2] = 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();
}
}
示例2: SingularValueDecomposition
/// <summary>
/// Construct the singular value decomposition
/// </summary>
/// <param name="Arg">Rectangular matrix</param>
/// <returns>Structure to access U, S and V.</returns>
public SingularValueDecomposition(MatrixValue Arg)
{
// Derived from LINPACK code.
// Initialize.
var A = Arg.GetRealMatrix();
m = Arg.DimensionY;
n = Arg.DimensionX;
var nu = Math.Min(m, n);
s = new double[Math.Min(m + 1, n)];
U = new double[m][];
for (int i = 0; i < m; i++)
U[i] = new double[nu];
V = new double[n][];
for (int i2 = 0; i2 < n; i2++)
V[i2] = new double[n];
var e = new double[n];
var work = new double[m];
var wantu = true;
var wantv = true;
// Reduce A to bidiagonal form, storing the diagonal elements
// in s and the super-diagonal elements in e.
int nct = Math.Min(m - 1, n);
int nrt = Math.Max(0, Math.Min(n - 2, m));
for (int k = 0; k < Math.Max(nct, nrt); k++)
{
if (k < nct)
{
// Compute the transformation for the k-th column and
// place the k-th diagonal in s[k].
// Compute 2-norm of k-th column without under/overflow.
s[k] = 0;
for (int i = k; i < m; i++)
s[k] = Helpers.Hypot(s[k], A[i][k]);
if (s[k] != 0.0)
{
if (A[k][k] < 0.0)
s[k] = -s[k];
for (int i = k; i < m; i++)
A[i][k] /= s[k];
A[k][k] += 1.0;
}
s[k] = -s[k];
}
for (int j = k + 1; j < n; j++)
{
if ((k < nct) & (s[k] != 0.0))
{
// Apply the transformation.
double t = 0;
for (int i = k; i < m; i++)
t += A[i][k] * A[i][j];
t = (-t) / A[k][k];
for (int i = k; i < m; i++)
A[i][j] += t * A[i][k];
}
// Place the k-th row of A into e for the
// subsequent calculation of the row transformation.
e[j] = A[k][j];
}
if (wantu & (k < nct))
{
// Place the transformation in U for subsequent back
// multiplication.
for (int i = k; i < m; i++)
U[i][k] = A[i][k];
}
if (k < nrt)
{
// Compute the k-th row transformation and place the
// k-th super-diagonal in e[k].
// Compute 2-norm without under/overflow.
e[k] = 0;
for (int i = k + 1; i < n; i++)
e[k] = Helpers.Hypot(e[k], e[i]);
//.........这里部分代码省略.........