public IGaSymMultivectorTemp AddFactor(int id, Expr coef) { var index = (ulong)id; var node = _termsTree.GetLeafNode(index); if (ReferenceEquals(node, null)) { _termsTree.SetLeafValue( index, new List <Expr>(1) { coef } ); return(this); } if (ReferenceEquals(node.Value, null)) { node.Value = new List <Expr>(1) { coef } } ; else { node.Value.Add(coef); } return(this); }
//public static BinaryTreeNode<MathematicaScalar> ComputeBasisBladesSignatures(this IReadOnlyList<MathematicaScalar> basisVectorsSignaturesList) //{ // var vSpaceDim = basisVectorsSignaturesList.Count; // var bbsList = new BinaryTreeNode<MathematicaScalar>(vSpaceDim); // bbsList.SetValue(0ul, Constants.One); // for (var m = 0; m < vSpaceDim; m++) // { // var bvs = basisVectorsSignaturesList[m]; // if (bvs.IsNullOrZero()) continue; // bbsList.SetValue(1ul << m, bvs); // } // var idsSeq = FrameUtils.BasisBladeIDsSortedByGrade(vSpaceDim, 2); // foreach (var id in idsSeq) // { // int id1, id2; // id.SplitBySmallestBasisVectorId(out id1, out id2); // var bvs1 = bbsList.GetValue((ulong)id1); // if (bvs1.IsNullOrZero()) continue; // var bvs2 = bbsList.GetValue((ulong)id2); // if (bvs2.IsNullOrZero()) continue; // bbsList.SetValue((ulong)id, bvs1 * bvs2); // } // return bbsList; //} public static GMacBinaryTree <int> ComputeBasisBladesSignatures(this IReadOnlyList <int> basisVectorsSignaturesList) { var vSpaceDim = basisVectorsSignaturesList.Count; var bbsList = new GMacBinaryTree <int>(vSpaceDim); bbsList.SetLeafValue(0ul, 1); for (var m = 0; m < vSpaceDim; m++) { var bvs = basisVectorsSignaturesList[m]; if (bvs == 0) { continue; } bbsList.SetLeafValue(1ul << m, bvs); } var idsSeq = GMacMathUtils.BasisBladeIDsSortedByGrade(vSpaceDim, 2); foreach (var id in idsSeq) { int id1, id2; id.SplitBySmallestBasisVectorId(out id1, out id2); var bvs1 = bbsList.GetLeafValue((ulong)id1); if (bvs1 == 0) { continue; } var bvs2 = bbsList.GetLeafValue((ulong)id2); if (bvs2 == 0) { continue; } bbsList.SetLeafValue((ulong)id, bvs1 * bvs2); } return(bbsList); }
public GaSymMapUnilinearTree SetBasisBladeMap(int basisBladeId, IGaSymMultivector targetMv) { Debug.Assert(ReferenceEquals(targetMv, null) || targetMv.VSpaceDimension == TargetVSpaceDimension); targetMv = targetMv.Compactify(true); if (ReferenceEquals(targetMv, null)) { return(this); } _basisBladeMaps.SetLeafValue((ulong)basisBladeId, targetMv); return(this); }