Пример #1
0
        public GaNumMapTrilinearHash SetBasisBladesMap(int id1, int id2, int id3, IGaNumMultivector value)
        {
            Debug.Assert(ReferenceEquals(value, null) || value.VSpaceDimension == TargetVSpaceDimension);

            _basisBladesMaps[id1, id2, id3] = value.Compactify(true);

            return(this);
        }
Пример #2
0
        public GaNumMapUnilinearHash SetBasisBladeMap(int basisBladeId, IGaNumMultivector targetMv)
        {
            Debug.Assert(ReferenceEquals(targetMv, null) || targetMv.VSpaceDimension == TargetVSpaceDimension);

            _basisBladeMaps[basisBladeId] = targetMv.Compactify(true);

            return(this);
        }
Пример #3
0
        public GaNumMapUnilinearCoefSums SetBasisBladeMap(int domainBasisBladeId, IGaNumMultivector targetMv)
        {
            if (ReferenceEquals(targetMv, null))
            {
                return(this);
            }

            foreach (var term in targetMv.NonZeroTerms)
            {
                SetFactor(term.Key, domainBasisBladeId, term.Value);
            }

            return(this);
        }
Пример #4
0
        public static IGaNumMultivector Compactify(this IGaNumMultivector mv, bool returnZeroMvAsNull = false)
        {
            if (DisableCompactifyMultivectors)
            {
                return(mv);
            }

            if (ReferenceEquals(mv, null))
            {
                return(null);
            }

            //Make sure this is not a temp multivector
            if (mv.IsTemp)
            {
                mv = mv.ToMultivector();
            }

            //If it's zero return null or a zero term depending on returnZeroMvAsNull
            if (mv.IsZero())
            {
                return(returnZeroMvAsNull
                    ? null
                    : GaNumMultivectorTerm.CreateZero(mv.GaSpaceDimension));
            }

            //If it's a non-zero term return it as is
            var termMv = mv as GaNumMultivectorTerm;

            if (!ReferenceEquals(termMv, null))
            {
                return(termMv);
            }

            //It's a full multivector
            var fullMv = (GaNumMultivector)mv;

            //If it's not a term return it after simplification
            if (!mv.IsTerm())
            {
                fullMv.Simplify();
                return(fullMv);
            }

            //It's a full multivector containing a single term
            var term = mv.NonZeroTerms.FirstOrDefault();

            return(GaNumMultivectorTerm.CreateTerm(mv.GaSpaceDimension, term.Key, term.Value));
        }
Пример #5
0
        public GaNumMapBilinearTree SetBasisBladesMap(int id1, int id2, IGaNumMultivector targetMv)
        {
            Debug.Assert(ReferenceEquals(targetMv, null) || targetMv.VSpaceDimension == TargetVSpaceDimension);

            targetMv = targetMv.Compactify(true);

            if (ReferenceEquals(targetMv, null))
            {
                return(this);
            }

            BasisBladesMapTree.SetLeafValue((ulong)id1, (ulong)id2, targetMv);

            return(this);
        }
Пример #6
0
        public static IGaNumMultivectorTemp ToTempMultivector(this IGaNumMultivector mv)
        {
            if (ReferenceEquals(mv, null))
            {
                return(null);
            }

            var tempMv = GaNumMultivector.CreateZeroTemp(mv.GaSpaceDimension);

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

            return(tempMv);
        }
Пример #7
0
 public double this[IGaNumMultivector mv1]
 => _factorsList.Count == 0
         ? 0.0d
         : _factorsList
 .Select(factor => mv1[factor.Item1] * factor.Item2)
 .Sum();
Пример #8
0
 public static bool IsNullOrZero(this IGaNumMultivector mv)
 {
     return(ReferenceEquals(mv, null) || mv.IsZero());
 }
Пример #9
0
        public GaNumMapBilinearCoefSums SetBasisBladesMap(int domainBasisBladeId1, int domainBasisBladeId2, IGaNumMultivector targetMv)
        {
            Debug.Assert(targetMv.VSpaceDimension == TargetVSpaceDimension);

            foreach (var term in targetMv.NonZeroTerms)
            {
                SetFactor(term.Key, domainBasisBladeId1, domainBasisBladeId2, term.Value);
            }

            return(this);
        }