本文整理汇总了C#中DenseMatrix.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# DenseMatrix.CopyTo方法的具体用法?C# DenseMatrix.CopyTo怎么用?C# DenseMatrix.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.CopyTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DenseEvd
/// <summary>
/// Initializes a new instance of the <see cref="DenseEvd"/> class. This object will compute the
/// the eigenvalue decomposition when the constructor is called and cache it's decomposition.
/// </summary>
/// <param name="matrix">The matrix to factor.</param>
/// <exception cref="ArgumentNullException">If <paramref name="matrix"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentException">If EVD algorithm failed to converge with matrix <paramref name="matrix"/>.</exception>
public DenseEvd(DenseMatrix matrix)
{
if (matrix == null)
{
throw new ArgumentNullException("matrix");
}
if (matrix.RowCount != matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixSquare);
}
var order = matrix.RowCount;
// Initialize matricies for eigenvalues and eigenvectors
MatrixEv = matrix.CreateMatrix(order, order);
MatrixD = matrix.CreateMatrix(order, order);
VectorEv = new LinearAlgebra.Complex.DenseVector(order);
IsSymmetric = true;
for (var i = 0; i < order & IsSymmetric; i++)
{
for (var j = 0; j < order & IsSymmetric; j++)
{
IsSymmetric &= matrix.At(i, j) == matrix.At(j, i);
}
}
var d = new float[order];
var e = new float[order];
if (IsSymmetric)
{
matrix.CopyTo(MatrixEv);
d = MatrixEv.Row(order - 1).ToArray();
SymmetricTridiagonalize(((DenseMatrix)MatrixEv).Values, d, e, order);
SymmetricDiagonalize(((DenseMatrix)MatrixEv).Values, d, e, order);
}
else
{
var matrixH = matrix.ToArray();
NonsymmetricReduceToHessenberg(((DenseMatrix)MatrixEv).Values, matrixH, order);
NonsymmetricReduceHessenberToRealSchur(((DenseMatrix)MatrixEv).Values, matrixH, d, e, order);
}
for (var i = 0; i < order; i++)
{
MatrixD.At(i, i, d[i]);
if (e[i] > 0)
{
MatrixD.At(i, i + 1, e[i]);
}
else if (e[i] < 0)
{
MatrixD.At(i, i - 1, e[i]);
}
}
for (var i = 0; i < order; i++)
{
VectorEv[i] = new Complex(d[i], e[i]);
}
}