public GaSymMultivector AddFactor(int grade, int index, Expr coef) { return(AddFactor( GMacMathUtils.BasisBladeId(grade, index), coef )); }
public GMacMultivectorBinding BindCoefToConstant(int grade, int index, Expr valueExpr) { return(BindCoefToPattern( GMacMathUtils.BasisBladeId(grade, index), GMacScalarBinding.CreateConstant(BaseFrameMultivector.Root, valueExpr) )); }
public GaSymMultivector SetTermCoef(int grade, int index, MathematicaScalar coef) { return(SetTermCoef( GMacMathUtils.BasisBladeId(grade, index), coef.Expression )); }
public double this[int grade, int index] { get { return(this[GMacMathUtils.BasisBladeId(grade, index)]); } }
public GaSymMultivector SetTermCoef(int grade, int index, Expr coef) { return(SetTermCoef( GMacMathUtils.BasisBladeId(grade, index), coef )); }
public GMacMultivectorBinding BindCoefToVariable(int grade, int index) { return(BindCoefToPattern( GMacMathUtils.BasisBladeId(grade, index), GMacScalarBinding.CreateVariable(BaseFrameMultivector.Root) )); }
public GMacMultivectorBinding UnBindCoefs(int grade, IEnumerable <int> indexes) { foreach (var index in indexes) { _patternDictionary.Remove(GMacMathUtils.BasisBladeId(grade, index)); } return(this); }
public Expr this[int grade, int index] { get { var id = GMacMathUtils.BasisBladeId(grade, index); return((id == TermId) ? TermCoef : Expr.INT_ZERO); } }
public double this[int grade, int index] { get { var id = GMacMathUtils.BasisBladeId(grade, index); return((id == TermId) ? TermCoef : 0.0d); } }
private void GenerateOutermorphismToLinearTransformMacro(AstFrame frameInfo) { var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.LinearTransform, "newTr"), GMacDslSyntaxFactory.EmptyLine(), GMacDslSyntaxFactory.FixedCode("let newTr.ImageE0 = Multivector(#E0# = '1')"), GMacDslSyntaxFactory.EmptyLine() ); for (var index = 1; index <= frameInfo.VSpaceDimension; index++) { var id = GMacMathUtils.BasisVectorId(index - 1); commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "newTr.ImageE" + id, "om.ImageV" + index + ".@G1@" ) ); } commandsList.AddEmptyLine(); for (var grade = 2; grade <= frameInfo.VSpaceDimension; grade++) { var kvSpaceDim = frameInfo.KvSpaceDimension(grade); for (var index = 0; index < kvSpaceDim; index++) { int id = GMacMathUtils.BasisBladeId(grade, index); int id1, id2; id.SplitBySmallestBasisVectorId(out id1, out id2); commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "newTr.ImageE" + id, " newTr.ImageE" + id1 + " op newTr.ImageE" + id2 ) ); } commandsList.AddEmptyLine(); } var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.Outermorphism.ToLinearTransform, ComposeMacroInputs("om", DefaultStructure.Outermorphism), DefaultStructure.LinearTransform, commandsText, "newTr" ); }
public GaNumMultivector GetNumTerm(int gaSpaceDim, int grade, int index) { var mv = GaNumMultivector.CreateZero(gaSpaceDim); var basisBladeId = GMacMathUtils.BasisBladeId(grade, index); mv.SetTermCoef(basisBladeId, GetScalar()); return(mv); }
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); }
public Expr this[int grade, int index] { get { return(this[GMacMathUtils.BasisBladeId(grade, index)]); } set { this[GMacMathUtils.BasisBladeId(grade, index)] = value; } }
public double this[int grade, int index] { get { var id = GMacMathUtils.BasisBladeId(grade, index); double coef; _termsDictionary.TryGetValue(id, out coef); return(coef); } }
public virtual IEnumerable <Tuple <int, IGaSymMultivector> > BasisVectorMaps() { for (var index = 0; index < DomainVSpaceDimension; index++) { var mv = this[GMacMathUtils.BasisBladeId(1, index)]; if (!mv.IsNullOrZero()) { yield return(new Tuple <int, IGaSymMultivector>(index, mv)); } } }
public Expr this[int grade, int index] { get { var id = GMacMathUtils.BasisBladeId(grade, index); List <Expr> coef; _termsDictionary.TryGetValue(id, out coef); return(ReferenceEquals(coef, null) ? Expr.INT_ZERO : coef.Simplify()); } }
/// <summary> /// Create a default subspaces of k-vectors with a given grade and name /// </summary> private void DefineDefaultSubspaces_KVectors(GMacFrame frame, int grade, string subspaceName) { var basisCount = GMacMathUtils.KvSpaceDimension(frame.VSpaceDimension, grade); var idsList = new List <int>(basisCount); for (var index = 0; index < basisCount; index++) { idsList.Add(GMacMathUtils.BasisBladeId(grade, index)); } var subspaceSignature = BooleanPattern.CreateFromTrueIndexes(frame.GaSpaceDimension, idsList); var subspace = frame.DefineSubspace(subspaceName, subspaceSignature); subspace.AddCodeLocation(Context.GetCodeLocation(frame.ParseNode)); }
public override IEnumerable <Tuple <int, int, IGaNumMultivector> > BasisVectorsMaps() { for (var index1 = 0; index1 < DomainVSpaceDimension; index1++) { for (var index2 = 0; index2 < DomainVSpaceDimension2; index2++) { var id1 = GMacMathUtils.BasisBladeId(1, index1); var id2 = GMacMathUtils.BasisBladeId(1, index2); var mv = MapToTerm(id1, id2); if (!mv.IsZero()) { yield return(new Tuple <int, int, IGaNumMultivector>(index1, index2, mv)); } } } }
public virtual IEnumerable <Tuple <int, int, IGaSymMultivector> > BasisVectorsMaps() { for (var index1 = 0; index1 < DomainVSpaceDimension; index1++) { for (var index2 = 0; index2 < DomainVSpaceDimension; index2++) { var id1 = GMacMathUtils.BasisBladeId(1, index1); var id2 = GMacMathUtils.BasisBladeId(1, index2); var mv = this[id1, id2]; if (!mv.IsNullOrZero()) { yield return(new Tuple <int, int, IGaSymMultivector>(index1, index2, mv)); } } } }
private void GenerateTransposeOutermorphismMacro(AstFrame frameInfo) { var inputsText = ComposeMacroInputs( "om", DefaultStructure.Outermorphism ); var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.Outermorphism, "newOm"), GMacDslSyntaxFactory.EmptyLine() ); var componentsText = new ListComposer("," + Environment.NewLine); for (var index1 = 1; index1 <= frameInfo.VSpaceDimension; index1++) { componentsText.Clear(); var id1 = GMacMathUtils.BasisBladeId(1, index1 - 1); commandsList.AddFixedCode("let newOm.ImageV" + index1 + " = Multivector("); for (var index2 = 1; index2 <= frameInfo.VSpaceDimension; index2++) { var id2 = GMacMathUtils.BasisBladeId(1, index2 - 1); componentsText.Add(" #E" + id2 + "# = om.ImageV" + index2 + ".#E" + id1 + "#"); } commandsList.AddFixedCode(componentsText.ToString()); commandsList.AddFixedCode(")"); commandsList.AddEmptyLine(); } var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.Outermorphism.Transpose, inputsText, DefaultStructure.Outermorphism, commandsText, "newOm" ); }
public GaNumMultivector SetTermCoef(int grade, int index, bool isNegative, double coef) { var id = GMacMathUtils.BasisBladeId(grade, index); var value = isNegative ? -coef : coef; var node = TermsTree; for (var i = VSpaceDimension - 1; i > 0; i--) { var bitPattern = (1 << i) & id; node = node.GetOrAddInternalChildNode(bitPattern != 0); } if ((1 & id) != 0) { if (node.HasChildNode1) { node.LeafChildNode1.Value = value; } else { node.ResetLeafChildNode1(value); } return(this); } if (node.HasChildNode0) { node.LeafChildNode0.Value = value; } else { node.ResetLeafChildNode0(value); } return(this); }
public GaNumMultivector AddFactor(int grade, int index, double coef) { AddFactorsCallCount++; var id = GMacMathUtils.BasisBladeId(grade, index); var node = TermsTree; for (var i = VSpaceDimension - 1; i > 0; i--) { var bitPattern = (1 << i) & id; node = node.GetOrAddInternalChildNode(bitPattern != 0); } if ((1 & id) != 0) { if (node.HasChildNode1) { node.LeafChildNode1.Value += coef; } else { node.ResetLeafChildNode1(coef); } return(this); } if (node.HasChildNode0) { node.LeafChildNode0.Value += coef; } else { node.ResetLeafChildNode0(coef); } return(this); }
/// <summary> /// Create the default subspace of odd multivectors named @odd@ /// </summary> /// <returns></returns> private GMacFrameSubspace DefineDefaultSubspaces_Odd(GMacFrame frame) { var idsList = new List <int>(frame.GaSpaceDimension); for (var grade = 1; grade <= frame.VSpaceDimension; grade = grade + 2) { var basisCount = GMacMathUtils.KvSpaceDimension(frame.VSpaceDimension, grade); for (var index = 0; index < basisCount; index++) { idsList.Add(GMacMathUtils.BasisBladeId(grade, index)); } } const string subspaceName = "Odd"; var subspaceSignature = BooleanPattern.CreateFromTrueIndexes(frame.GaSpaceDimension, idsList); var subspace = frame.DefineSubspace(subspaceName, subspaceSignature); subspace.AddCodeLocation(Context.GetCodeLocation(frame.ParseNode)); return(subspace); }
public Expr this[int grade, int index] => this[GMacMathUtils.BasisBladeId(grade, index)];
public double this[int grade, int index] => _termsArray[GMacMathUtils.BasisBladeId(grade, index)];
public Expr this[int grade, int index] => _coefsArray[GMacMathUtils.BasisBladeId(grade, index)].Simplify();
public GMacMultivectorBinding UnBindCoef(int grade, int index) { _patternDictionary.Remove(GMacMathUtils.BasisBladeId(grade, index)); return(this); }
public string BasisBladeName(int grade, int index) { return(AssociatedFrame.BasisVectorNames.ConcatenateUsingPattern( GMacMathUtils.BasisBladeId(grade, index), "E0", "^" )); }
internal AstFrameBasisBlade(GMacFrame frame, int grade, int index) { AssociatedMultivector = frame.MultivectorType; BasisBladeId = GMacMathUtils.BasisBladeId(grade, index); }
public IGaSymMultivector this[int grade1, int index1] => this[GMacMathUtils.BasisBladeId(grade1, index1)];