/// <summary> /// Initializes <c>m_argumentPtr</c> automatically from the <c>m_argumentTypeNames</c>. /// The length of the <c>m_argumentPtr</c> array is adjusted to match <c>m_argumentTypeNames</c>. /// Existing values are not changed. The other values are set in a language-dependent way. /// (currently only for 'C' language). /// /// Does nothing when <c>m_argumentTypeNames</c> is null. /// </summary> /// <param name="S">Used for <c>m_outputLanguage</c> and the types.</param> public void InitArgumentPtrFromTypeNames(Specification S) { if (m_argumentTypeNames == null) return; int i = (m_argumentPtr == null) ? 0 : m_argumentPtr.Length; if (i != m_argumentTypeNames.Length) {// resize the array System.Array.Resize<bool>(ref m_argumentPtr, m_argumentTypeNames.Length); System.Array.Resize<bool>(ref m_argumentArr, m_argumentTypeNames.Length); } if (S.OutputC()) { // if it is not a float or a double, then it is a pointer for (; i < m_argumentTypeNames.Length; i++) { //m_argumentPtr[i] = !(S.IsFloatType(m_argumentTypeNames[i]); m_argumentPtr[i] = S.IsGaTypeName(m_argumentTypeNames[i]); } } }
/// <summary> /// Throws an exception when MV.SanityCheck(int spaceDim, String[] bvNames) throws an exception, or when not all basis blades are listed, /// or when blades of different grades are in the same group. /// </summary> /// <param name="S">Specification of the algebra.</param> /// <param name="bvNames">Names of all basis vectors (used for converting basis blades to strings when throwing the exception).</param> public override void SanityCheck(Specification S, String[] bvNames) { base.SanityCheck(S, bvNames); int spaceDim = S.m_dimension; bool[] present = new bool[1 << spaceDim]; for (int i = 0; i < m_basisBlades.Length; i++) { int grade = -1; for (int j = 0; j < m_basisBlades[i].Length; j++) { if (j == 0) grade = m_basisBlades[i][j].Grade(); else if (m_basisBlades[i][j].Grade() != grade) throw new G25.UserException("In the general multivector type " + Name + ":\n"+ "Group " + (i+1) + " contains blades of different grades."); present[m_basisBlades[i][j].bitmap] = true; } } if ((S.OutputC()) && (MemoryAllocationMethod == MEM_ALLOC_METHOD.DYNAMIC)) throw new G25.UserException("Dynamic memory allocation of general multivector type " + Name + " is not supported for the 'C' language."); for (int i = 0; i < (1 << spaceDim); i++) if (!present[i]) throw new G25.UserException("In the general multivector type " + Name + ":\n"+ "Missing basis blade '" + (new RefGA.BasisBlade((uint)i)).ToString(bvNames) + "'."); }
/// <summary> /// Returns the whether argument 'argIdx' is a pointer. /// If not filled in, 'false' is returned. /// </summary> /// <param name="S">Specification.</param> /// <param name="argIdx">Index of argument.</param> /// <returns>name of argument 'argIdx'.</returns> public bool GetArgumentPtr(Specification S, int argIdx) { if (argIdx < 0) return (S.OutputC()) ? true : false; else if (NbArguments == 0) return false; else return ArgumentPtr[argIdx]; }