本文整理汇总了C#中System.Matrix.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.GetData方法的具体用法?C# Matrix.GetData怎么用?C# Matrix.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.GetData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestConstructor
public void TestConstructor()
{
int[,] matrix1 = new int[,]
{
{1, 2, -3},
{2, 1, 3},
{3, 1, 2}
};
Matrix<int> m1 = new Matrix<int>(matrix1);
int[,] matrixContents = m1.GetData();
CollectionAssert.AreEqual(matrix1, matrixContents);
}
示例2: CallZgeev
private unsafe void CallZgeev(Matrix m, out Matrix eigenvals, out Matrix eigenvecs)
{
char jobvl = 'N';
char jobvr = 'V';
int N = m.Rows;
Complex[] A_array = m.GetData();
int lda = N;
Complex* W = stackalloc Complex[N];
Complex* VL = stackalloc Complex[N];
int ldvl = 1;
Complex* VR = stackalloc Complex[N*N];
int ldvr = N;
int lwork = 4 * N;
Complex* work = stackalloc Complex[lwork];
double* rwork = stackalloc double[2*N];
int info;
fixed (Complex* A = A_array)
{
zgeev(ref jobvl, ref jobvr, ref N, ref A[0], ref lda, ref W[0],
ref VL[0], ref ldvl, ref VR[0], ref ldvr, ref work[0], ref lwork,
ref rwork[0], out info);
}
eigenvals = new Matrix(N, 1);
for (int i = 0; i < N; i++)
{
eigenvals[i, 0] = W[i];
}
eigenvecs = new Matrix(N, N);
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
eigenvecs[i, j] = VR[i + j * N].Conjugate();
}
}
}
示例3: CallZheev
unsafe void CallZheev(Matrix m, out Matrix eigenvals, out Matrix eigenvecs)
{
char jobz = 'V';
char uplo = 'U';
int N = m.Rows;
int LDA = N;
Complex[] A_array = m.GetData();
double* W = stackalloc double[N];
int lwork = 4 * N;
Complex* Work = stackalloc Complex[lwork];
double* rwork = stackalloc double[4 * N];
int info;
fixed (Complex* A = A_array)
{
zheev(ref jobz, ref uplo, ref N, ref A[0], ref LDA, ref W[0], ref Work[0], ref lwork, ref rwork[0], out info);
}
if (info != 0)
throw new Exception("Error calling Lapack. Info: " + info.ToString());
eigenvals = new Matrix(m.Rows, 1);
eigenvecs = new Matrix(m.Rows, m.Columns);
for (int i = 0; i < N; i++)
{
eigenvals[i, 0] = W[i];
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
eigenvecs[i, j] = A_array[i + j * N].Conjugate();
}
}
}