当前位置: 首页>>代码示例>>C#>>正文


C# FloatType.GetMangledName方法代码示例

本文整理汇总了C#中FloatType.GetMangledName方法的典型用法代码示例。如果您正苦于以下问题:C# FloatType.GetMangledName方法的具体用法?C# FloatType.GetMangledName怎么用?C# FloatType.GetMangledName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FloatType的用法示例。


在下文中一共展示了FloatType.GetMangledName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteDefinition

        private static void WriteDefinition(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.Constant C)
        {
            // assume only SMV constants for now
            G25.SMV smv = C.Type as G25.SMV;
            ConstantSMV Csmv = C as ConstantSMV;

            // MANGLED_TYPENAME MANGLED_CONSTANT_NAME = {...}
            SB.Append(FT.GetMangledName(S, C.Type.GetName()));
            SB.Append(" ");
            SB.Append(FT.GetMangledName(S, C.Name));
            SB.Append(" = {");

            if (smv.NbNonConstBasisBlade == 0)
            {
                // 'C' does not allow empty structs, so there is a filler that must be initialized
                SB.Append("0");
            }
            else
            {
                if (S.m_coordStorage == COORD_STORAGE.ARRAY)
                    SB.Append("{");

                for (int c = 0; c < smv.NbNonConstBasisBlade; c++)
                {
                    if (c > 0) SB.Append(", ");
                    SB.Append(FT.DoubleToString(S, Csmv.Value[c]));
                }

                if (S.m_coordStorage == COORD_STORAGE.ARRAY)
                    SB.Append("}");
            }

            SB.AppendLine("};");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:34,代码来源:constants.cs

示例2: WriteDefinition

        private static void WriteDefinition(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.Constant C)
        {
            // assume only SMV constants for now
            G25.SMV smv = C.Type as G25.SMV;
            ConstantSMV Csmv = C as ConstantSMV;

            string className = FT.GetMangledName(S, smv.Name);

            // MANGLED_TYPENAME MANGLED_CONSTANT_NAME = {...}
            SB.Append(className);
            SB.Append(" ");
            SB.Append(FT.GetMangledName(S, C.Name));

            if (smv.NbNonConstBasisBlade > 0) {
                // MANGLED_TYPENAME MANGLED_CONSTANT_NAME(...)
                SB.Append("(" + className + "::" + G25.CG.Shared.SmvUtil.GetCoordinateOrderConstant(S, smv));

                for (int c = 0; c < smv.NbNonConstBasisBlade; c++)
                {
                    SB.Append(", ");
                    SB.Append(FT.DoubleToString(S, Csmv.Value[c]));
                }

                SB.Append(")");
            }

            SB.AppendLine(";");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:28,代码来源:constants.cs

示例3: GenerateCode

        /// <summary>
        /// Generates a source file with the GOM class definition.
        /// </summary>
        /// <param name="S"></param>
        /// <param name="cgd"></param>
        /// <param name="FT"></param>
        /// <returns></returns>
        public static string GenerateCode(Specification S, G25.CG.Shared.CGdata cgd, FloatType FT)
        {
            G25.GOM gom = S.m_GOM;
            string className = FT.GetMangledName(S, gom.Name);

            // get range vector type
            G25.SMV rangeVectorType = G25.CG.Shared.OMinit.GetRangeVectorType(S, FT, cgd, gom);
            string rangeVectorSMVname = FT.GetMangledName(S, rangeVectorType.Name);

            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();
            string sourceFilename = MainGenerator.GetClassOutputPath(S, className);
            generatedFiles.Add(sourceFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // get a new 'cgd' where all ouput goes to the one StringBuilder SB
            cgd = new G25.CG.Shared.CGdata(cgd, SB, SB, SB);

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            // open namespace
            G25.CG.Shared.Util.WriteOpenNamespace(SB, S);

            // write class comment
            G25.CG.CSJ.GOM.WriteComment(SB, S, cgd, FT, gom);

            // open class
            G25.CG.Shared.Util.WriteOpenClass(SB, S, G25.CG.Shared.AccessModifier.AM_public, className, null, null);

            // write member variables
            G25.CG.CSJ.GOM.WriteMemberVariables(SB, S, cgd, FT, gom);

            // write constructors
            G25.CG.CSJ.GOM.WriteConstructors(SB, S, cgd, FT, gom, className, rangeVectorSMVname);

            // write set functions
            G25.CG.CSJ.GOM.WriteSetIdentity(SB, S, cgd, FT);
            G25.CG.CSJ.GOM.WriteSetCopy(SB, S, cgd, FT);
            G25.CG.CSJ.GOM.WriteSetVectorImages(S, cgd, FT, false, false); // false, false = matrixMode, transpose
            G25.CG.CSJ.GOM.WriteSetVectorImages(S, cgd, FT, true, false); // true, false = matrixMode, transpose
            G25.CG.CSJ.GOM.WriteSOMtoGOMcopy(S, cgd, FT);

            // write shortcuts for functions
            G25.CG.Shared.Shortcut.WriteFunctionShortcuts(SB, S, cgd, FT, gom);

            // close class
            G25.CG.Shared.Util.WriteCloseClass(SB, S, className);

            // close namespace
            G25.CG.Shared.Util.WriteCloseNamespace(SB, S);

            // write all to file
            G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());

            return sourceFilename;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:67,代码来源:gom.cs

示例4: WriteConstructors

 /// <summary>
 /// Writes constructors.
 /// </summary>
 /// <param name="SB">Where the code goes.</param>
 /// <param name="S">Used for basis vector names and output language.</param>
 /// <param name="cgd">Not used yet.</param>
 /// <param name="FT">Float point type of 'SMV'.</param>
 /// <param name="smv">The specialized multivector for which the struct should be written.</param>
 public static void WriteConstructors(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.SMV smv)
 {
     cgd.m_cog.EmitTemplate(SB, "SMVconstructors",
         "S=", S,
         "smv=", smv,
         "className=", FT.GetMangledName(S, smv.Name),
         "gmvClassName=", FT.GetMangledName(S, S.m_GMV.Name),
         "FT=", FT);
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:17,代码来源:smv.cs

示例5: WriteDeclaration

 private static void WriteDeclaration(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.Constant C)
 {
     // extern MANGLED_TYPENAME MANGLED_CONSTANT_NAME;
     if (C.Comment.Length > 0)
         SB.AppendLine("/** " + C.Comment + " */");
     SB.Append("extern ");
     SB.Append(FT.GetMangledName(S, C.Type.GetName()));
     SB.Append(" ");
     SB.Append(FT.GetMangledName(S, C.Name));
     SB.AppendLine(";");
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:11,代码来源:constants.cs

示例6: WriteFunctionShortcut

        /// <summary>
        /// Writes a shortcut for 'type', 'fgs'.
        /// </summary>
        /// <param name="SB">Where the code goes.</param>
        /// <param name="S">Used for basis vector names and output language.</param>
        /// <param name="cgd">Not used yet.</param>
        /// <param name="FT">Float point type of 'type'.</param>
        /// <param name="type">The type for which shortcuts should be written.</param>
        /// <param name="fgs"></param>
        /// <param name="FAI"></param>
        public static void WriteFunctionShortcut(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.VariableType type,
            G25.fgs fgs, FuncArgInfo[] FAI)
        {
            int nbTabs = 1;

            FuncArgInfo[] tailFAI = getTail(FAI);

            string shortcutCall = getShortcutCall(S, fgs, tailFAI);

            SB.AppendLine("");

            // output comment
            new Comment("shortcut to " + shortcutCall).Write(SB, S, nbTabs);

            bool inline = false;
            bool staticFunc = false;
            string returnType = FT.GetMangledName(S, fgs.ReturnTypeName);
            FuncArgInfo returnArgument = null;

            SB.Append('\t', nbTabs);
            Functions.WriteDeclaration(SB, S, cgd,
                inline, staticFunc, returnType, fgs.OutputName,
                returnArgument, tailFAI);
            SB.AppendLine(" {");

            SB.Append('\t', nbTabs+1);
            SB.Append("return ");
            SB.Append(shortcutCall);
            SB.AppendLine(";");

            SB.Append('\t', nbTabs);
            SB.AppendLine("}");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:43,代码来源:shortcut.cs

示例7: WriteAddSubHpFunction

        /// <summary>
        /// Writes any addition or subtraction function for general multivectors,
        /// based on CASN parts code.
        /// </summary>
        /// <param name="S"></param>
        /// <param name="cgd"></param>
        /// <param name="FT"></param>
        /// <param name="FAI"></param>
        /// <param name="F"></param>
        /// <param name="comment"></param>
        /// <param name="funcType">ADD, SUB or HP</param>
        /// <returns>Full name of generated function.</returns>
        public static string WriteAddSubHpFunction(Specification S, G25.CG.Shared.CGdata cgd, FloatType FT,
            G25.CG.Shared.FuncArgInfo[] FAI, G25.fgs F,
            Comment comment, G25.CG.Shared.CANSparts.ADD_SUB_HP_TYPE funcType)
        {
            // setup instructions
            System.Collections.Generic.List<G25.CG.Shared.Instruction> I = new System.Collections.Generic.List<G25.CG.Shared.Instruction>();
            int nbTabs = 1;

            // write this function:
            string code = G25.CG.Shared.CANSparts.GetAddSubtractHpCode(S, cgd, FT, funcType, FAI, fgs.RETURN_ARG_NAME);

            // add one instruction (verbatim code)
            I.Add(new G25.CG.Shared.VerbatimCodeInstruction(nbTabs, code));

            // because of lack of overloading, function names include names of argument types
            G25.fgs CF = G25.CG.Shared.Util.AppendTypenameToFuncName(S, FT, F, FAI);

            // setup return type and argument:
            string returnTypeName = FT.GetMangledName(S, S.m_GMV.Name);
            G25.CG.Shared.FuncArgInfo returnArgument = null;
            if (S.OutputC())
                returnArgument = new G25.CG.Shared.FuncArgInfo(S, CF, -1, FT, S.m_GMV.Name, false); // false = compute value

            string funcName = CF.OutputName;
            //if (S.OutputC())
              //  funcName = FT.GetMangledName(S, funcName);

            // write function
            bool inline = false; // never inline GMV functions
            bool staticFunc = Functions.OutputStaticFunctions(S);
            G25.CG.Shared.Functions.WriteFunction(S, cgd, F, inline, staticFunc, returnTypeName, funcName, returnArgument, FAI, I, comment);

            return funcName;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:46,代码来源:gmv_casn_parts.cs

示例8: GetSetFromLowerGradeFunctionNames

 public static string[] GetSetFromLowerGradeFunctionNames(Specification S, FloatType FT, bool matrixMode)
 {
     G25.GOM gom = S.m_GOM;
     // generate function names for all grades (basis blade names not included)
     string typeName = FT.GetMangledName(S, gom.Name);
     string[] funcNames = new string[gom.Domain.Length];
     for (int g = 1; g < gom.Domain.Length; g++)
     {
         string nameC = (g > 1) ? "_set" : ((matrixMode) ? "_setMatrix" : "_setVectorImages");
         string suffix = (g > 1) ? ("_grade_" + g) : "";
         funcNames[g] = GetFunctionName(S, typeName, "set" + suffix, nameC + suffix);
     }
     return funcNames;
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:14,代码来源:om_init.cs

示例9: WriteGMVgpFunction

        /// <summary>
        /// Writes any geometric product based product for general multivectors,
        /// based on gp parts code.
        /// </summary>
        /// <param name="SB"></param>
        /// <param name="S"></param>
        /// <param name="cgd"></param>
        /// <param name="FT"></param>
        /// <param name="M"></param>
        /// <param name="FAI"></param>
        /// <param name="F"></param>
        /// <param name="comment"></param>
        /// <param name="declOnly"></param>
        /// <param name="productType"></param>
        /// <returns>name of generated function</returns>
        public static string WriteGMVgpFunction(Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.Metric M, 
            G25.CG.Shared.FuncArgInfo[] FAI, G25.fgs F,
            Comment comment, G25.CG.Shared.GPparts.ProductTypes productType)
        {
            // setup instructions
            System.Collections.Generic.List<G25.CG.Shared.Instruction> I = new System.Collections.Generic.List<G25.CG.Shared.Instruction>();
            int nbTabs = 1;

            // write this function:
            string code = G25.CG.Shared.GPparts.GetGPcode(S, cgd, FT, M, productType, FAI, fgs.RETURN_ARG_NAME);

            // add one instruction (verbatim code)
            I.Add(new G25.CG.Shared.VerbatimCodeInstruction(nbTabs, code));

            // because of lack of overloading, function names include names of argument types
            G25.fgs CF = G25.CG.Shared.Util.AppendTypenameToFuncName(S, FT, F, FAI);

            // setup return type and argument:
            string returnTypeName = null;

            G25.CG.Shared.FuncArgInfo returnArgument = null;
            if (productType == G25.CG.Shared.GPparts.ProductTypes.SCALAR_PRODUCT)
            {
                // return scalar
                returnTypeName = FT.type;
            }
            else
            {
                // return GMV (in C, via 'return argument')
                returnTypeName = FT.GetMangledName(S, S.m_GMV.Name);

                if (S.OutputC())
                    returnArgument = new G25.CG.Shared.FuncArgInfo(S, CF, -1, FT, S.m_GMV.Name, false); // false = compute value
            }

            string funcName = CF.OutputName;

            // FAI[0].MangledTypeName;
            //CF.ArgumentTypeNames[0] = CF.ArgumentTypeNames[0] + G25.CG.Shared.Main.IF_SUFFIX;

            // write function
            bool inline = false; // never inline GMV functions
            bool staticFunc = Functions.OutputStaticFunctions(S);
            G25.CG.Shared.Functions.WriteFunction(S, cgd, F, inline, staticFunc, returnTypeName, funcName, returnArgument, FAI, I, comment);

            return funcName;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:62,代码来源:gmv_gp_parts.cs

示例10: WriteGMVnormFunction

        /// <summary>
        /// Writes any norm function for general multivectors, based on gp parts code.
        /// </summary>
        /// <param name="SB"></param>
        /// <param name="S"></param>
        /// <param name="cgd"></param>
        /// <param name="FT"></param>
        /// <param name="M"></param>
        /// <param name="FAI"></param>
        /// <param name="F"></param>
        /// <param name="comment"></param>
        /// <param name="declOnly"></param>
        /// <param name="squared"></param>
        /// <returns>name of generated function.</returns>
        public static string WriteGMVnormFunction(Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.Metric M,
            G25.CG.Shared.FuncArgInfo[] FAI, G25.fgs F,
            Comment comment, bool squared)
        {
            // setup instructions
            System.Collections.Generic.List<G25.CG.Shared.Instruction> I = new System.Collections.Generic.List<G25.CG.Shared.Instruction>();
            int nbTabs = 1;

            // because of lack of overloading, function names include names of argument types
            G25.fgs CF = G25.CG.Shared.Util.AppendTypenameToFuncName(S, FT, F, FAI);

            string funcName = CF.OutputName;

            // get return info
            G25.SMV returnType = null;
            string returnTypeName = null;
            G25.CG.Shared.FuncArgInfo returnArgument = null;
            { // try to get scalar type
                returnType = S.GetScalarSMV();
                if (returnType == null)
                {
                    returnTypeName = FT.type;
                }
                else
                {
                    if (S.OutputC())
                        returnArgument = new G25.CG.Shared.FuncArgInfo(S, CF, -1, FT, returnType.Name, false); // false = compute value
                    returnTypeName = FT.GetMangledName(S, returnType.GetName());
                }
            }

            // write this function:
            string code = G25.CG.Shared.GPparts.GetNormCode(S, cgd, FT, M, squared, FAI, returnType, G25.fgs.RETURN_ARG_NAME);

            // add the verbatim code
            I.Add(new G25.CG.Shared.VerbatimCodeInstruction(nbTabs, code));

            // write function
            bool inline = false; // never inline GMV functions
            bool staticFunc = Functions.OutputStaticFunctions(S);
            G25.CG.Shared.Functions.WriteFunction(S, cgd, F, inline, staticFunc, returnTypeName, funcName, returnArgument, FAI, I, comment);

            return funcName;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:58,代码来源:gmv_gp_parts.cs

示例11: WriteSMVtoGMVcopy

        /// <summary>
        /// Writes functions to copy SMVs to GMVs
        /// </summary>
        /// <param name="SB">Where the output goes.</param>
        /// <param name="S"></param>
        /// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param>
        /// <param name="FT"></param>
        public static void WriteSMVtoGMVcopy(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT)
        {
            int nbTabs;
            G25.GMV gmv = S.m_GMV;
            bool gmvParityPure = (S.m_GMV.MemoryAllocationMethod == G25.GMV.MEM_ALLOC_METHOD.PARITY_PURE);

            //string dstClassName = FT.GetMangledName(S, gmv.Name);
            for (int s = 0; s < S.m_SMV.Count; s++)
            {
                G25.SMV smv = S.m_SMV[s];

                // do not generate converter if the GMV cannot hold the type
                if (gmvParityPure && (!smv.IsParityPure())) continue;

                string srcClassName = FT.GetMangledName(S, smv.Name);

                SB.AppendLine();

                nbTabs = 1;
                new G25.CG.Shared.Comment("sets this to " + srcClassName + " value.").Write(SB, S, nbTabs);

                string funcName = GetSetFuncName(S);

                string funcDecl = "\tpublic void " + funcName + "(" + srcClassName + " src)";

                SB.Append(funcDecl);

                {
                    SB.AppendLine(" {");

                    // get a dictionary which tells you for each basis blade of 'gmv' where it is in 'smv'
                    Dictionary<Tuple<int, int>, Tuple<int, int>> D = G25.MV.GetCoordMap(smv, gmv);

                    // convert SMV to symbolic Multivector:
                    bool smvPtr = false;
                    RefGA.Multivector value = G25.CG.Shared.Symbolic.SMVtoSymbolicMultivector(S, smv, "src", smvPtr);

                    // find out which groups are present
                    StringBuilder guSB = new StringBuilder();
                    int gu = 0;
                    foreach (KeyValuePair<Tuple<int, int>, Tuple<int, int>> KVP in D)
                    {
                        int bit = 1 << KVP.Value.Value1;
                        if ((gu & bit) == 0)
                        {
                            gu |= 1 << KVP.Value.Value1;
                            if (guSB.Length > 0) guSB.Append("|");
                            guSB.Append("GroupBitmap.GROUP_" + KVP.Value.Value1);
                        }
                    }

                    // generate the code to set group usage:
                    SB.AppendLine("\t\t" + GetAllocateGroupsString(S) + "(" + guSB.ToString() + ");");

                    // a helper pointer
                    string dstArrName = "ptr";
                    SB.AppendLine("\t\t" + FT.type + "[] " + dstArrName + ";");

                    // for each used group, generate the assignment code
                    for (int g = 0; (1 << g) <= gu; g++)
                    {
                        if (((1 << g) & gu) != 0)
                        {
                            SB.AppendLine();
                            SB.AppendLine("\t\tptr = m_c[" + g + "];");

                            int dstBaseIdx = 0;
                            bool mustCast = false;
                            nbTabs = 2;
                            bool writeZeros = true;
                            string str = G25.CG.Shared.CodeUtil.GenerateGMVassignmentCode(S, FT, mustCast, gmv, dstArrName, g, dstBaseIdx, value, nbTabs, writeZeros);
                            SB.Append(str);
                        }

                    }

                    if (S.m_reportUsage)
                    {
                        SB.AppendLine("\t\tm_t = " + G25.CG.CSJ.GMV.SMV_TYPE + "." + G25.CG.Shared.ReportUsage.GetSpecializedConstantName(S, smv.Name) + ";");
                    }

                    SB.AppendLine("\t}");
                }
            } // end of loop over all SMVs
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:92,代码来源:gmv.cs

示例12: GetMvInterfaceName

 public static string GetMvInterfaceName(Specification S, FloatType FT)
 {
     return FT.GetMangledName(S, S.m_GMV.Name) + G25.CG.Shared.Main.IF_SUFFIX;
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:4,代码来源:mvinterface.cs

示例13: WriteNormReturnsScalar

        protected void WriteNormReturnsScalar(FloatType FT, G25.CG.Shared.FuncArgInfo[] FAI, String funcName, G25.SMV scalarSMV)
        {
            StringBuilder declSB = m_cgd.m_declSB;
            StringBuilder defSB = (m_specification.m_inlineFunctions) ? m_cgd.m_inlineDefSB : m_cgd.m_defSB;

            string inlineStr = G25.CG.Shared.Util.GetInlineString(m_specification, m_specification.m_inlineFunctions, " ");

            string refPtrStr = "";
            if (m_specification.OutputC()) refPtrStr = "*";
            else if (m_specification.OutputCpp()) refPtrStr = "&";

            string ACCESS = "";
            if (m_specification.OutputJava()) ACCESS = "public final static ";
            else if (m_specification.OutputCSharp()) ACCESS = "public static ";

            string VAR_MOD = "";
            if (m_specification.OutputCppOrC()) VAR_MOD = "const ";
            if (m_specification.OutputJava()) VAR_MOD = "final ";

            string funcDecl = FT.type + " " + funcName + G25.CG.Shared.CANSparts.RETURNS_SCALAR + "(" + VAR_MOD + FAI[0].MangledTypeName + " " + refPtrStr + FAI[0].Name + ")";
            string comment = "internal conversion function (this is just a pass through)";

            int nbTabs = 0;
            if (m_specification.OutputCppOrC())
            {
                new Comment(comment).Write(declSB, m_specification, nbTabs);
                declSB.Append(funcDecl);
                declSB.AppendLine(";");
            }
            else new Comment(comment).Write(defSB, m_specification, nbTabs);

            defSB.Append(inlineStr + ACCESS + funcDecl);
            defSB.AppendLine(" {");
            if (m_specification.OutputC())
            {
                defSB.AppendLine("\t" + FT.GetMangledName(m_specification, scalarSMV.Name) + " tmp;");
                defSB.AppendLine("\t" + funcName + "(&tmp, " + FAI[0].Name + ");");
            }
            else if (m_specification.OutputCpp())
            {
                defSB.AppendLine("\t" + FT.GetMangledName(m_specification, scalarSMV.Name) + " tmp(" + funcName + "(" + FAI[0].Name + "));");
            }
            else
            {
                defSB.AppendLine("\t" + FT.GetMangledName(m_specification, scalarSMV.Name) + " tmp = " + funcName + "(" + FAI[0].Name + ");");
            }

            string[] accessStr;
            {
                bool ptr = false;
                accessStr = G25.CG.Shared.CodeUtil.GetAccessStr(m_specification, scalarSMV, "tmp", ptr);
            }

            defSB.AppendLine("\treturn " + accessStr[0] + ";");

            defSB.AppendLine("}");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:57,代码来源:norm.cs

示例14: WriteSetMatrix

        public static void WriteSetMatrix(Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.SOM som, bool transpose)
        {
            int NB_ARGS = 1;
            string[] argTypes = new string[NB_ARGS];
            string[] argNames = new string[NB_ARGS];
            argTypes[0] = FT.type;
            argNames[0] = "M";

            // construct image values
            RefGA.Multivector[] imageValue = new RefGA.Multivector[som.DomainVectors.Length];
            for (int d = 0; d < som.DomainVectors.Length; d++)
            {
                //imageValue[d] = RefGA.Multivector.ZERO;
                RefGA.BasisBlade[] IV = new RefGA.BasisBlade[som.RangeVectors.Length];
                for (int r = 0; r < som.RangeVectors.Length; r++)
                {
                    int matrixIdx = (transpose) ? (d * som.RangeVectors.Length + r) : (r * som.DomainVectors.Length + d);
                    string entryName = argNames[0] + "[" + matrixIdx + "]";
                    IV[r] = new RefGA.BasisBlade(som.RangeVectors[r].bitmap, 1.0, entryName);
                }
                imageValue[d] = new RefGA.Multivector(IV);
            }

            string typeName = FT.GetMangledName(S, som.Name);
            string funcName = GetFunctionName(S, typeName, "set", "_setMatrix");
            if (transpose) funcName = funcName + "Transpose";

            //argNames[0] = "*" + argNames[0]; // quick hack: add pointer to name instead of type!
            G25.fgs F = new G25.fgs(funcName, funcName, "", argTypes, argNames, new String[] { FT.type }, null, null, null); // null, null = metricName, comment, options
            F.InitArgumentPtrFromTypeNames(S);
            if (S.OutputCppOrC())
                F.m_argumentPtr[0] = true;
            else F.m_argumentArr[0] = true;
            bool computeMultivectorValue = false;
            G25.CG.Shared.FuncArgInfo[] FAI = G25.CG.Shared.FuncArgInfo.GetAllFuncArgInfo(S, F, NB_ARGS, FT, S.m_GMV.Name, computeMultivectorValue);

            G25.CG.Shared.FuncArgInfo returnArgument = null;
            if (S.OutputC())
                returnArgument = new G25.CG.Shared.FuncArgInfo(S, F, -1, FT, som.Name, computeMultivectorValue);

            // setup instructions
            List<G25.CG.Shared.Instruction> I = new List<G25.CG.Shared.Instruction>();
            {
                bool mustCast = false;
                int nbTabs = 1;
                string dstName = (S.OutputC()) ? G25.fgs.RETURN_ARG_NAME : SmvUtil.THIS;
                bool dstPtr = S.OutputCppOrC();
                bool declareDst = false;
                for (int g = 1; g < som.Domain.Length; g++)
                {
                    for (int c = 0; c < som.DomainForGrade(g).Length; c++)
                    {
                        G25.SMVOM smvOM = som.DomainSmvForGrade(g)[c];
                        RefGA.BasisBlade domainBlade = som.DomainForGrade(g)[c];
                        RefGA.Multivector value = new RefGA.Multivector(new RefGA.BasisBlade(domainBlade, 0)); // copy the scalar part, ditch the basis blade
                        for (uint v = 0; v < som.DomainVectors.Length; v++)
                        {
                            if ((domainBlade.bitmap & som.DomainVectors[v].bitmap) != 0)
                            {
                                value = RefGA.Multivector.op(value, imageValue[v]);
                            }
                        }

                        I.Add(new G25.CG.Shared.CommentInstruction(nbTabs, "Set image of " + domainBlade.ToString(S.m_basisVectorNames)));
                        I.Add(new G25.CG.Shared.AssignInstruction(nbTabs, smvOM, FT, mustCast, value, dstName, dstPtr, declareDst));
                    }
                }

            }

            Comment comment = new Comment("Sets " + typeName + " from a " + (transpose ? "transposed " : "") + "matrix.");
            bool writeDecl = (S.OutputC());
            bool staticFunc = false;
            G25.CG.Shared.Functions.WriteFunction(S, cgd, F, S.m_inlineSet, staticFunc, "void", funcName, returnArgument, FAI, I, comment, writeDecl);
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:75,代码来源:om_init.cs

示例15: WriteSOMstruct

        /// <summary>
        /// Writes the definition of an SOM struct to 'SB' (including comments).
        /// </summary>
        /// <param name="SB">Where the code goes.</param>
        /// <param name="S">Used for basis vector names and output language.</param>
        /// <param name="cgd">Intermediate data for code generation. Also contains plugins and cog.</param>
        /// <param name="FT">Float point type of 'SMV'.</param>
        /// <param name="som">The general outermorphism for which the struct should be written.</param>
        public static void WriteSOMstruct(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.SOM som)
        {
            SB.AppendLine("");

            { // comments for type:
                SB.AppendLine("/**");
                SB.AppendLine(" * This struct can hold a specialized outermorphism.");
                SB.AppendLine(" * ");

                SB.AppendLine(" * The coordinates are stored in type " + FT.type + ".");
                SB.AppendLine(" * ");

                SB.AppendLine(" * There are " + som.Domain.Length + " matrices, one for each grade.");
                SB.AppendLine(" * The columns of these matrices are the range of the outermorphism.");
                SB.AppendLine(" * Matrices are stored in row-major order. So the coordinates of rows are stored contiguously.");
                for (int g = 1; g < som.Domain.Length; g++) // start at '1' in order to skip scalar grade
                {
                    SB.Append(" * Domain grade " + g + ": ");
                    for (int i = 0; i < som.DomainForGrade(g).Length; i++)
                    {
                        if (i > 0) SB.Append(", ");
                        SB.Append(som.DomainForGrade(g)[i].ToString(S.m_basisVectorNames));

                    }

                    SB.AppendLine(".");
                }
                SB.AppendLine(" * ");
                if (!som.DomainAndRangeAreEqual())
                {
                    for (int g = 1; g < som.Range.Length; g++) // start at '1' in order to skip scalar grade
                    {
                        SB.Append(" * Range grade " + g + ": ");
                        for (int i = 0; i < som.RangeForGrade(g).Length; i++)
                        {
                            if (i > 0) SB.Append(", ");
                            SB.Append(som.RangeForGrade(g)[i].ToString(S.m_basisVectorNames));

                        }

                        SB.AppendLine(".");
                    }
                }
                else SB.AppendLine(" * The range and domain are equal.");
                SB.AppendLine(" * ");

                SB.AppendLine(" */");
            } // end of comment

            // typedef
            SB.AppendLine("typedef struct ");
            SB.AppendLine("{");
            for (int g = 1; g < som.Domain.Length; g++) // start at '1' in order to skip scalar grade
            {
                if (!som.EmptyGrade(g))
                {
                    SB.AppendLine("\t/** Matrix for grade " + g + "; the size is " + som.DomainForGrade(g).Length + " x " + som.RangeForGrade(g).Length + " */");
                    SB.AppendLine("\t" + FT.type + " m" + g + "[" +
                        som.DomainForGrade(g).Length * som.RangeForGrade(g).Length + "];");
                }
            }

            SB.AppendLine("} " + FT.GetMangledName(S, som.Name) + ";");
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:72,代码来源:som.cs


注:本文中的FloatType.GetMangledName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。