Ejemplo n.º 1
0
        public static void ConstructionTest()
        {
            TestUtils.AddTestStartingMessage("MathematicaMatrix Creation Test Started.");

            var scalarsArray = new MathematicaScalar[2, 2];

            scalarsArray[0, 0] = MathematicaScalar.Create(Cas, 2);
            scalarsArray[0, 1] = MathematicaScalar.Create(Cas, -2);
            scalarsArray[1, 0] = MathematicaScalar.Create(Cas, 3);
            scalarsArray[1, 1] = MathematicaScalar.Create(Cas, 1);

            var s = MathematicaMatrix.CreateFullMatrix(Cas, scalarsArray);

            TestUtils.AddTest("Try create full matrix from array of scalars ... ", s);

            s = MathematicaMatrix.CreateIdentity(Cas, 3);
            TestUtils.AddTest("Try create full 3x3 identity matrix ... ", s);

            s = MathematicaMatrix.CreateIdentity(Cas, 3, false);
            TestUtils.AddTest("Try create sparse 3x3 identity matrix ... ", s);

            var v = MathematicaVector.CreateFullVector(Cas, Cas.Constants.Zero, Cas.Constants.TwoPi, Cas.Constants.One);

            s = MathematicaMatrix.CreateDiagonal(v);
            TestUtils.AddTest("Try create full 3x3 diagonal matrix from vector {0, 2 Pi, 1} ... ", s);

            s = MathematicaMatrix.CreateDiagonal(v, false);
            TestUtils.AddTest("Try create sparse 3x3 diagonal matrix from vector {0, 2 Pi, 1} ... ", s);

            s = MathematicaMatrix.CreateRowVector(v);
            TestUtils.AddTest("Try create full row vector matrix from vector {0, 2 Pi, 1} ... ", s);

            s = MathematicaMatrix.CreateRowVector(v, false);
            TestUtils.AddTest("Try create sparse row vector matrix from vector {0, 2 Pi, 1} ... ", s);

            s = MathematicaMatrix.CreateColumnVector(v);
            TestUtils.AddTest("Try create full row vector matrix from vector {0, 2 Pi, 1} ... ", s);

            s = MathematicaMatrix.CreateColumnVector(v, false);
            TestUtils.AddTest("Try create sparse row vector matrix from vector {0, 2 Pi, 1} ... ", s);

            s = MathematicaMatrix.CreateConstant(Cas.Constants.Pi, 2, 3);
            TestUtils.AddTest("Try create 2x3 matrix with constant elements of Pi ... ", s);

            s = MathematicaMatrix.Create(Cas, @"{{1, x}, {2, y}, {3, z}}");
            TestUtils.AddTest("Try create matrix from expression text \"{{1, x}, {2, y}, {3, z}}\" ... ", s);

            TestUtils.AddTestCompletionMessage("MathematicaMatrix Creation Test Completed.");
        }