Пример #1
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv1, GaSymMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension2)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            return(GaSymMultivector
                   .CreateZeroTemp(TargetGaSpaceDimension)
                   .AddFactors(mv1.GetBiTermsForECp(mv2)));
        }
Пример #2
0
        public override IGaSymMultivectorTemp MapToTemp(int id1, int id2)
        {
            var tempMultivector = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            tempMultivector.SetTermCoef(
                id1 ^ id2,
                GMacMathUtils.IsNegativeEGp(id1, id2),
                OrthogonalMetric[id1 & id2]
            );

            return tempMultivector;
        }
Пример #3
0
        public override IGaSymMultivectorTemp MapToTemp(int id1, int id2)
        {
            var tempMultivector = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            tempMultivector.SetTermCoef(
                id1 ^ id2,
                GMacMathUtils.IsNegativeEGp(id1, id2),
                OrthonormalMetric.GetExprSignature(id1 & id2)
                );

            return(tempMultivector);
        }
Пример #4
0
        public override IGaSymMultivectorTemp MapToTemp(int id1, int id2)
        {
            var tempMultivector = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            tempMultivector.SetTermCoef(
                id1 ^ id2,
                GMacMathUtils.IsNegativeEGp(id1, id2),
                Expr.INT_ONE
                );

            return(tempMultivector);
        }
Пример #5
0
        public static GaSymMultivector EHip(this GaSymMultivector mv1, GaSymMultivector mv2)
        {
            if (mv1.GaSpaceDimension != mv2.GaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            return(GaSymMultivector
                   .CreateZeroTemp(mv1.GaSpaceDimension)
                   .AddFactors(mv1.GetBiTermsForEHip(mv2))
                   .ToMultivector());
        }
Пример #6
0
        public override IGaSymMultivectorTemp MapToTemp(int domainBasisBladeId1, int domainBasisBladeId2)
        {
            var resultMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

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

            return(resultMv);
        }
Пример #7
0
        public override IGaSymMultivectorTemp MapToTemp(int id1, int id2)
        {
            var resultMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

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

            return(resultMv);
        }
Пример #8
0
        public override IGaSymMultivectorTemp MapToTemp(int id1, int id2)
        {
            var tempMultivector = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            if (GMacMathUtils.IsNonZeroESp(id1, id2))
            {
                tempMultivector.AddFactor(
                    0,
                    GMacMathUtils.IsNegativeEGp(id1, id1),
                    Expr.INT_ONE
                    );
            }

            return(tempMultivector);
        }
Пример #9
0
        public override IGaSymMultivectorTemp MapToTemp(int id1, int id2)
        {
            var tempMultivector = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            if (GMacMathUtils.IsNonZeroESp(id1, id2))
            {
                tempMultivector.SetTermCoef(
                    0,
                    GMacMathUtils.IsNegativeEGp(id1, id1),
                    OrthogonalMetric[id1]
                    );
            }

            return(tempMultivector);
        }
Пример #10
0
        public override IGaSymMultivectorTemp MapToTemp(int id1, int id2, int id3)
        {
            var tempMultivector = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            IGaSymMultivector basisBladeMv;

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

            tempMultivector.AddFactors(
                Expr.INT_ONE,
                basisBladeMv
                );

            return(tempMultivector);
        }
Пример #11
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv1)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var resultMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

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

            return(resultMv);
        }
Пример #12
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv1, GaSymMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var resultMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            foreach (var term in _termsList)
            {
                resultMv.AddFactors(
                    term.Coef.Expression,
                    term.LinearMap.MapToTemp(mv1, mv2)
                    );
            }

            return(resultMv);
        }
Пример #13
0
        public static GaTreeMultivector Op(this GaTreeMultivector mv1, GaTreeMultivector mv2)
        {
            if (mv1.GaSpaceDimension != mv2.GaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var resultMv = GaSymMultivector.CreateZeroTemp(mv1.GaSpaceDimension);

            var signList = OpSign(mv1.VSpaceDimension);

            for (var basisBladeId = 0; basisBladeId < mv1.GaSpaceDimension; basisBladeId++)
            {
                var indexList = new List <int>();

                indexList =
                    basisBladeId
                    .PatternToBooleans(mv1.VSpaceDimension)
                    .Aggregate(
                        indexList,
                        (currentList, bitFlag) =>
                        OpOneLevel(currentList, bitFlag).ToList()
                        )
                    .Select(idx => idx.ReverseBits(mv1.VSpaceDimension))
                    .ToList();

                var i = 0;
                foreach (var index in indexList)
                {
                    resultMv.AddFactor(
                        basisBladeId,
                        signList[i],
                        Mfs.Times[mv1[index], mv2[basisBladeId ^ index]]
                        );

                    i++;
                }
            }

            return(resultMv.ToTreeMultivector());
        }
Пример #14
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv1, GaSymMultivector mv2, GaSymMultivector mv3)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension || mv3.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var tempMultivector = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

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

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

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

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

                        tempMultivector.AddFactors(
                            Mfs.Times[coef1, coef2, coef3],
                            basisBladeMv
                            );
                    }
                }
            }

            return(tempMultivector);
        }
Пример #15
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv1)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var tempMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

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

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

            return(tempMv);
        }
Пример #16
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv)
        {
            if (mv.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var resultMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            var nodeStack1 = _basisBladeMaps.CreateNodesStack();
            var nodeStack2 = mv.TermsTree.CreateNodesStack();

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

                if (node1.IsLeafNode)
                {
                    resultMv.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(resultMv);
        }
Пример #17
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv1, GaSymMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var tempMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            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);
        }
Пример #18
0
 public override IGaSymMultivectorTemp MapToTemp(int id1)
 {
     return(_basisBladeMaps.GetLeafValue((ulong)id1)?.ToTempMultivector()
            ?? GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension));
 }
Пример #19
0
        public override IGaSymMultivectorTemp MapToTemp(GaSymMultivector mv1, GaSymMultivector mv2)
        {
            if (mv1.GaSpaceDimension != DomainGaSpaceDimension || mv2.GaSpaceDimension != DomainGaSpaceDimension)
            {
                throw new GMacSymbolicException("Multivector size mismatch");
            }

            var tempMv = GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension);

            var mapNodeStack = _basisBladesMaps.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(
                        Mfs.Times[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);
        }
Пример #20
0
 public override IGaSymMultivectorTemp MapToTemp(int id1, int id2)
 {
     return(_basisBladesMaps[id1, id2]?.ToTempMultivector()
            ?? GaSymMultivector.CreateZeroTemp(TargetGaSpaceDimension));
 }