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); }
public GaNumMapUnilinearHash SetBasisBladeMap(int basisBladeId, IGaNumMultivector targetMv) { Debug.Assert(ReferenceEquals(targetMv, null) || targetMv.VSpaceDimension == TargetVSpaceDimension); _basisBladeMaps[basisBladeId] = targetMv.Compactify(true); return(this); }
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); }
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)); }
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); }
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); }
public double this[IGaNumMultivector mv1] => _factorsList.Count == 0 ? 0.0d : _factorsList .Select(factor => mv1[factor.Item1] * factor.Item2) .Sum();
public static bool IsNullOrZero(this IGaNumMultivector mv) { return(ReferenceEquals(mv, null) || mv.IsZero()); }
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); }