/// <summary> /// Constructor. /// </summary> /// <param name="name">The name of the multivector (typically smvom_gradeX_columnY.</param> /// <param name="basisBlades">The basis blades.</param> /// <param name="parentOM">Parent outermorphism this SMVOM belongs to.</param> /// <param name="gradeOM">The grade this SMVOM is for.</param> /// <param name="columnOM">The column of the OM matrix this SMVOM is for.</param> public SMVOM(String name, RefGA.BasisBlade[] basisBlades, G25.OM parentOM, int gradeOM, int columnOM) : base(name, basisBlades, MULTIVECTOR_TYPE.MULTIVECTOR, null, null, null) { m_parentOM = parentOM; m_gradeOM = gradeOM; m_columnOM = columnOM; }
/// <summary> /// If this FunctionGenerator can implement 'F', then this function should complete the (possible) /// blanks in 'F'. This means: /// - Fill in F.m_returnTypeName if it is empty /// - Fill in F.m_argumentTypeNames (and m_argumentVariableNames) if it is empty. /// </summary> public override void CompleteFGS() { // fill in ArgumentTypeNames if (m_fgs.ArgumentTypeNames.Length == 0) { if (m_specification.m_GOM == null) { throw new G25.UserException("No general outermorphism type defined, while it is required because the type of the first argument was unspecified."); } m_fgs.m_argumentTypeNames = new String[] { m_specification.m_GOM.Name, m_gmv.Name }; } // init argument pointers from the completed typenames (language sensitive); m_fgs.InitArgumentPtrFromTypeNames(m_specification); // get all function info FloatType FT = m_specification.GetFloatType(m_fgs.FloatNames[0]); bool computeMultivectorValue = true; G25.CG.Shared.FuncArgInfo[] tmpFAI = G25.CG.Shared.FuncArgInfo.GetAllFuncArgInfo(m_specification, m_fgs, NB_ARGS, FT, m_specification.m_GMV.Name, computeMultivectorValue); m_om = (G25.OM)tmpFAI[0].Type; m_mv = (G25.MV)tmpFAI[1].Type; m_gmvFunc = !tmpFAI[1].IsScalarOrSMV(); // compute intermediate results, set return type if (m_gmvFunc) { m_fgs.m_returnTypeName = m_gmv.Name; // gmv + gmv = gmv } else { RefGA.Multivector inputValue = tmpFAI[1].MultivectorValue[0]; // Compute m_returnValue: // Replace each basis blade in 'inputValue' with its value under the outermorphism. m_returnValue = RefGA.Multivector.ZERO; for (int i = 0; i < inputValue.BasisBlades.Length; i++) { // get input blade and domain for that grade RefGA.BasisBlade inputBlade = inputValue.BasisBlades[i]; RefGA.BasisBlade[] domainBlades = m_om.DomainForGrade(inputBlade.Grade()); for (int c = 0; c < domainBlades.Length; c++) { // if a match is found in the domain, add range vector to m_returnValue if (domainBlades[c].bitmap == inputBlade.bitmap) { bool ptr = m_specification.OutputC(); RefGA.Multivector omColumnValue = G25.CG.Shared.Symbolic.SMVtoSymbolicMultivector(m_specification, m_om.DomainSmvForGrade(inputBlade.Grade())[c], tmpFAI[0].Name, ptr); RefGA.Multivector inputBladeScalarMultiplier = new RefGA.Multivector(new RefGA.BasisBlade(inputBlade, 0)); RefGA.Multivector domainBladeScalarMultiplier = new RefGA.Multivector(new RefGA.BasisBlade(domainBlades[c], 0)); m_returnValue = RefGA.Multivector.Add(m_returnValue, RefGA.Multivector.gp( RefGA.Multivector.gp(omColumnValue, inputBladeScalarMultiplier), domainBladeScalarMultiplier)); break; // no need to search the other domainBlades too } } } // get name of return type if (m_fgs.m_returnTypeName.Length == 0) { m_fgs.m_returnTypeName = G25.CG.Shared.SpecializedReturnType.GetReturnType(m_specification, m_cgd, m_fgs, FT, m_returnValue).GetName(); } } }
/// <summary> /// If this FunctionGenerator can implement 'F', then this function should complete the (possible) /// blanks in 'F'. This means: /// - Fill in F.m_returnTypeName if it is empty /// - Fill in F.m_argumentTypeNames (and m_argumentVariableNames) if it is empty. /// </summary> public override void CompleteFGS() { // fill in ArgumentTypeNames if (m_fgs.ArgumentTypeNames.Length == 0) { if (m_specification.m_GOM == null) throw new G25.UserException("No general outermorphism type defined, while it is required because the type of the first argument was unspecified."); m_fgs.m_argumentTypeNames = new String[] { m_specification.m_GOM.Name, m_gmv.Name }; } // init argument pointers from the completed typenames (language sensitive); m_fgs.InitArgumentPtrFromTypeNames(m_specification); // get all function info FloatType FT = m_specification.GetFloatType(m_fgs.FloatNames[0]); bool computeMultivectorValue = true; G25.CG.Shared.FuncArgInfo[] tmpFAI = G25.CG.Shared.FuncArgInfo.GetAllFuncArgInfo(m_specification, m_fgs, NB_ARGS, FT, m_specification.m_GMV.Name, computeMultivectorValue); m_om = (G25.OM)tmpFAI[0].Type; m_mv = (G25.MV)tmpFAI[1].Type; m_gmvFunc = !tmpFAI[1].IsScalarOrSMV(); // compute intermediate results, set return type if (m_gmvFunc) m_fgs.m_returnTypeName = m_gmv.Name;// gmv + gmv = gmv else { RefGA.Multivector inputValue = tmpFAI[1].MultivectorValue[0]; // Compute m_returnValue: // Replace each basis blade in 'inputValue' with its value under the outermorphism. m_returnValue = RefGA.Multivector.ZERO; for (int i = 0; i < inputValue.BasisBlades.Length; i++) { // get input blade and domain for that grade RefGA.BasisBlade inputBlade = inputValue.BasisBlades[i]; RefGA.BasisBlade[] domainBlades = m_om.DomainForGrade(inputBlade.Grade()); for (int c = 0; c < domainBlades.Length; c++) { // if a match is found in the domain, add range vector to m_returnValue if (domainBlades[c].bitmap == inputBlade.bitmap) { bool ptr = m_specification.OutputC(); RefGA.Multivector omColumnValue = G25.CG.Shared.Symbolic.SMVtoSymbolicMultivector(m_specification, m_om.DomainSmvForGrade(inputBlade.Grade())[c], tmpFAI[0].Name, ptr); RefGA.Multivector inputBladeScalarMultiplier = new RefGA.Multivector(new RefGA.BasisBlade(inputBlade, 0)); RefGA.Multivector domainBladeScalarMultiplier = new RefGA.Multivector(new RefGA.BasisBlade(domainBlades[c], 0)); m_returnValue = RefGA.Multivector.Add(m_returnValue, RefGA.Multivector.gp( RefGA.Multivector.gp(omColumnValue, inputBladeScalarMultiplier), domainBladeScalarMultiplier)); break; // no need to search the other domainBlades too } } } // get name of return type if (m_fgs.m_returnTypeName.Length == 0) m_fgs.m_returnTypeName = G25.CG.Shared.SpecializedReturnType.GetReturnType(m_specification, m_cgd, m_fgs, FT, m_returnValue).GetName(); } }