示例#1
0
        public static GaNumMultivector EAcp(this GaNumMultivector mv1, GaNumMultivector mv2)
        {
            if (mv1.GaSpaceDimension != mv2.GaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            return(GaNumMultivector
                   .CreateZeroTemp(mv1.GaSpaceDimension)
                   .AddFactors(mv1.GetBiTermsForEAcp(mv2))
                   .ToMultivector());
        }
示例#2
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1, GaNumMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension2)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            return
                (GaNumMultivector
                 .CreateZeroTemp(TargetGaSpaceDimension)
                 .AddFactors(mv1.GetBiTermsForEFdp(mv2)));
        }
示例#3
0
        public override IGaNumMultivector this[int domainBasisBladeId]
        {
            get
            {
                var resultMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

                foreach (var terms in _coefSumsTable.Values)
                {
                    resultMv.AddFactor(
                        terms.TargetBasisBladeId,
                        terms[domainBasisBladeId]
                        );
                }

                return(resultMv.ToMultivector());
            }
        }
示例#4
0
        public override IGaNumMultivector this[int id1, int id2]
        {
            get
            {
                var resultMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

                foreach (var term in _termsList)
                {
                    resultMv.AddFactors(
                        term.Coef,
                        term.LinearMap[id1, id2]
                        );
                }

                return(resultMv.ToMultivector());
            }
        }
示例#5
0
        public static IGaNumMultivectorTemp MapToTemp(this GMacBinaryTree <IGaNumMapUnilinear> mappingTree, GaNumMultivector mv1, GaNumMultivector mv2, int targetGaSpaceDimension)
        {
            if (mv1.GaSpaceDimension != mappingTree.TreeDepth.ToGaSpaceDimension())
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var resultMv = GaNumMultivector.CreateZeroTemp(targetGaSpaceDimension);

            var nodeStack1 = mappingTree.CreateNodesStack();
            var nodeStack2 = mv1.TermsTree.CreateNodesStack();

            while (nodeStack1.Count > 0)
            {
                var node1 = nodeStack1.Pop();
                var node2 = nodeStack2.Pop();

                if (node1.IsLeafNode && !ReferenceEquals(node1.Value, null))
                {
                    var leafScalar = node2.Value;
                    var leafMv     = node1.Value.MapToTemp(mv2);

                    resultMv.AddFactors(
                        leafScalar,
                        leafMv
                        );

                    continue;
                }

                if (node1.HasChildNode0 && node2.HasChildNode0)
                {
                    nodeStack1.Push(node1.ChildNode0);
                    nodeStack2.Push(node2.ChildNode0);
                }

                if (node1.HasChildNode1 && node2.HasChildNode1)
                {
                    nodeStack1.Push(node1.ChildNode1);
                    nodeStack2.Push(node2.ChildNode1);
                }
            }

            return(resultMv);
        }
示例#6
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1, GaNumMultivector mv2, GaNumMultivector mv3)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension || mv3.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            foreach (var term1 in mv1.NonZeroTerms)
            {
                var id1   = term1.Key;
                var coef1 = term1.Value;

                foreach (var term2 in mv2.NonZeroTerms)
                {
                    var id2   = term2.Key;
                    var coef2 = term2.Value;

                    foreach (var term3 in mv3.NonZeroTerms)
                    {
                        var id3   = term3.Key;
                        var coef3 = term3.Value;

                        IGaNumMultivector basisBladeMv;
                        if (!_basisBladesMaps.TryGetValue(id1, id2, id3, out basisBladeMv) ||
                            basisBladeMv == null)
                        {
                            continue;
                        }

                        foreach (var basisBladeMvTerm in basisBladeMv.NonZeroTerms)
                        {
                            tempMv.AddFactor(
                                basisBladeMvTerm.Key,
                                basisBladeMvTerm.Value * coef1 * coef2 * coef3
                                );
                        }
                    }
                }
            }

            return(tempMv);
        }
示例#7
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            foreach (var terms in _coefSumsTable.Values)
            {
                tempMv.AddFactor(
                    terms.TargetBasisBladeId,
                    terms[mv1]
                    );
            }

            return(tempMv);
        }
示例#8
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            foreach (var term in _mappingsList)
            {
                tempMv.AddFactors(
                    term.Coef,
                    term.LinearMap[mv1]
                    );
            }

            return(tempMv);
        }
示例#9
0
        public override IGaNumMultivector this[int id1]
        {
            get
            {
                var resultMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

                foreach (var term in _mappingsList)
                {
                    var mv = term.LinearMap[id1];

                    foreach (var mvTerm in mv.NonZeroTerms)
                    {
                        resultMv.AddFactor(
                            mvTerm.Key,
                            mvTerm.Value * term.Coef
                            );
                    }
                }

                return(resultMv.ToMultivector());
            }
        }
示例#10
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            foreach (var term1 in mv1.NonZeroTerms)
            {
                var basisBladeMv = _basisBladeMaps[term1.Key];
                if (ReferenceEquals(basisBladeMv, null))
                {
                    continue;
                }

                tempMv.AddFactors(term1.Value, basisBladeMv);
            }

            return(tempMv);
        }
示例#11
0
        public static IGaNumMultivectorTemp MapToTemp(this Matrix mappingMatrix, GaNumMultivector mv1)
        {
            if (mv1.GaSpaceDimension != mappingMatrix.ColumnCount)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(mappingMatrix.RowCount);

            foreach (var term in mv1.NonZeroTerms)
            {
                var id   = term.Key;
                var coef = term.Value;

                for (var row = 0; row < mappingMatrix.RowCount; row++)
                {
                    tempMv.AddFactor(id, mappingMatrix[row, id] * coef);
                }
            }

            return(tempMv);
        }
示例#12
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            var nodeStack1 = BasisBladesMapTree.CreateNodesStack();
            var nodeStack2 = mv1.TermsTree.CreateNodesStack();

            while (nodeStack1.Count > 0)
            {
                var node1 = nodeStack1.Pop();
                var node2 = nodeStack2.Pop();

                if (node1.IsLeafNode)
                {
                    tempMv.AddFactors(node2.Value, node1.Value);

                    continue;
                }

                if (node1.HasChildNode0 && node2.HasChildNode0)
                {
                    nodeStack1.Push(node1.ChildNode0);
                    nodeStack2.Push(node2.ChildNode0);
                }

                if (node1.HasChildNode1 && node2.HasChildNode1)
                {
                    nodeStack1.Push(node1.ChildNode1);
                    nodeStack2.Push(node2.ChildNode1);
                }
            }

            return(tempMv);
        }
示例#13
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1, GaNumMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            foreach (var biTerm in mv1.GetBiTermsForEGp(mv2))
            {
                IGaNumMultivector basisBladeMv;
                _basisBladesMaps.TryGetValue(biTerm.Id1, biTerm.Id2, out basisBladeMv);
                if (ReferenceEquals(basisBladeMv, null))
                {
                    continue;
                }

                tempMv.AddFactors(biTerm.ValuesProduct, basisBladeMv);
            }

            return(tempMv);
        }
示例#14
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1, GaNumMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            var mvNodeStack1 = mv1.TermsTree.CreateNodesStack();
            var mvNodeStack2 = mv2.TermsTree.CreateNodesStack();

            var idStack1 = mv1.TermsTree.CreateNodeIDsStack();
            var idStack2 = mv2.TermsTree.CreateNodeIDsStack();

            while (mvNodeStack1.Count > 0)
            {
                var mvNode1 = mvNodeStack1.Pop();
                var mvNode2 = mvNodeStack2.Pop();

                var id1 = idStack1.Pop();
                var id2 = idStack2.Pop();

                if (mvNode1.IsLeafNode)
                {
                    var basisBladeMv = _basisBladesMaps[id1, id2];

                    if (!ReferenceEquals(basisBladeMv, null))
                    {
                        tempMv.AddFactors(mvNode1.Value * mvNode2.Value, basisBladeMv);
                    }

                    continue;
                }

                if (mvNode1.HasChildNode0)
                {
                    if (mvNode2.HasChildNode0)
                    {
                        mvNodeStack1.Push(mvNode1.ChildNode0);
                        mvNodeStack2.Push(mvNode2.ChildNode0);

                        idStack1.Push(id1);
                        idStack2.Push(id2);
                    }

                    if (mvNode2.HasChildNode1)
                    {
                        mvNodeStack1.Push(mvNode1.ChildNode0);
                        mvNodeStack2.Push(mvNode2.ChildNode1);

                        idStack1.Push(id1);
                        idStack2.Push(id2 | mvNode2.ChildNode1.BitMask);
                    }
                }

                if (mvNode1.HasChildNode1)
                {
                    if (mvNode2.HasChildNode0)
                    {
                        mvNodeStack1.Push(mvNode1.ChildNode1);
                        mvNodeStack2.Push(mvNode2.ChildNode0);

                        idStack1.Push(id1 | mvNode1.ChildNode1.BitMask);
                        idStack2.Push(id2);
                    }

                    if (mvNode2.HasChildNode1)
                    {
                        mvNodeStack1.Push(mvNode1.ChildNode1);
                        mvNodeStack2.Push(mvNode2.ChildNode1);

                        idStack1.Push(id1 | mvNode1.ChildNode1.BitMask);
                        idStack2.Push(id2 | mvNode2.ChildNode1.BitMask);
                    }
                }
            }

            //foreach (var biTerm in mv1.GetBiTermsForEGp(mv2))
            //{
            //    var basisBladeMv = _basisBladesMaps[biTerm.Id1, biTerm.Id2];
            //    if (ReferenceEquals(basisBladeMv, null))
            //        continue;

            //    tempMv.AddFactors(biTerm.ValuesProduct, basisBladeMv);
            //}

            return(tempMv);
        }
示例#15
0
        public override IGaNumMultivectorTemp MapToTemp(GaNumMultivector mv1, GaNumMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacNumericException("Multivector size mismatch");
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            var mapNodeStack = BasisBladesMapTree.CreateNodesStack();

            var mvNodeStack1 = mv1.TermsTree.CreateNodesStack();
            var mvNodeStack2 = mv2.TermsTree.CreateNodesStack();

            while (mapNodeStack.Count > 0)
            {
                var mapNode = mapNodeStack.Pop();

                var mvNode1 = mvNodeStack1.Pop();
                var mvNode2 = mvNodeStack2.Pop();

                if (mapNode.IsLeafNode)
                {
                    tempMv.AddFactors(
                        mvNode1.Value * mvNode2.Value,
                        mapNode.Value
                        );

                    continue;
                }

                if (mvNode1.HasChildNode0)
                {
                    if (mvNode2.HasChildNode0 && mapNode.HasChildNode00)
                    {
                        mapNodeStack.Push(mapNode.ChildNode00);

                        mvNodeStack1.Push(mvNode1.ChildNode0);
                        mvNodeStack2.Push(mvNode2.ChildNode0);
                    }

                    if (mvNode2.HasChildNode1 && mapNode.HasChildNode10)
                    {
                        mapNodeStack.Push(mapNode.ChildNode10);

                        mvNodeStack1.Push(mvNode1.ChildNode0);
                        mvNodeStack2.Push(mvNode2.ChildNode1);
                    }
                }

                if (mvNode1.HasChildNode1)
                {
                    if (mvNode2.HasChildNode0 && mapNode.HasChildNode01)
                    {
                        mapNodeStack.Push(mapNode.ChildNode01);

                        mvNodeStack1.Push(mvNode1.ChildNode1);
                        mvNodeStack2.Push(mvNode2.ChildNode0);
                    }

                    if (mvNode2.HasChildNode1 && mapNode.HasChildNode11)
                    {
                        mapNodeStack.Push(mapNode.ChildNode11);

                        mvNodeStack1.Push(mvNode1.ChildNode1);
                        mvNodeStack2.Push(mvNode2.ChildNode1);
                    }
                }
            }

            return(tempMv);
        }