Beispiel #1
0
        /// <summary>
        /// Create a derived frame system where the derived frame is the reciprocal of the base frame
        /// </summary>
        /// <param name="baseFrame"></param>
        /// <returns></returns>
        public static GaSymMetricNonOrthogonal CreateReciprocalCbmFrameSystem(GaSymFrame baseFrame)
        {
            if (baseFrame.IsOrthogonal)
            {
                var cbmat = baseFrame.Ipm.Inverse();

                var b2DOm = baseFrame.Ipm.ToOutermorphismTree();
                var d2BOm = cbmat.ToOutermorphismTree();

                var derivedFrame = CreateOrthogonal(cbmat.GetDiagonal());
                return(new GaSymMetricNonOrthogonal(baseFrame, derivedFrame, d2BOm, b2DOm));
            }

            var cbmArray = new MathematicaScalar[baseFrame.VSpaceDimension, baseFrame.VSpaceDimension];

            var mv2 = baseFrame.CreateInverseUnitPseudoScalar();

            for (var i = 0; i < baseFrame.VSpaceDimension; i++)
            {
                var id  = (1 << i) ^ baseFrame.MaxBasisBladeId;
                var mv1 = GaSymMultivector.CreateTerm(baseFrame.GaSpaceDimension, id, SymbolicUtils.Constants.One);

                var mv = baseFrame.Lcp[mv1, mv2];

                foreach (var term in mv.NonZeroTerms)
                {
                    var j = term.Key.BasisBladeIndex();

                    if ((i & 1) == 1)
                    {
                        cbmArray[i, j] = term.Value;
                    }
                    else
                    {
                        cbmArray[i, j] = -term.Value;
                    }
                }
            }

            var cbm = MathematicaMatrix.CreateFullMatrix(SymbolicUtils.Cas, cbmArray);

            return(CreateDerivedCbmFrameSystem(baseFrame, cbm));
        }
Beispiel #2
0
        /// <summary>
        /// Odd Versor Product of a list of basis blades given by their IDs
        /// </summary>
        /// <param name="oddVersor"></param>
        /// <param name="basisBladeIDs"></param>
        /// <returns></returns>
        public IEnumerable <GaSymMultivector> OddVersorProduct(GaSymMultivector oddVersor, IEnumerable <int> basisBladeIDs)
        {
            var oddVersorReverse      = oddVersor.Reverse();
            var oddVersorNorm2Inverse =
                SymbolicUtils.Constants.One / Sp[oddVersor, oddVersorReverse][0]
                .ToMathematicaScalar();
            var oddVersorInverse = oddVersorReverse * oddVersorNorm2Inverse;

            return(basisBladeIDs.Select(id =>
            {
                var mv = GaSymMultivector.CreateTerm(
                    GaSpaceDimension,
                    id,
                    id.BasisBladeIdHasNegativeGradeInv() ? Expr.INT_MINUSONE : Expr.INT_ONE
                    );

                return
                Gp[Gp[oddVersor, mv], oddVersorInverse]
                .GetKVectorPart(id.BasisBladeGrade());
            }));
        }
        internal static GMacValueMultivector CreateTerm(GMacFrameMultivector mvType, int id, MathematicaScalar coef)
        {
            var mvCoefs = GaSymMultivector.CreateTerm(mvType.ParentFrame.GaSpaceDimension, id, coef);

            return(new GMacValueMultivector(mvType, mvCoefs));
        }
Beispiel #4
0
 public GaSymMultivector CreateInverseUnitPseudoScalar()
 {
     //TODO: Review this computation
     return(GaSymMultivector.CreateTerm(GaSpaceDimension, MaxBasisBladeId, UnitPseudoScalarCoef));
 }