Ejemplo n.º 1
0
        public static GaSymOutermorphism Create(ISymbolicMatrix vectorsMappingMatrix, GaUnilinearMapImplementation multivectorsMappingKind)
        {
            if (multivectorsMappingKind == GaUnilinearMapImplementation.Identity)
            {
                var vSpaceDim = vectorsMappingMatrix.ColumnCount;

                return(new GaSymOutermorphism(
                           MathematicaMatrix.CreateIdentity(SymbolicUtils.Cas, vSpaceDim),
                           GaSymMapUnilinearIdentity.Create(vSpaceDim),
                           GaUnilinearMapImplementation.Identity
                           ));
            }

            var mvMappingDictionaryDict = vectorsMappingMatrix.ToOutermorphismDictionary();
            GaSymMapUnilinear multivectorsMap;

            switch (multivectorsMappingKind)
            {
            case GaUnilinearMapImplementation.Array:
                multivectorsMap = mvMappingDictionaryDict.ToArrayMap(
                    vectorsMappingMatrix.ColumnCount,
                    vectorsMappingMatrix.RowCount
                    );
                break;

            case GaUnilinearMapImplementation.Hash:
                multivectorsMap = mvMappingDictionaryDict.ToHashMap(
                    vectorsMappingMatrix.ColumnCount,
                    vectorsMappingMatrix.RowCount
                    );
                break;

            case GaUnilinearMapImplementation.Matrix:
                multivectorsMap = mvMappingDictionaryDict.ToMatrixMap(
                    vectorsMappingMatrix.ColumnCount,
                    vectorsMappingMatrix.RowCount
                    );
                break;

            case GaUnilinearMapImplementation.CoefSums:
                multivectorsMap = mvMappingDictionaryDict.ToCoefSumsMap(
                    vectorsMappingMatrix.ColumnCount,
                    vectorsMappingMatrix.RowCount
                    );
                break;

            default:
                multivectorsMap = mvMappingDictionaryDict.ToTreeMap(
                    vectorsMappingMatrix.ColumnCount,
                    vectorsMappingMatrix.RowCount
                    );
                break;
            }

            return(new GaSymOutermorphism(
                       vectorsMappingMatrix,
                       multivectorsMap,
                       multivectorsMappingKind
                       ));
        }
Ejemplo n.º 2
0
 public static GaSymOutermorphism CreateIdentity(int vSpaceDim)
 {
     return(new GaSymOutermorphism(
                MathematicaMatrix.CreateIdentity(SymbolicUtils.Cas, vSpaceDim),
                GaSymMapUnilinearIdentity.Create(vSpaceDim),
                GaUnilinearMapImplementation.Identity
                ));
 }
Ejemplo n.º 3
0
        public static void IsOpsTest()
        {
            TestUtils.AddTestStartingMessage("MathematicaMatrix 'Is' Operations Test Started.");

            var m1 = MathematicaMatrix.CreateFullDiagonalMatrix(Cas, Cas.Constants.Zero, Cas.Constants.One, Cas.Constants.TwoPi);

            TestUtils.AddTest("Try apply IsZero() to full diagonal matrix {0, 1, 2 Pi} ... ", m1.IsZero());

            var sm1 = m1.ToMathematicaSparseMatrix();

            TestUtils.AddTest("Try apply IsZero() to sparse diagonal matrix {0, 1, 2 Pi} ... ", sm1.IsZero());

            m1 = MathematicaMatrix.CreateFullDiagonalMatrix(Cas, Cas.Constants.Zero, Cas.Constants.Zero, Cas.Constants.Zero);
            TestUtils.AddTest("Try apply IsZero() to full diagonal matrix {0, 0, 0} ... ", m1.IsZero());

            sm1 = m1.ToMathematicaSparseMatrix();
            TestUtils.AddTest("Try apply IsZero() to sparse diagonal matrix {0, 0, 0} ... ", sm1.IsZero());


            m1 = MathematicaMatrix.CreateFullDiagonalMatrix(Cas, Cas.Constants.Zero, Cas.Constants.One, Cas.Constants.TwoPi);
            TestUtils.AddTest("Try apply IsIdentity() to full diagonal matrix {0, 1, 2 Pi} ... ", m1.IsIdentity());

            sm1 = m1.ToMathematicaSparseMatrix();
            TestUtils.AddTest("Try apply IsIdentity() to sparse diagonal matrix {0, 1, 2 Pi} ... ", sm1.IsIdentity());

            m1 = MathematicaMatrix.CreateIdentity(Cas, 4);
            TestUtils.AddTest("Try apply IsIdentity() to full 4x4 Identity matrix ... ", m1.IsIdentity());

            sm1 = m1.ToMathematicaSparseMatrix();
            TestUtils.AddTest("Try apply IsIdentity() to sparse 4x4 Identity matrix ... ", sm1.IsIdentity());


            m1 = MathematicaMatrix.CreateFullDiagonalMatrix(Cas, Cas.Constants.Zero, Cas.Constants.One, Cas.Constants.TwoPi);
            TestUtils.AddTest("Try apply IsDiagonal() to full diagonal matrix {0, 1, 2 Pi} ... ", m1.IsDiagonal());

            sm1 = m1.ToMathematicaSparseMatrix();
            TestUtils.AddTest("Try apply IsDiagonal() to sparse diagonal matrix {0, 1, 2 Pi} ... ", sm1.IsDiagonal());

            m1 = MathematicaMatrix.CreateConstant(Cas.Constants.Pi, 5, 5);
            TestUtils.AddTest("Try apply IsDiagonal() to full 5x5 matrix with non-zero elements ... ", m1.IsDiagonal());

            sm1 = MathematicaMatrix.Create(Cas, "SparseArray[RandomInteger[1, {5, 5}]]");
            TestUtils.AddTest("Try apply IsDiagonal() to sparse 5x5 matrix " + sm1.ToMathematicaFullMatrix().ExpressionText + " ... ", sm1.IsDiagonal());


            m1 = MathematicaMatrix.Create(Cas, "RandomInteger[3, {5, 5}]");
            m1 = m1 * m1.Transpose().ToMathematicaMatrix();
            TestUtils.AddTest("Try apply IsSymmetric() to full 5x5 symmetric matrix " + m1.ExpressionText + " ... ", m1.IsSymmetric());

            TestUtils.AddTest("Try apply IsSymmetric() to sparse 5x5 matrix " + sm1.ToMathematicaFullMatrix().ExpressionText + " ... ", sm1.IsSymmetric());


            m1 = MathematicaMatrix.Create(Cas, "RandomInteger[{-10, 10}, {5, 5}]");
            TestUtils.AddTest("Try apply IsInvertable() to full 5x5 matrix " + m1.ExpressionText + " ... ", m1.IsInvertable());

            sm1 = MathematicaMatrix.Create(Cas, "SparseArray[RandomInteger[1, {5, 5}]]");
            TestUtils.AddTest("Try apply IsInvertable() to sparse 5x5 matrix " + sm1.ToMathematicaFullMatrix().ExpressionText + " ... ", sm1.IsInvertable());


            m1 = MathematicaMatrix.Create(Cas, "RandomInteger[3, {5, 5}]");
            m1 = m1 * m1.Transpose().ToMathematicaMatrix();
            TestUtils.AddTest("Try apply IsOrthogonal() to full 5x5 symmetric matrix " + m1.ExpressionText + " ... ", m1.IsOrthogonal());

            TestUtils.AddTest("Try apply IsOrthogonal() to sparse 5x5 matrix " + sm1.ToMathematicaFullMatrix().ExpressionText + " ... ", sm1.IsOrthogonal());

            m1 = MathematicaMatrix.Create(Cas, Cas[Mfs.Orthogonalize[m1.Expression]]);
            TestUtils.AddTest("Try apply IsOrthogonal() to full 5x5 symmetric matrix " + m1.ExpressionText + " ... ", m1.IsOrthogonal());

            sm1 = MathematicaMatrix.Create(Cas, Cas[Mfs.SparseArray[Mfs.Orthogonalize[sm1.Expression]]]);
            TestUtils.AddTest("Try apply IsOrthogonal() to sparse 5x5 matrix " + sm1.ToMathematicaFullMatrix().ExpressionText + " ... ", sm1.IsOrthogonal());


            TestUtils.AddTestCompletionMessage("MathematicaMatrix 'Is' Operations Test Completed.");
        }