Esempio n. 1
0
        private void Test_conj()
        {
            // test for common matrix 4x3
            ILArray <complex> A = new complex[, ] {
                { new complex(1, 2), new complex(3, 4), new complex(5, 6) },
                { new complex(7, 8), new complex(9, 10), new complex(11, 12) },
                { new complex(13, 14), new complex(15, 16), new complex(17, 18) },
                { new complex(19, 20), new complex(21, 22), new complex(23, 24) }
            };
            ILArray <fcomplex> Af = ILMath.tofcomplex(A);

            Test_isConj(A, ILMath.conj(A));
            Test_isfConj(Af, ILMath.conj(Af));
            // test on reference matrix
            Test_isConj(A, ILMath.conj(A.R));
            Test_isfConj(Af, ILMath.conj(Af.R));
            // test on 2x2x3 matrix (reference)
            A = A.Reshape(new ILDimension(2, 2, 3)).R;
            if (!A.IsReference)
            {
                throw new Exception("Unable to test conj() for reference 2x2x3!");
            }
            Af = Af.Reshape(new ILDimension(2, 2, 3)).R;
            if (!Af.IsReference)
            {
                throw new Exception("Unable to test conj() for reference 2x2x3!");
            }
            Test_isConj(A, ILMath.conj(A));
            Test_isfConj(Af, ILMath.conj(Af));
            // test those on dense array
            Test_isConj(A, ILMath.conj(A.C));
            Test_isfConj(Af, ILMath.conj(Af.C));
            // test for empty
            A = ILArray <complex> .empty();

            Af = ILArray <fcomplex> .empty();

            Test_isConj(A, ILMath.conj(A));
            Test_isfConj(Af, ILMath.conj(Af));
            // test on vector
            A  = new complex[] { new complex(1, 2), new complex(3, 4), new complex(5, 6) };
            Af = ILMath.tofcomplex(A);
            Test_isConj(A, ILMath.conj(A));
            Test_isfConj(Af, ILMath.conj(Af));
            // transpose
            Test_isConj(A.T, ILMath.conj(A.T));
            Test_isfConj(Af.T, ILMath.conj(Af.T));
            // test on scalar
            A = A[2]; Af = Af[2];
            Test_isConj(A, ILMath.conj(A));
            Test_isfConj(Af, ILMath.conj(Af));
        }
Esempio n. 2
0
        private void Test_conj() {
            // test for common matrix 4x3
            ILArray<complex> A = new complex[,] {
                {new complex(1,2), new complex(3,4), new complex(5,6)},
                {new complex(7,8), new complex(9,10), new complex(11,12)},
                {new complex(13,14), new complex(15,16), new complex(17,18)},
                {new complex(19,20), new complex(21,22), new complex(23,24)}};
            ILArray<fcomplex> Af = ILMath.tofcomplex(A); 
            Test_isConj(A,ILMath.conj(A)); 
            Test_isfConj(Af,ILMath.conj(Af));
            // test on reference matrix
            Test_isConj(A,ILMath.conj(A.R)); 
            Test_isfConj(Af,ILMath.conj(Af.R));
            // test on 2x2x3 matrix (reference)
            A = A.Reshape(new ILDimension(2,2,3)).R;
            if (!A.IsReference) 
                throw new Exception("Unable to test conj() for reference 2x2x3!"); 
            Af = Af.Reshape(new ILDimension(2,2,3)).R; 
            if (!Af.IsReference) 
                throw new Exception("Unable to test conj() for reference 2x2x3!"); 
            Test_isConj(A,ILMath.conj(A)); 
            Test_isfConj(Af,ILMath.conj(Af));
            // test those on dense array 
            Test_isConj(A,ILMath.conj(A.C)); 
            Test_isfConj(Af,ILMath.conj(Af.C));
            // test for empty
            A = ILArray<complex>.empty();
            Af = ILArray<fcomplex>.empty();
            Test_isConj(A,ILMath.conj(A)); 
            Test_isfConj(Af,ILMath.conj(Af)); 
            // test on vector
            A = new complex[] { new complex(1,2), new complex(3,4), new complex(5,6)}; 
            Af = ILMath.tofcomplex(A); 
            Test_isConj(A,ILMath.conj(A)); 
            Test_isfConj(Af,ILMath.conj(Af)); 
            // transpose 
            Test_isConj(A.T,ILMath.conj(A.T)); 
            Test_isfConj(Af.T,ILMath.conj(Af.T)); 
            // test on scalar 
            A = A[2]; Af = Af[2]; 
            Test_isConj(A,ILMath.conj(A)); 
            Test_isfConj(Af,ILMath.conj(Af)); 

        }