当前位置: 首页>>代码示例>>C#>>正文


C# complex.SetValue方法代码示例

本文整理汇总了C#中complex.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# complex.SetValue方法的具体用法?C# complex.SetValue怎么用?C# complex.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在complex的用法示例。


在下文中一共展示了complex.SetValue方法的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);
            }
        }
开发者ID:wdxa,项目名称:ILNumerics,代码行数:46,代码来源:TESTILMath.cs


注:本文中的complex.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。