本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Single.DenseMatrix.Evd方法的典型用法代码示例。如果您正苦于以下问题:C# DenseMatrix.Evd方法的具体用法?C# DenseMatrix.Evd怎么用?C# DenseMatrix.Evd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathNet.Numerics.LinearAlgebra.Single.DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.Evd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCheckRankOfSquareSingular
public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order)
{
var A = new DenseMatrix(order, order);
A[0, 0] = 1;
A[order - 1, order - 1] = 1;
for (var i = 1; i < order - 1; i++)
{
A[i, i - 1] = 1;
A[i, i + 1] = 1;
A[i - 1, i] = 1;
A[i + 1, i] = 1;
}
var factorEvd = A.Evd();
Assert.AreEqual(factorEvd.Determinant, 0);
Assert.AreEqual(factorEvd.Rank, order - 1);
}
示例2: CanCheckRankOfSquareSingular
public void CanCheckRankOfSquareSingular(int order)
{
var matrixA = new DenseMatrix(order, order);
matrixA[0, 0] = 1;
matrixA[order - 1, order - 1] = 1;
for (var i = 1; i < order - 1; i++)
{
matrixA[i, i - 1] = 1;
matrixA[i, i + 1] = 1;
matrixA[i - 1, i] = 1;
matrixA[i + 1, i] = 1;
}
var factorEvd = matrixA.Evd();
Assert.AreEqual(factorEvd.Determinant, 0);
Assert.AreEqual(factorEvd.Rank, order - 1);
}
示例3: vanillaLogCov
Evd evd; //factorization storage
#endregion Fields
#region Constructors
public vanillaLogCov(float[,] matrix1, float[,] matrix2)
{
//deep copy the covariances
//densematrix allocates new memory for the matrix
cov1 = new DenseMatrix(Covariance(matrix1));
cov2 = new DenseMatrix(Covariance(matrix2));
evd = cov1.Evd();
diag = evd.D();
//could make this a function but thats for later cleanup.... < . <
//should be square matrix so matrix lengths dont matter
for (int i = 0; i < diag.RowCount; i++)
{
diag[i, i] = (float)Math.Log(Math.Abs((double)diag[i, i]));
}
logcov1 = evd.EigenVectors() * diag * evd.EigenVectors().Transpose();
evd = cov2.Evd();
diag = evd.D();
//could make this a function but thats for later cleanup.... < . <
//should be square matrix so matrix lengths dont matter
for (int i = 0; i < diag.RowCount; i++)
{
diag[i, i] = (float)Math.Log(Math.Abs((double)diag[i, i]));
}
logcov2 = evd.EigenVectors() * diag * evd.EigenVectors().Transpose();
//compute distance
distance = 0; //initialize to empty
for (int i = 0; i < logcov2.RowCount; i++)
{
for (int j = 0; j < logcov2.RowCount; j++)
{
distance += (float)Math.Pow(logcov1[i, j] - logcov2[i, j], 2);
}
}
distance = (float)Math.Sqrt(distance);
}
示例4: ToCovMat
public MathNet.Numerics.LinearAlgebra.Generic.Matrix<float> ToCovMat(int VectDimen, int FPSegment, float[,] DistData, float[] MeanDist)
{
DenseMatrix Cov = new DenseMatrix(VectDimen);
for (int i = 0; i < VectDimen; i++)
{
for (int j = i; j < VectDimen; j++)
{
for (int t = 0; t < FPSegment; t++)
{
Cov[i, j] += DistData[i, t] * DistData[j, t];
}
Cov[i, j] -= MeanDist[i] * MeanDist[j] * FPSegment;
Cov[i, j] /= FPSegment - 1;
}
}
for (int i = 0; i < VectDimen; i++)
{
for (int j = i; j < VectDimen; j++)
{
Cov[j, i] = Cov[i, j];
}
}
MathNet.Numerics.LinearAlgebra.Single.Factorization.Evd evd;
MathNet.Numerics.LinearAlgebra.Generic.Matrix<float> LogD;
var thread = new Thread(() => tryEvd(Cov));
thread.Start();
if (!thread.Join(3000))
{
LogD = Cov;
LogD.Clear();
return LogD;
}
evd = Cov.Evd();
LogD = evd.D();
for (int i = 0; i < VectDimen; i++)
{
LogD[i, i] = (float)Math.Log(Math.Abs((double)LogD[i, i]));
}
MathNet.Numerics.LinearAlgebra.Generic.Matrix<float> LogCov;
LogCov = evd.EigenVectors() * LogD * evd.EigenVectors().Transpose();
return LogCov;
}