Exemple #1
0
 public static GaNumMapUnilinearCoefSums RotorProductToCoefSumsMap(this GaNumFrame frame, GaNumMultivector rotorVersor)
 {
     return(frame
            .RotorProduct(rotorVersor, frame.BasisVectorIDs())
            .ToOutermorphismDictionary()
            .ToCoefSumsMap(frame.VSpaceDimension, frame.VSpaceDimension));
 }
 internal GaNumMetricNonOrthogonal(GaNumFrame baseFrame, GaNumFrame derivedFrame, GaNumOutermorphism derivedToBaseCba, GaNumOutermorphism baseToDerivedCba)
 {
     BaseFrame        = baseFrame;
     DerivedFrame     = derivedFrame;
     DerivedToBaseCba = derivedToBaseCba;
     BaseToDerivedCba = baseToDerivedCba;
 }
Exemple #3
0
 public static GaNumMapUnilinearArray EvenVersorProductToArrayMap(this GaNumFrame frame, GaNumMultivector evenVersor)
 {
     return(frame
            .EvenVersorProduct(evenVersor, frame.BasisVectorIDs())
            .ToOutermorphismDictionary()
            .ToArrayMap(frame.VSpaceDimension, frame.VSpaceDimension));
 }
Exemple #4
0
 public static GaNumMapUnilinearTree OddVersorProductToTreeMap(this GaNumFrame frame, GaNumMultivector oddVersor)
 {
     return(frame
            .OddVersorProduct(oddVersor, frame.BasisVectorIDs())
            .ToOutermorphismDictionary()
            .ToTreeMap(frame.VSpaceDimension, frame.VSpaceDimension));
 }
        public void Setup()
        {
            _randGen = new GMacRandomGenerator(10);

            _frame = GaNumFrame.CreateConformal(5);
            _frame.SetProductsImplementation(ProductsImplementation);

            _mv1 = _randGen.GetNumKVector(_frame.GaSpaceDimension, Grade);
            _mv2 = _randGen.GetNumKVector(_frame.GaSpaceDimension, Grade);
        }
Exemple #6
0
        public string Execute()
        {
            var validation = new GaBilinearProductsValidator();

            validation.SymbolicFrame = GaSymFrame.CreateConformal(5);
            validation.NumericFrame  = GaNumFrame.CreateConformal(5);

            validation.ShowValidatedResults = false;

            return(validation.Validate());
        }
        public GaNumMultivector GetNumNonNullVector(GaNumFrame frame)
        {
            GaNumMultivector mv;

            do
            {
                mv = GetNumVector(frame.GaSpaceDimension);
            }while (!frame.Norm2(mv).IsNearZero());

            return(mv);
        }
        public void Setup()
        {
            _randGen = new GMacRandomGenerator(10);

            _frame = GaNumFrame.CreateConformal(5);
            //_frame.SelectBilinearProductsImplementation(ProductsImplementation);

            _mv1 = _randGen.GetNumMultivectorFull(_frame.GaSpaceDimension);
            _mv2 = _mv1.Terms.ToDictionary(t => t.Key, t => t.Value);

            _mv3 = GaNumMultivector.CreateZero(_frame.GaSpaceDimension);
            //_mv4 = new Dictionary<int, double>();
            //_mv5 = new double[_frame.GaSpaceDimension];
        }
        public GaNumMultivector GetNumVersor(GaNumFrame frame, int vectorsCount)
        {
            var mv = GetNumNonNullVector(frame);

            vectorsCount--;

            while (vectorsCount > 0)
            {
                mv = frame.Gp[mv, GetNumNonNullVector(frame)];
                vectorsCount--;
            }

            return(mv);
        }
Exemple #10
0
        public string Execute()
        {
            var randGen = new GMacRandomGenerator(10);
            var frame   = GaNumFrame.CreateEuclidean(3);

            //var mv = randGen.GetNumMultivectorByGrades(frame.GaSpaceDimension, 2);
            //var dotGraph = mv.ToGraphViz(true, true);

            var bilinearMap = frame.ComputedLcp.ToTreeMap();
            var dotGraph    = bilinearMap.ToGraphViz(false, true);

            //var unilinearMap = frame.NonOrthogonalMetric.BaseToDerivedCba.ToTreeMap();
            //var dotGraph = unilinearMap.ToGraphViz(true, true);

            return(dotGraph.GenerateDotCode());
        }
Exemple #11
0
        public string Execute()
        {
            var randGen      = new GMacRandomGenerator(10);
            var textComposer = new LinearComposer();

            var numFrame = GaNumFrame.CreateConformal(5);
            var symFrame = GaSymFrame.CreateConformal(5);

            var numMv1 = randGen.GetNumMultivectorFull(numFrame.GaSpaceDimension);
            var numMv2 = randGen.GetNumMultivectorFull(numFrame.GaSpaceDimension);
            var symMv1 = numMv1.ToSymbolic();
            var symMv2 = numMv2.ToSymbolic();

            var symMvGp = symFrame.Gp[symMv1, symMv2];

            //textComposer.AppendLineAtNewLine("Symbolic Multivector 1: ").AppendLine(symMv1);
            //textComposer.AppendLineAtNewLine("Numeric Multivector 1: ").AppendLine(numMv1);

            //textComposer.AppendLineAtNewLine("Symbolic Multivector 2: ").AppendLine(symMv2);
            //textComposer.AppendLineAtNewLine("Numeric Multivector 2: ").AppendLine(numMv2);

            //textComposer.AppendLineAtNewLine("Symbolic Gp: ").AppendLine(symMvGp);
            //textComposer.AppendLineAtNewLine("Numeric GP: ").AppendLine(numMvGp);


            numFrame.SetProductsImplementation(GaBilinearProductImplementation.Computed);
            GaNumMultivector.ResetAddFactorsCallCount();
            var numMvGp    = numFrame.Gp[numMv1, numMv2];
            var callsCount = GaNumMultivector.AddFactorsCallCount;
            var diff       = symMvGp.ToNumeric() - numMvGp;

            diff.Simplify();
            GaNumMultivector.ResetAddFactorsCallCount();
            textComposer
            .AppendLineAtNewLine("Difference, Computed Tree: ")
            .AppendLine(callsCount)
            .AppendLine(diff);


            numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupArray);
            GaNumMultivector.ResetAddFactorsCallCount();
            numMvGp    = numFrame.Gp[numMv1, numMv2];
            callsCount = GaNumMultivector.AddFactorsCallCount;
            //var factorsCount = ((GaNumMapBilinearArray) numFrame.Gp).FactorsCount;
            diff = symMvGp.ToNumeric() - numMvGp;
            diff.Simplify();
            GaNumMultivector.ResetAddFactorsCallCount();
            textComposer
            .AppendLineAtNewLine("Difference, Lookup Array: ")
            .AppendLine(callsCount)
            //.AppendLine(factorsCount)
            .AppendLine(diff);


            numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupHash);
            GaNumMultivector.ResetAddFactorsCallCount();
            numMvGp    = numFrame.Gp[numMv1, numMv2];
            callsCount = GaNumMultivector.AddFactorsCallCount;
            //factorsCount = ((GaNumMapBilinearHash)numFrame.Gp).FactorsCount;
            diff = symMvGp.ToNumeric() - numMvGp;
            diff.Simplify();
            GaNumMultivector.ResetAddFactorsCallCount();
            textComposer
            .AppendLineAtNewLine("Difference, Lookup Hash: ")
            .AppendLine(callsCount)
            //.AppendLine(factorsCount)
            .AppendLine(diff);


            numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupTree);
            GaNumMultivector.ResetAddFactorsCallCount();
            numMvGp    = numFrame.Gp[numMv1, numMv2];
            callsCount = GaNumMultivector.AddFactorsCallCount;
            //factorsCount = ((GaNumMapBilinearTree)numFrame.Gp).FactorsCount;
            diff = symMvGp.ToNumeric() - numMvGp;
            diff.Simplify();
            GaNumMultivector.ResetAddFactorsCallCount();
            textComposer
            .AppendLineAtNewLine("Difference, Lookup Tree: ")
            .AppendLine(callsCount)
            //.AppendLine(factorsCount)
            .AppendLine(diff);


            numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupCoefSums);
            GaNumMultivector.ResetAddFactorsCallCount();
            numMvGp    = numFrame.Gp[numMv1, numMv2];
            callsCount = GaNumMultivector.AddFactorsCallCount;
            //factorsCount = ((GaNumMapBilinearCoefSums)numFrame.Gp).FactorsCount;
            diff = symMvGp.ToNumeric() - numMvGp;
            diff.Simplify();
            GaNumMultivector.ResetAddFactorsCallCount();
            textComposer
            .AppendLineAtNewLine("Difference, Lookup CoefSums: ")
            .AppendLine(callsCount)
            //.AppendLine(factorsCount)
            .AppendLine(diff);


            return(textComposer.ToString());
        }
Exemple #12
0
        private void ProjectiveTables()
        {
            MdSparsityTable = new MarkdownTable();
            var firstColumn = MdSparsityTable.AddColumn("op", MarkdownTableColumnAlignment.Left);

            firstColumn.Add("Geometric Product - Multivectors");
            firstColumn.Add("Geometric Product - Terms");

            firstColumn.Add("Scalar Product - Multivectors");
            firstColumn.Add("Scalar Product - Terms");

            firstColumn.Add("Left Contraction Product - Multivectors");
            firstColumn.Add("Left Contraction Product - Terms");


            MdSizeTable = new MarkdownTable();
            firstColumn = MdSizeTable.AddColumn("op", MarkdownTableColumnAlignment.Left);
            firstColumn.Add("Geometric Product - Hash");
            firstColumn.Add("Geometric Product - Tree");
            firstColumn.Add("Geometric Product - Array");
            firstColumn.Add("Geometric Product - CoefSums");

            firstColumn.Add("Scalar Product - Hash");
            firstColumn.Add("Scalar Product - Tree");
            firstColumn.Add("Scalar Product - Array");
            firstColumn.Add("Scalar Product - CoefSums");

            firstColumn.Add("Left Contraction Product - Hash");
            firstColumn.Add("Left Contraction Product - Tree");
            firstColumn.Add("Left Contraction Product - Array");
            firstColumn.Add("Left Contraction Product - CoefSums");

            for (var n = MinVSpaceDimension; n <= MaxVSpaceDimension; n++)
            {
                Console.Out.WriteLine("Projective Frame " + n);
                Frame = GaNumFrame.CreateProjective(n);

                var sparsityColumn = MdSparsityTable.AddColumn(
                    "n" + n,
                    MarkdownTableColumnAlignment.Right,
                    n.ToString()
                    );

                var sizeColumn = MdSizeTable.AddColumn(
                    "n" + n,
                    MarkdownTableColumnAlignment.Right,
                    n.ToString()
                    );

                var t = GpHashTableSize();
                sparsityColumn.Add(t.Item2.ToString(LongFmt));
                sparsityColumn.Add(t.Item3.ToString(LongFmt));
                sizeColumn.Add(t.Item1.ToString(LongFmt));
                sizeColumn.Add(GpTreeTableSize().ToString(LongFmt));
                sizeColumn.Add(GpArrayTableSize().ToString(LongFmt));
                sizeColumn.Add(GpCoefSumsTableSize().ToString(LongFmt));

                t = SpSparseTableSize();
                sparsityColumn.Add(t.Item2.ToString(LongFmt));
                sparsityColumn.Add(t.Item3.ToString(LongFmt));
                sizeColumn.Add(t.Item1.ToString(LongFmt));
                sizeColumn.Add(SpTreeTableSize().ToString(LongFmt));
                sizeColumn.Add(SpArrayTableSize().ToString(LongFmt));
                sizeColumn.Add(SpCoefSumsTableSize().ToString(LongFmt));

                t = LcpHashTableSize();
                sparsityColumn.Add(t.Item2.ToString(LongFmt));
                sparsityColumn.Add(t.Item3.ToString(LongFmt));
                sizeColumn.Add(t.Item1.ToString(LongFmt));
                sizeColumn.Add(LcpTreeTableSize().ToString(LongFmt));
                sizeColumn.Add(LcpArrayTableSize().ToString(LongFmt));
                sizeColumn.Add(LcpCoefSumsTableSize().ToString(LongFmt));
            }
        }