本文整理汇总了C#中complex.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# complex.GetValue方法的具体用法?C# complex.GetValue怎么用?C# complex.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类complex
的用法示例。
在下文中一共展示了complex.GetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_ishermitianComplex
private void Test_ishermitianComplex() {
int errorCode = 0;
try {
ILArray<complex> A = ILArray<complex>.empty();
if (ILMath.ishermitian(A))
throw new Exception("ishermitian on empty array should return false");
A = new complex(1.0,1.0);
if (!ILMath.ishermitian(A))
throw new Exception("ishermitian on scalar array should return true");
A = ILMath.tocomplex( ILMath.vector(1,5));
if (ILMath.ishermitian(A))
throw new Exception("ishermitian on scalar array should return false");
errorCode = 1;
A = ILMath.tocomplex(ILMath.randn (4,4));
for (int i = 0; i < 16; i++)
A.SetValue(new complex(A.GetValue(i).real,A.GetValue(i).real),i);
A[1,0] = A.GetValue(0,1).conj;
A[2,0] = A.GetValue(0,2).conj;
A[2,1] = A.GetValue(1,2).conj;
A[3,0] = A.GetValue(0,3).conj;
A[3,1] = A.GetValue(1,3).conj;
A[3,2] = A.GetValue(2,3).conj;
A[0,0] = (complex)A.GetValue(0,0).real;
A[1,1] = (complex)A.GetValue(1,1).real;
A[2,2] = (complex)A.GetValue(2,2).real;
A[3,3] = (complex)A.GetValue(3,3).real;
if (!ILMath.ishermitian(A))
throw new Exception("ishermitian: A was Hermitian but detected as not");
A[3,2] += new complex(1.0,0.0);
if (ILMath.ishermitian(A))
throw new Exception("ishermitian: A was not Hermitian but detected as true");
A[3,2] -= new complex(1.0,0.0);
A[1,0] += new complex(1.0,0.0);
if (ILMath.ishermitian(A))
throw new Exception("ishermitian: A was not Hermitian but detected as true");
A[1,0] -= new complex(1.0,0.0);
A[3,0] += new complex(1.0,0.0);
if (ILMath.ishermitian(A))
throw new Exception("ishermitian: A was not Hermitian but detected as true");
errorCode = 2;
Success();
} catch(Exception e) {
Error(errorCode,e.Message);
}
}