Пример #1
0
        /// <summary>
        /// Convert this binding pattern into a multivector value
        /// </summary>
        /// <param name="basisBladeToVarName"></param>
        /// <returns></returns>
        public AstValueMultivector ToValue(Func <AstFrameBasisBlade, string> basisBladeToVarName)
        {
            var frameInfo = new AstFrame(BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame);

            var mv = GaSymMultivector.CreateZero(
                BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame.GaSpaceDimension
                );

            foreach (var pair in _patternDictionary)
            {
                mv.AddFactor(
                    pair.Key,
                    pair.Value.IsConstant
                        ? pair.Value.ConstantSymbolicScalar
                        : MathematicaScalar.Create(SymbolicUtils.Cas, basisBladeToVarName(frameInfo.BasisBlade(pair.Key)))
                    );
            }

            return
                (new AstValueMultivector(
                     GMacValueMultivector.Create(
                         BaseFrameMultivector.AssociatedFrameMultivector,
                         mv
                         )
                     ));
        }
Пример #2
0
        public GaSymMultivector GetSymIntegerBlade(int gaSpaceDim, int grade)
        {
            var vSpaceDim = gaSpaceDim.ToVSpaceDimension();

            if (grade < 0 || grade > vSpaceDim)
            {
                return(GaSymMultivector.CreateZero(gaSpaceDim));
            }

            if (grade <= 1 || grade >= vSpaceDim - 1)
            {
                return(GetSymIntegerKVector(gaSpaceDim, grade));
            }

            var mv = GetSymIntegerVector(gaSpaceDim);

            grade--;

            while (grade > 0)
            {
                var v   = GetSymIntegerVector(gaSpaceDim);
                var mv1 = mv.Op(v);

                if (mv1.IsZero())
                {
                    continue;
                }

                mv = mv1;
                grade--;
            }

            return(mv);
        }
Пример #3
0
        public GaSymMultivector GetSymTerm(int gaSpaceDim, int basisBladeId, double minValue, double maxValue)
        {
            var mv = GaSymMultivector.CreateZero(gaSpaceDim);

            mv.SetTermCoef(basisBladeId, GetSymbolicScalar(minValue, maxValue));

            return(mv);
        }
Пример #4
0
        public GaSymMultivector GetSymTerm(int gaSpaceDim, int grade, int index, double minValue, double maxValue)
        {
            var mv = GaSymMultivector.CreateZero(gaSpaceDim);

            var basisBladeId = GMacMathUtils.BasisBladeId(grade, index);

            mv.SetTermCoef(basisBladeId, GetSymbolicScalar(minValue, maxValue));

            return(mv);
        }
Пример #5
0
        public GaSymMultivector GetSymIntegerKVector(int gaSpaceDim, int grade, int minValue, int maxValue)
        {
            var mv = GaSymMultivector.CreateZero(gaSpaceDim);

            foreach (var basisBladeId in GMacMathUtils.BasisBladeIDsOfGrade(mv.VSpaceDimension, grade))
            {
                mv.SetTermCoef(basisBladeId, GetIntegerExpr(minValue, maxValue));
            }

            return(mv);
        }
Пример #6
0
        public GaSymMultivector GetSymKVector(int gaSpaceDim, int grade, double maxValue)
        {
            var mv = GaSymMultivector.CreateZero(gaSpaceDim);

            foreach (var basisBladeId in GMacMathUtils.BasisBladeIDsOfGrade(mv.VSpaceDimension, grade))
            {
                mv.SetTermCoef(basisBladeId, GetSymbolicScalar(maxValue));
            }

            return(mv);
        }
Пример #7
0
        public GaSymMultivector GetSymMultivectorByTerms(int gaSpaceDim, IEnumerable <int> basisBladeIDs)
        {
            var mv = GaSymMultivector.CreateZero(gaSpaceDim);

            foreach (var basisBladeId in basisBladeIDs)
            {
                mv.SetTermCoef(basisBladeId, GetSymbolicScalar());
            }

            return(mv);
        }
Пример #8
0
        public GaSymMultivector GetSymMultivectorFull(int gaSpaceDim, double minValue, double maxValue)
        {
            var mv = GaSymMultivector.CreateZero(gaSpaceDim);

            for (var basisBladeId = 0; basisBladeId < gaSpaceDim; basisBladeId++)
            {
                mv.SetTermCoef(basisBladeId, GetSymbolicScalar(minValue, maxValue));
            }

            return(mv);
        }
Пример #9
0
        public override IGaSymMultivector this[int id1]
        {
            get
            {
                IGaSymMultivector basisBladeMv;
                _basisBladeMaps.TryGetValue(id1, out basisBladeMv);

                return(basisBladeMv
                       ?? GaSymMultivector.CreateZero(TargetGaSpaceDimension));
            }
        }
Пример #10
0
        public GaSymMultivector ToMultivector()
        {
            var mv = GaSymMultivector.CreateZero(GaSpaceDimension);

            foreach (var term in NonZeroExprTerms)
            {
                mv.SetTermCoef(term.Key, term.Value);
            }

            return(mv);
        }
Пример #11
0
 public override IGaSymMultivector this[int id1, int id2, int id3]
 {
     get
     {
         IGaSymMultivector basisBladeMv;
         return
             (!_basisBladesMaps.TryGetValue(id1, id2, id3, out basisBladeMv) || ReferenceEquals(basisBladeMv, null)
                 ? GaSymMultivector.CreateZero(TargetGaSpaceDimension)
                 : basisBladeMv);
     }
 }
Пример #12
0
        public GaSymMultivector GetVectorPart()
        {
            var mv = GaSymMultivector.CreateZero(GaSpaceDimension);

            foreach (var id in GMacMathUtils.BasisVectorIDs(VSpaceDimension))
            {
                var coef = this[id];
                if (!coef.IsNullOrZero())
                {
                    mv.SetTermCoef(id, coef);
                }
            }

            return(mv);
        }
Пример #13
0
        public GaSymMultivector GetSymMultivectorByGrades(int gaSpaceDim, params int[] grades)
        {
            var mv = GaSymMultivector.CreateZero(gaSpaceDim);

            var basisBladeIDs =
                GMacMathUtils.BasisBladeIDsOfGrades(
                    mv.VSpaceDimension,
                    grades
                    );

            foreach (var basisBladeId in basisBladeIDs)
            {
                mv.SetTermCoef(basisBladeId, GetSymbolicScalar());
            }

            return(mv);
        }
Пример #14
0
        public static Dictionary <int, GaSymMultivector> ToOutermorphismDictionary(this Dictionary <int, IGaSymMultivector> linearVectorMaps, int domainVSpaceDim, int targetVSpaceDim)
        {
            var domainGaSpaceDim =
                domainVSpaceDim.ToGaSpaceDimension();

            var targetGaSpaceDim =
                targetVSpaceDim.ToGaSpaceDimension();

            var omMapDict = new Dictionary <int, GaSymMultivector>();

            //Add unit scalar as the image of the 0-basis blade
            omMapDict.Add(0, GaSymMultivector.CreateUnitScalar(targetGaSpaceDim));

            for (var id = 1; id <= domainGaSpaceDim - 1; id++)
            {
                GaSymMultivector basisBladeImage;

                if (id.IsValidBasisVectorId())
                {
                    //Add images of vector basis blades
                    IGaSymMultivector mv;
                    linearVectorMaps.TryGetValue(id.BasisBladeIndex(), out mv);

                    basisBladeImage = mv?.GetVectorPart()
                                      ?? GaSymMultivector.CreateZero(targetGaSpaceDim);
                }
                else
                {
                    //Add images of a higher dimensional basis blade using the outer product
                    //of the images of two lower dimensional basis blades
                    int id1, id2;
                    id.SplitBySmallestBasicPattern(out id1, out id2);

                    basisBladeImage =
                        omMapDict[id1].Op(omMapDict[id2]);
                }

                if (!basisBladeImage.IsZero())
                {
                    omMapDict.Add(id, basisBladeImage);
                }
            }

            return(omMapDict);
        }
Пример #15
0
        public GaSymMultivector ToMultivector()
        {
            var mv = GaSymMultivector.CreateZero(GaSpaceDimension);

            var id = 0;

            foreach (var coef in _coefsArray.Select(c => c.Simplify()))
            {
                if (!coef.IsZero())
                {
                    mv.SetTermCoef(id, coef);
                }

                id++;
            }

            return(mv);
        }
Пример #16
0
        /// <summary>
        /// Convert this binding pattern into a multivector value
        /// </summary>
        /// <param name="varNameTemplate"></param>
        /// <returns></returns>
        public AstValueMultivector ToValue(StringSequenceTemplate varNameTemplate)
        {
            var mv = GaSymMultivector.CreateZero(
                BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame.GaSpaceDimension
                );

            foreach (var pair in _patternDictionary)
            {
                mv.AddFactor(pair.Key, pair.Value.ToMathematicaScalar(varNameTemplate));
            }

            return(new AstValueMultivector(
                       GMacValueMultivector.Create(
                           BaseFrameMultivector.AssociatedFrameMultivector,
                           mv
                           )
                       ));
        }
Пример #17
0
        internal static GMacValueMultivector CreateZero(GMacFrameMultivector mvType)
        {
            var mvCoefs = GaSymMultivector.CreateZero(mvType.ParentFrame.GaSpaceDimension);

            return(new GMacValueMultivector(mvType, mvCoefs));
        }
Пример #18
0
 public override IGaSymMultivector this[int id1, int id2]
 => MapToTemp(id1, id2)?.ToMultivector()
 ?? GaSymMultivector.CreateZero(TargetGaSpaceDimension);
Пример #19
0
 public override IGaSymMultivector this[int id1, int id2]
 => _basisBladesMaps[id1, id2]
 ?? GaSymMultivector.CreateZero(TargetGaSpaceDimension);