public GMacMultivectorBinding BindBasisVectorCoefToConstant(int index, Expr valueExpr) { return(BindCoefToPattern( GMacMathUtils.BasisVectorId(index), GMacScalarBinding.CreateConstant(BaseFrameMultivector.Root, valueExpr) )); }
public GaSymMultivector SetTermCoef(int grade, int index, Expr coef) { return(SetTermCoef( GMacMathUtils.BasisBladeId(grade, index), coef )); }
public GaSymMultivector SetTermCoef(int grade, int index, MathematicaScalar coef) { return(SetTermCoef( GMacMathUtils.BasisBladeId(grade, index), coef.Expression )); }
public GMacMultivectorBinding BindBasisVectorCoefToVariable(int index) { return(BindCoefToPattern( GMacMathUtils.BasisVectorId(index), GMacScalarBinding.CreateVariable(BaseFrameMultivector.Root) )); }
private void GenerateApplyOutermorphismToVectorMacro(AstFrame frameInfo) { var inputsText = ComposeMacroInputs( "om", DefaultStructure.Outermorphism, "mv", frameInfo.FrameMultivector.Name ); var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.AssignToLocalVariable("imageMv", "mv.#E1# * om.ImageV1.@G1@") ); for (var index = 2; index <= frameInfo.VSpaceDimension; index++) { var id = GMacMathUtils.BasisVectorId(index - 1); commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "imageMv", "imageMv + mv.#E" + id + "# * om.ImageV" + index + ".@G1@" ) ); } commandsList.AddEmptyLine(); var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.Outermorphism.ApplyToVector, inputsText, commandsText, "imageMv" ); }
public override string ToString() { var tableText = new TableComposer(TargetGaSpaceDimension, TargetGaSpaceDimension); var basisBladeIds = GMacMathUtils.BasisBladeIDs(TargetVSpaceDimension).ToArray(); foreach (var basisBladeId in basisBladeIds) { tableText.ColumnsInfo[basisBladeId].Header = basisBladeId.BasisBladeName(); tableText.RowsInfo[basisBladeId].Header = basisBladeId.BasisBladeName(); } for (var basisBladeId1 = 0; basisBladeId1 < TargetGaSpaceDimension; basisBladeId1++) { for (var basisBladeId2 = 0; basisBladeId2 < TargetGaSpaceDimension; basisBladeId2++) { var mv = _basisBladesMaps[basisBladeId1, basisBladeId2]; if (mv != null) { tableText.Items[basisBladeId1, basisBladeId2] = mv.ToString(); } } } var text = tableText.ToString(); return(text); }
public GaSymMultivector AddFactor(int grade, int index, Expr coef) { return(AddFactor( GMacMathUtils.BasisBladeId(grade, index), coef )); }
public double this[int grade, int index] { get { return(this[GMacMathUtils.BasisBladeId(grade, index)]); } }
public static GaNumMetricOrthonormal Create(IReadOnlyList <int> basisVectorsSignaturesList) { var vSpaceDim = basisVectorsSignaturesList.Count; var bbsList = new GaNumMetricOrthonormal(vSpaceDim); bbsList[0] = 1; for (var m = 0; m < vSpaceDim; m++) { var bvs = basisVectorsSignaturesList[m]; if (bvs == 0) { continue; } bbsList[1 << m] = bvs; } var idsSeq = GMacMathUtils.BasisBladeIDsSortedByGrade(vSpaceDim, 2); foreach (var id in idsSeq) { int id1, id2; id.SplitBySmallestBasisVectorId(out id1, out id2); bbsList[id] = bbsList[id1] * bbsList[id2]; } return(bbsList); }
public static GaSymMultivector CreateSymbolicKVector(int gaSpaceDim, string baseCoefName, int grade) { return(CreateSymbolic( gaSpaceDim, baseCoefName, GMacMathUtils.BasisBladeIDsOfGrade(gaSpaceDim.ToVSpaceDimension(), grade) )); }
public override GaSymMultivectorTerm MapToTerm(int id1, int id2) { return(GaSymMultivectorTerm.CreateTerm( TargetGaSpaceDimension, id1 ^ id2, GMacMathUtils.IsNegativeEGp(id1, id2) ? Expr.INT_MINUSONE : Expr.INT_ONE )); }
public override GaNumMultivectorTerm MapToTerm(int id1, int id2) { return(GaNumMultivectorTerm.CreateTerm( TargetGaSpaceDimension, id1 ^ id2, GMacMathUtils.IsNegativeEGp(id1, id2) ? -1.0d : 1.0d )); }
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 override GaNumMultivectorTerm MapToTerm(int id1, int id2) { return(GaNumMultivectorTerm.CreateTerm( TargetGaSpaceDimension, id1 ^ id2, GMacMathUtils.IsNegativeEGp(id1, id2) ? -OrthogonalMetric[id1 & id2] : OrthogonalMetric[id1 & id2] )); }
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 override GaSymMultivectorTerm MapToTerm(int id1, int id2) { return(GaSymMultivectorTerm.CreateTerm( TargetGaSpaceDimension, id1 ^ id2, GMacMathUtils.IsNegativeEGp(id1, id2) ? Mfs.Minus[OrthonormalMetric.GetExprSignature(id1 & id2)] : OrthonormalMetric.GetExprSignature(id1 & id2) )); }
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 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); }
public GaNumMultivector GetNumVector(int gaSpaceDim) { var mv = GaNumMultivector.CreateZero(gaSpaceDim); foreach (var basisBladeId in GMacMathUtils.BasisBladeIDsOfGrade(mv.VSpaceDimension, 1)) { mv.SetTermCoef(basisBladeId, GetScalar()); } return(mv); }
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); }
public override GaNumMultivectorTerm MapToTerm(int id1, int id2) { return(GaNumMultivectorTerm.CreateTerm( TargetGaSpaceDimension, 0, GMacMathUtils.IsNonZeroESp(id1, id2) ? (GMacMathUtils.IsNegativeEGp(id1, id1) ? -OrthogonalMetric[id1] : OrthogonalMetric[id1]) : 0.0d )); }
public override GaSymMultivectorTerm MapToTerm(int id1, int id2) { return(GaSymMultivectorTerm.CreateTerm( TargetGaSpaceDimension, id1 ^ id2, GMacMathUtils.IsNonZeroEHip(id1, id2) ? (GMacMathUtils.IsNegativeEGp(id1, id2) ? Mfs.Minus[OrthogonalMetric[id1 & id2]] : OrthogonalMetric[id1 & id2]) : Expr.INT_ZERO )); }
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[] KVectorPartToColumnVector(int grade) { var columnVectorLength = GMacMathUtils.KvSpaceDimension(VSpaceDimension, grade); var columnVector = new Expr[columnVectorLength]; for (var index = 0; index < columnVectorLength; index++) { columnVector[index] = this[grade, index]; } return(columnVector); }
public double this[int grade, int index] { get { var id = GMacMathUtils.BasisBladeId(grade, index); double coef; _termsDictionary.TryGetValue(id, out coef); return(coef); } }
public override GaSymMultivectorTerm MapToTerm(int id1, int id2) { return(GaSymMultivectorTerm.CreateTerm( TargetGaSpaceDimension, 0, GMacMathUtils.IsNonZeroESp(id1, id2) ? (GMacMathUtils.IsNegativeEGp(id1, id1) ? Mfs.Minus[OrthonormalMetric.GetExprSignature(id1)] : OrthonormalMetric.GetExprSignature(id1)) : Expr.INT_ZERO )); }