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


C# G25.IsCoordinateConstant方法代码示例

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


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

示例1: WriteGMVtoSMVcopy

        /// <summary>
        /// Writes functions to copy GMVs to SMVs
        /// </summary>
        /// <param name="S"></param>
        /// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param>
        public static void WriteGMVtoSMVcopy(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT, G25.SMV smv)
        {
            StringBuilder defSB = cgd.m_defSB;

            G25.GMV gmv = S.m_GMV;
            string srcClassName = FT.GetMangledName(S, gmv.Name);

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

            bool dstPtr = false;
            string[] smvAccessStr = G25.CG.Shared.CodeUtil.GetAccessStr(S, smv, G25.CG.Shared.SmvUtil.THIS, dstPtr);

            string funcName = GMV.GetSetFuncName(S);

            string FINAL = (S.OutputJava()) ? "final " : "";
            string funcDecl = "\tpublic " + FINAL + "void " + funcName + "(" + FINAL + srcClassName + " src)";

            defSB.Append(funcDecl);
            {
                defSB.AppendLine(" {");

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

                // what is the highest group of the 'gmv' that must be (partially) copied to the 'smv'
                int highestGroup = -1;
                foreach (KeyValuePair<Tuple<int, int>, Tuple<int, int>> KVP in D)
                    if (KVP.Value.Value1 > highestGroup) highestGroup = KVP.Value.Value1;

                // generate code for each group
                for (int g = 0; g <= highestGroup; g++)
                {
                    // determine if group 'g' is to be copied to smv:
                    bool groupIsUsedBySMV = false;
                    foreach (KeyValuePair<Tuple<int, int>, Tuple<int, int>> KVP in D)
                    {
                        // KVP.Key = SMV<group, element>
                        // KVP.Value = GMV<group, element>
                        if (KVP.Value.Value1 == g)
                        {
                            if (!smv.IsCoordinateConstant(KVP.Key.Value2))
                            {
                                groupIsUsedBySMV = true;
                                break;
                            }
                        }
                    }

                    // if group is present in GMV:
                    if (groupIsUsedBySMV)
                    {
                        defSB.AppendLine("\t\tif (src.c()[" + g + "] != null) {");
                        defSB.AppendLine("\t\t\t" + FT.type + "[] ptr = src.c()[" + g + "];");
                        bool mustCast = false;
                        bool srcPtr = true;
                        int nbTabs = 3;
                        RefGA.Multivector[] value = G25.CG.Shared.Symbolic.GMVtoSymbolicMultivector(S, gmv, "ptr", srcPtr, g);
                        bool writeZeros = false;
                        string str = G25.CG.Shared.CodeUtil.GenerateSMVassignmentCode(S, FT, mustCast, smv, G25.CG.Shared.SmvUtil.THIS, dstPtr, value[g], nbTabs, writeZeros);
                        defSB.Append(str);
                        defSB.AppendLine("\t\t}");

                        defSB.AppendLine("\t\telse {");
                        foreach (KeyValuePair<Tuple<int, int>, Tuple<int, int>> KVP in D)
                        {
                            if ((KVP.Value.Value1 == g) && (!smv.IsCoordinateConstant(KVP.Key.Value2)))
                            {
                                // translate KVP.Key.Value2 to non-const idx, because the accessStrs are only about non-const blades blades!
                                int bladeIdx = smv.BladeIdxToNonConstBladeIdx(KVP.Key.Value2);
                                defSB.AppendLine("\t\t\t" + smvAccessStr[bladeIdx] + " = " + FT.DoubleToString(S, 0.0) + ";");
                            }
                        }
                        defSB.AppendLine("\t\t}");
                    }
                }
                defSB.AppendLine("\t}");
            }
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:84,代码来源:smv.cs

示例2: SMVtoXmlString

        /// <summary>
        /// Converts a G25.SMV to an XML string representation.
        /// </summary>
        /// <param name="S"></param>
        /// <param name="smv"></param>
        /// <returns>XML string representation of 'smv'.</returns>
        public static string SMVtoXmlString(Specification S, G25.SMV smv)
        {
            StringBuilder SB = new StringBuilder();
            bool constant = smv.IsConstant() && (S.GetMatchingConstant(smv) != null);
            string name = smv.Name;

            // remove the extra constant suffix?
            if (constant && name.EndsWith(Specification.CONSTANT_TYPE_SUFFIX))
                name = name.Substring(0, name.Length - Specification.CONSTANT_TYPE_SUFFIX.Length);

            SB.Append("<" + XML_SMV);

            // name
            SB.Append(" " + XML_NAME + "=\"" + name + "\"");

            // constant?
            if (constant)
                SB.Append(" " + XML_CONST + "=\"" + XML_TRUE + "\"");

            // type
            SB.Append(" " + XML_TYPE + "=\"" + smv.MvTypeString + "\"");

            // end of XML_SMV tag
            SB.Append(">");

            { // emit coordinate order:
                string[] bvNames = (string[])S.m_basisVectorNames.ToArray();
                // loop over all basis blades
                for (int b = 0; b < smv.Group(0).Length; b++)
                {
                    if (b > 0) SB.Append(" ");
                    string bbStr = BasisBladeToString(smv.BasisBlade(0, b), bvNames);
                    SB.Append(bbStr);

                    // if constant, add '=....'
                    if (smv.IsCoordinateConstant(b))
                        SB.Append("=" + smv.ConstBasisBladeValue(smv.BladeIdxToConstBladeIdx(b)).ToString());
                }
                if (smv.Comment.Length > 0)
                    SB.Append("  <" + XML_COMMENT + ">" + smv.Comment + "</" + XML_COMMENT + ">");
            }

            SB.Append("</" + XML_SMV + ">\n");

            return SB.ToString();
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:52,代码来源:xml.cs


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