} // end of CheckTestingDepencies() /// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); if (m_trueGmvFunc) // GMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomVersorFuncName"] = m_randomVersorFuncName[FT.type]; argTable["subtractFuncName"] = m_subtractGmvFuncName[FT.type]; argTable["gpFuncName"] = m_gpFuncName[FT.type]; argTable["versorInverseFuncName"] = m_versorInverseFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testIGP_GMV", argTable); } else if ((m_smv1 != null) && (m_smv2 != null) && m_smv1.CanConvertToGmv(m_specification) && m_smv2.CanConvertToGmv(m_specification) && (m_specification.GetType(m_fgs.m_returnTypeName) as G25.MV).CanConvertToGmv(m_specification)) { // SMV test testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["smv1"] = m_smv1; argTable["smv2"] = m_smv2; argTable["smv1Name"] = FT.GetMangledName(m_specification, m_smv1.Name); argTable["smv2Name"] = FT.GetMangledName(m_specification, m_smv2.Name); argTable["smvRName"] = FT.GetMangledName(m_specification, m_fgs.m_returnTypeName); argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomSmv1FuncName"] = m_randomSmv1FuncName[FT.type]; argTable["randomSmv2FuncName"] = m_randomSmv2FuncName[FT.type]; argTable["gpFuncName"] = m_gpFuncName[FT.type]; argTable["subtractFuncName"] = m_subtractGmvFuncName[FT.type]; argTable["versorInverseFuncName"] = m_versorInverseFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testIGP_SMV", argTable); } } return(testFuncNames); } // end of WriteTestFunction()
/// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); if (m_gmvFunc) // GMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["euclideanBasisVectorBitmap"] = m_G25M.GetEuclideanBasisVectorBitmap(); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomBladeFuncName"] = m_randomBladeFuncName[FT.type]; argTable["opGmvFunc"] = m_opFuncName[FT.type]; argTable["expGmvFunc"] = m_expFuncName[FT.type]; argTable["subtractGmvFuncName"] = m_subtractGmvFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testEuclideanLogGMV", argTable); } else if ((m_smv != null) && m_smv.CanConvertToGmv(m_specification)) // SMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["rotorType"] = m_smv; argTable["rotorName"] = FT.GetMangledName(m_specification, m_smv.Name); argTable["bivectorName"] = FT.GetMangledName(m_specification, m_fgs.m_returnTypeName); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomBivectorFuncName"] = m_randomBivectorFuncName[FT.type]; argTable["expBivectorFunc"] = m_expBivectorFuncName[FT.type]; argTable["subtractRotorFuncName"] = m_subtractRotorFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testEuclideanLogSMV", argTable); } } return(testFuncNames); } // end of WriteTestFunction()
/// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); if (m_gmvFunc) // GMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomBladeFuncName"] = m_randomBladeFuncName[FT.type]; argTable["reverseFuncName"] = m_reverseFuncName[FT.type]; argTable["spFuncName"] = m_spFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testUnitGMV", argTable); } else if ((m_smv != null) && m_smv.CanConvertToGmv(m_specification)) // SMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["smv"] = m_smv; argTable["smvName"] = FT.GetMangledName(m_specification, m_smv.Name); argTable["resultSmvName"] = FT.GetMangledName(m_specification, m_fgs.m_returnTypeName); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomSmvFuncName"] = m_randomSmvFuncName[FT.type]; argTable["reverseFuncName"] = m_reverseFuncName[FT.type]; argTable["spFuncName"] = m_spFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testUnitSMV", argTable); } } return(testFuncNames); } // end of WriteTestFunction()
/// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); if (m_smv1.CanConvertToGmv(m_specification) && m_smv2.CanConvertToGmv(m_specification)) { string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["squared"] = IsDistance2(m_fgs); argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["arg1TypeName"] = FT.GetMangledName(m_specification, m_smv1.Name); argTable["arg2TypeName"] = FT.GetMangledName(m_specification, m_smv2.Name); argTable["cgaPointName"] = FT.GetMangledName(m_specification, m_cgaPointTypeName[FT.type]); argTable["cgaPointType"] = m_specification.GetType(m_cgaPointTypeName[FT.type]); argTable["sqrt"] = CodeUtil.OpNameToLangString(m_specification, FT, UnaryScalarOp.SQRT); argTable["fabs"] = CodeUtil.OpNameToLangString(m_specification, FT, UnaryScalarOp.ABS); argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["c3gaPointFuncName"] = m_cgaPointFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testCgaPointDistance", argTable); } } return(testFuncNames); } // end of WriteTestFunction()
} // end of CheckTestingDepencies() /// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); if (m_gmvFunc) // GMV test { System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmv"] = m_specification.m_GMV; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["targetFuncName"] = m_funcName[FT.type]; argTable["targetFuncReturnsFloat"] = m_specification.IsFloatType(m_fgs.ReturnTypeName); argTable["productName"] = m_fgs.Name; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomBladeFuncName"] = m_randomBladeFuncName[FT.type]; argTable["subtractGmvFuncName"] = m_subtractGmvFuncName[FT.type]; argTable["gpGmvFuncName"] = m_gpGmvFuncName[FT.type]; argTable["extractGradeFuncName"] = m_extractGradeFuncName[FT.type]; string testFunc1 = testFuncName + "_1"; argTable["testFuncName"] = testFunc1; testFuncNames.Add(testFunc1); m_cgd.m_cog.EmitTemplate(defSB, "testFilteredGpGMV", argTable); string testFunc2 = testFuncName + "_2"; argTable["testFuncName"] = testFunc2; testFuncNames.Add(testFunc2); m_cgd.m_cog.EmitTemplate(defSB, "testOpGMV", argTable); } else if ((m_smv1 != null) && (m_smv2 != null) && m_smv1.CanConvertToGmv(m_specification) && m_smv2.CanConvertToGmv(m_specification)) { // SMV test testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["targetFuncReturnsFloat"] = m_specification.IsFloatType(m_fgs.ReturnTypeName); argTable["smv1"] = m_smv1; argTable["smv1Name"] = FT.GetMangledName(m_specification, m_smv1.Name); argTable["smv2"] = m_smv2; argTable["smv2Name"] = FT.GetMangledName(m_specification, m_smv2.Name); argTable["resultSmvName"] = FT.GetMangledName(m_specification, m_fgs.m_returnTypeName); argTable["productName"] = m_fgs.Name; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomSmv1FuncName"] = m_randomSmv1FuncName[FT.type]; argTable["randomSmv2FuncName"] = m_randomSmv2FuncName[FT.type]; argTable["subtractGmvFuncName"] = m_subtractGmvFuncName[FT.type]; argTable["gmvProductFuncName"] = m_gmvProductFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testFilteredGpSMV", argTable); } } return(testFuncNames); } // end of WriteTestFunction()
/// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["addGmvFuncName"] = m_addGmvFuncName[FT.type]; argTable["subtractGmvFuncName"] = m_subtractGmvFuncName[FT.type]; if (m_gradeIdx >= 0) { argTable["gradeGmvFuncName"] = m_gradeGmvFuncName[FT.type]; { // set "inverseGroupBitmap" // turn grade into inverse group bitmap int groupBitmap = 0; int inverseGroupBitmap = 0; for (int g = 0; g < m_specification.m_GMV.NbGroups; g++) { if (m_specification.m_GMV.Group(g)[0].Grade() != m_gradeIdx) { inverseGroupBitmap |= (1 << g); } else { groupBitmap |= (1 << g); } } string groupBitmapString; string inverseGroupBitmapString; if (m_specification.OutputCppOrC()) { groupBitmapString = groupBitmap.ToString(); inverseGroupBitmapString = inverseGroupBitmap.ToString(); } else { groupBitmapString = "0"; inverseGroupBitmapString = "0"; for (int g = 0; g < m_specification.m_GMV.NbGroups; g++) { string groupStr = " | GroupBitmap.GROUP_" + g; if ((groupBitmap & (1 << g)) != 0) { groupBitmapString = groupBitmapString + groupStr; } else { inverseGroupBitmapString = inverseGroupBitmapString + groupStr; } } } argTable["groupBitmap"] = groupBitmapString; argTable["inverseGroupBitmap"] = inverseGroupBitmapString; } } if (m_gmvFunc) // GMV test { testFuncNames.Add(testFuncName); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomVersorFuncName"] = m_randomVersorFuncName[FT.type]; if (m_gradeIdx >= 0) { m_cgd.m_cog.EmitTemplate(defSB, "testGradeXGMV", argTable); } else { m_cgd.m_cog.EmitTemplate(defSB, "testGradeGMV", argTable); } } else if ((m_smv != null) && m_smv.CanConvertToGmv(m_specification)) { // SMV test testFuncNames.Add(testFuncName); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["testFuncName"] = testFuncName; argTable["smv"] = m_smv; argTable["smvName"] = FT.GetMangledName(m_specification, m_smv.Name); argTable["smvRName"] = FT.GetMangledName(m_specification, m_fgs.m_returnTypeName); argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomSmvFuncName"] = m_randomSmvFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testGradeXSMV", argTable); } } return(testFuncNames); } // end of WriteTestFunction()
/// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); // get a table which describes the behavior of the operation int NB_ENTRIES = m_specification.m_dimension + 1; StringBuilder signArray = new StringBuilder(); int[] table = RefGA.Util.GetSignToggleMultipliers(GetRefGAFunctionId(m_fgs), NB_ENTRIES); for (int i = 0; i < NB_ENTRIES; i++) { if (i > 0) { signArray.Append(", "); } signArray.Append(table[i]); } foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); if (m_gmvFunc) // GMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmv"] = m_specification.m_GMV; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomVersorFuncName"] = m_randomVersorFuncName[FT.type]; argTable["extractGradeFuncName"] = m_extractGradeFuncName[FT.type]; argTable["signArray"] = signArray.ToString(); argTable["nbEntries"] = NB_ENTRIES; m_cgd.m_cog.EmitTemplate(defSB, "testToggleSignGMV", argTable); } else if ((m_smv != null) && m_smv.CanConvertToGmv(m_specification)) // SMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["smv"] = m_smv; argTable["smvName"] = FT.GetMangledName(m_specification, m_smv.Name); argTable["resultSmvName"] = FT.GetMangledName(m_specification, m_fgs.m_returnTypeName); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["targetFuncReturnsFloat"] = m_specification.IsFloatType(m_fgs.ReturnTypeName); argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomSmvFuncName"] = m_randomSmvFuncName[FT.type]; argTable["subtractGmvFuncName"] = m_subtractGmvFuncName[FT.type]; argTable["gmvToggleSignFuncName"] = m_gmvToggleSignFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testToggleSignSMV", argTable); } } return(testFuncNames); } // end of WriteTestFunction()
/// <summary> /// Writes the testing function for 'F' to 'm_defSB'. /// The generated function returns success (1) or failure (0). /// </summary> /// <returns>The list of name name of the int() function which tests the function.</returns> public override List <string> WriteTestFunction() { StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB; List <string> testFuncNames = new List <string>(); foreach (string floatName in m_fgs.FloatNames) { FloatType FT = m_specification.GetFloatType(floatName); string testFuncName = Util.GetTestingFunctionName(m_specification, m_cgd, m_funcName[FT.type]); if (m_gmvFunc) // GMV test { bool canTest = IsExp(m_fgs) || IsCosh(m_fgs) || IsSinh(m_fgs); canTest = canTest && m_specification.m_dimension >= 2; if (canTest) { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmv"] = m_specification.m_GMV; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomBladeFuncName"] = m_randomBladeFuncName[FT.type]; argTable["subtractGmvFuncName"] = m_subtractGmvFuncName[FT.type]; argTable["addGmvFuncName"] = m_addGmvFuncName[FT.type]; argTable["sinhFuncName"] = m_sinhFuncName[FT.type]; argTable["coshFuncName"] = m_coshFuncName[FT.type]; argTable["expFuncName"] = m_expFuncName[FT.type]; m_cgd.m_cog.EmitTemplate(defSB, "testSinhCoshExpGMV", argTable); } } else if ((m_smv != null) && m_smv.CanConvertToGmv(m_specification)) // SMV test { testFuncNames.Add(testFuncName); System.Collections.Hashtable argTable = new System.Collections.Hashtable(); argTable["S"] = m_specification; argTable["FT"] = FT; argTable["gmvName"] = FT.GetMangledName(m_specification, m_specification.m_GMV.Name); argTable["smv"] = m_smv; argTable["smvName"] = FT.GetMangledName(m_specification, m_smv.Name); argTable["resultIsScalar"] = m_returnType is G25.FloatType; argTable["resultSmvName"] = FT.GetMangledName(m_specification, m_fgs.m_returnTypeName); argTable["testFuncName"] = testFuncName; argTable["targetFuncName"] = m_funcName[FT.type]; argTable["randomScalarFuncName"] = m_randomScalarFuncName[FT.type]; argTable["randomSmvFuncName"] = m_randomSmvFuncName[FT.type]; argTable["subtractGmvFuncName"] = m_subtractGmvFuncName[FT.type]; argTable["gpSinCosExpFuncName"] = m_gpSinCosExpFuncName[FT.type]; argTable["scalarSquare"] = m_scalarSquare; m_cgd.m_cog.EmitTemplate(defSB, "testSinCosExpSMV", argTable); } } return(testFuncNames); } // end of WriteTestFunction()