public static bool CanConvertSumToGmv(Specification S, SMV smv1, SMV smv2) { if (S.m_GMV.MemoryAllocationMethod == GMV.MEM_ALLOC_METHOD.PARITY_PURE) { return((smv1.IsEven() && smv2.IsEven()) || (smv1.IsOdd() && smv2.IsOdd())); } else { return(true); } }
protected void SetValue(List <G25.rsbbp.BasisBlade> value) { SMV smv = m_type as SMV; // allocate memory for values; coordinates not specified in 'value' are assumed to be 0. m_value = new double[smv.NbNonConstBasisBlade]; if (value == null) { value = new List <G25.rsbbp.BasisBlade>(); } foreach (G25.rsbbp.BasisBlade B in value) { if (!B.IsConstant) { throw new Exception("G25.ConstantSMV(): expected only constant values for constant " + m_name + " (basis blade " + B.GetBasisBlade.ToString() + ")"); } // uint bitmap = B.GetBasisBlade.bitmap; int elementIdx = smv.GetElementIdx(B.GetBasisBlade); if (elementIdx < 0) { // This basis blade is not in the type. This is an error unles the value is 0 if (B.ConstantValue != 0.0) { throw new Exception("G25.ConstantSMV(): constant " + m_name + ", type " + m_type.GetName() + ": cannot represent this basis blade: " + B.GetBasisBlade); } } if (smv.IsCoordinateConstant(elementIdx)) // if constant in SMV: check is values match { if (smv.ConstBasisBladeValue(smv.BladeIdxToConstBladeIdx(elementIdx)) != B.ConstantValue) { throw new Exception("G25.ConstantSMV(): constant " + m_name + ", type " + m_type.GetName() + ": constant value for basis blade: " + B.GetBasisBlade + " does not match with type."); } } else // if variable coordinate: set the value { int nonConstCoordIdx = smv.BladeIdxToNonConstBladeIdx(elementIdx); m_value[nonConstCoordIdx] = B.ConstantValue; } } }
/// <summary> /// Adds a new specialized multivector (checks if name is not already in use, throws if it is.). /// </summary> public void AddSpecializedMV(SMV smv) { if (IsTypeName(smv.Name)) throw new G25.UserException("While adding a specialized multivector type: the name '" + smv.Name + "' is already a typename."); else m_SMV.Add(smv); }
public static bool CanConvertSumToGmv(Specification S, SMV smv1, SMV smv2) { if (S.m_GMV.MemoryAllocationMethod == GMV.MEM_ALLOC_METHOD.PARITY_PURE) return (smv1.IsEven() && smv2.IsEven()) || (smv1.IsOdd() && smv2.IsOdd()); else return true; }
public ConstantSMV(string name, SMV type, List <G25.rsbbp.BasisBlade> value, string comment) : base(name, type, comment) { SetValue(value); }
public ConstantSMV(string name, SMV type, List<G25.rsbbp.BasisBlade> value, string comment) : base(name, type, comment) { SetValue(value); }
/// <summary> /// Parses an XML_SMV element and stores the result. /// /// The XML_SMV element should contain the name, and optionally the type, const property and constant name. /// /// If the const property is true and no name is specified, the regular name is used as the name /// of the singleton constant and the name of the type is renamed to name_t. /// /// </summary> /// <param name="E">XML_SMV element</param> private static void ParseSMVelementAndAttributes(Specification S, XmlElement E) { string typeName = null; bool isConstant = false; string constantName = null; SMV.MULTIVECTOR_TYPE mvType = SMV.MULTIVECTOR_TYPE.MULTIVECTOR; { // handle attributes XmlAttributeCollection A = E.Attributes; // handle all attributes for (int i = 0; i < A.Count; i++) { // name if (A[i].Name == XML_NAME) typeName = A[i].Value; // const else if (A[i].Name == XML_CONST) isConstant = (A[i].Value.ToLower() == XML_TRUE); // type else if (A[i].Name == XML_TYPE) { if (A[i].Value == XML_MULTIVECTOR) mvType = SMV.MULTIVECTOR_TYPE.MULTIVECTOR; else if (A[i].Value == XML_BLADE) mvType = SMV.MULTIVECTOR_TYPE.BLADE; else if (A[i].Value == XML_ROTOR) mvType = SMV.MULTIVECTOR_TYPE.ROTOR; else if (A[i].Value == XML_VERSOR) mvType = SMV.MULTIVECTOR_TYPE.VERSOR; else throw new G25.UserException("XML parsing error: Invalid value for attribute'" + XML_TYPE + "':'" + A[i].Value + "' in element '" + XML_SMV + "'."); } } // sanity check on name if (typeName == null) throw new G25.UserException("XML parsing error: Missing '" + XML_NAME + "' attribute in element '" + XML_SMV + "'."); // if constant and no constantName provided, use the typeName as the constantName, and set typeName to typeName + "_t" if (isConstant && (constantName == null)) { // if a constant should be generated and no constant name is specified constantName = typeName; typeName = constantName + Specification.CONSTANT_TYPE_SUFFIX; } // check if name is already present if (S.IsTypeName(typeName)) throw new G25.UserException("In specialized multivector definition: type '" + typeName + "' already exists."); } // end of 'handle attributes' // parse list of basis blades and optional comment List<G25.rsbbp.BasisBlade> L = ParseBasisBladeList(S, E.FirstChild, typeName); string comment = ParseComment(S, E.FirstChild); if (L == null) throw new G25.UserException("XML parsing error in element '" + XML_SMV + "': Missing basis blade list for specialized multivector '" + typeName + "'"); SMV smv = new SMV(typeName, L.ToArray(), mvType, comment); // add new type to list of specialized multivectors S.AddSpecializedMV(smv); // if constant name is specified, the user wants a constant: if (constantName != null) S.AddConstant(new ConstantSMV(constantName, smv, null, comment)); }