Exemple #1
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);
        }
        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);
        }