本文整理汇总了C#中Specification.IsFloatType方法的典型用法代码示例。如果您正苦于以下问题:C# Specification.IsFloatType方法的具体用法?C# Specification.IsFloatType怎么用?C# Specification.IsFloatType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Specification
的用法示例。
在下文中一共展示了Specification.IsFloatType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: value
protected RefGA.Multivector m_returnValue; ///< returned value (symbolic multivector)
#endregion Fields
#region Methods
/// <summary>
/// Checks if this FunctionGenerator can implement a certain function.
/// </summary>
/// <param name="S">The specification of the algebra.</param>
/// <param name="F">The function to be implemented.</param>
/// <returns>true if 'F' can be implemented</returns>
public override bool CanImplement(Specification S, G25.fgs F)
{
String arg1Type = F.GetArgumentTypeName(0, S.m_GMV.Name);
return ((F.Name == "sas") && (F.MatchNbArguments(3) &&
(S.IsSpecializedMultivectorName(arg1Type) || (arg1Type == S.m_GMV.Name)) &&
S.IsFloatType(F.GetArgumentTypeName(1, S.m_GMV.Name)) &&
S.IsFloatType(F.GetArgumentTypeName(2, S.m_GMV.Name))));
}
示例2: GetFuncDecl
private static string GetFuncDecl(Specification S, bool declOnly, G25.fgs FGS, G25.Operator op, G25.FloatType FT, bool assign, bool constVal, bool returnByReference)
{
StringBuilder SB = new StringBuilder();
string inlineStr = G25.CG.Shared.Util.GetInlineString(S, (!declOnly) && S.m_inlineOperators, " ");
string returnTypeName = (FGS.m_returnTypeName.Length > 0) ? FGS.m_returnTypeName : FT.type;
if (!S.IsFloatType(returnTypeName)) returnTypeName = FT.GetMangledName(S, returnTypeName);
string arg1typeName = FT.GetMangledName(S, FGS.ArgumentTypeNames[0]);
string arg2typeName = (FGS.NbArguments > 1) ? FT.GetMangledName(S, FGS.ArgumentTypeNames[1]) : "";
SB.Append(inlineStr);
SB.Append(returnTypeName);
SB.Append(" ");
if (returnByReference) SB.Append("&");
SB.Append("operator");
SB.Append(op.Symbol);
if (assign) SB.Append("=");
SB.Append("(");
if (constVal) SB.Append("const ");
SB.Append(arg1typeName);
SB.Append(" &");
SB.Append(FGS.ArgumentVariableNames[0]);
if (op.IsBinary())
{
SB.Append(", const ");
SB.Append(arg2typeName);
SB.Append(" &");
SB.Append(FGS.ArgumentVariableNames[1]);
}
else if ((S.OutputCpp()) && op.IsPostfixUnary())
{ // add a dummy int argument so C++ knows this is a unary postfix op
SB.Append(", int");
}
SB.Append(")");
return SB.ToString();
}
示例3: IsCoordBased
/// <returns>true when input to function is coordinates.</returns>
public bool IsCoordBased(Specification S, G25.fgs F, FloatType FT)
{
return F.MatchNbArguments(S.m_dimension - 2) &&
S.IsFloatType(F.GetArgumentTypeName(0, FT.type)) &&
(!IsRandom(S, F));
}
示例4: CanImplement
/// <summary>
/// Checks if this FunctionGenerator can implement a certain function.
/// </summary>
/// <param name="S">The specification of the algebra.</param>
/// <param name="F">The function to be implemented.</param>
/// <returns>true if 'F' can be implemented</returns>
public override bool CanImplement(Specification S, G25.fgs F)
{
return F.Name.StartsWith(RANDOM) &&
S.IsFloatType(F.Name.Substring(RANDOM.Length));
}
示例5: WriteOperators
private static void WriteOperators(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, bool declOnly)
{
Dictionary<string, List<G25.Operator>> operatorMap = S.GetOperatorMap();
Dictionary<string, bool> boundOperators = new Dictionary<string,bool>();
// for all functions, find the matching op, write function
foreach (G25.fgs FGS in S.m_functions)
{
if (!operatorMap.ContainsKey(FGS.OutputName)) continue;
//if (FGS.MetricName != S.m_metric[0].m_name) continue; // only bind for default metric
// check if all argument types are built-in
bool allArgTypesAreBuiltin = true;
for (int i = 0; i < FGS.m_argumentTypeNames.Length; i++)
if (!S.IsFloatType(FGS.m_argumentTypeNames[i]))
allArgTypesAreBuiltin = false;
if (allArgTypesAreBuiltin) continue; // cannot overload operator for builtin types
List<G25.Operator> opList = operatorMap[FGS.OutputName];
foreach (G25.Operator op in opList)
{
if (op.NbArguments == FGS.NbArguments)
{
// check if this operator already bound to function with the same arguments
string uniqueOpArgId = op.Symbol;
for (int a = 0; a < FGS.NbArguments; a++)
uniqueOpArgId += "~_~" + FGS.m_argumentTypeNames[a];
if (boundOperators.ContainsKey(uniqueOpArgId)) continue;
else boundOperators[uniqueOpArgId] = true;
// write this operator for all float types
WriteOperator(SB, S, cgd, declOnly, FGS, op);
}
}
}
}
示例6: NotMixScalarGmv
/// <summary>
/// Return true if 'F' does not mix arguments of type scalar and GMV
/// </summary>
/// <param name="S">Specification of algebra</param>
/// <param name="F">Function specification</param>
/// <param name="defaultArgType">Default argument type for all arguments (todo: allow for per-argument type)</param>
/// <param name="nbArgs">Number of arguments.</param>
/// <returns>true if 'F' does not mix arguments of type scalar and GMV</returns>
public static bool NotMixScalarGmv(Specification S, G25.fgs F, int nbArgs, String defaultArgType)
{
bool useScalar = false;
bool useGMV = false;
for (int a = 0; a < nbArgs; a++)
{
String typeName = F.GetArgumentTypeName(a, defaultArgType);
useScalar |= S.IsFloatType(typeName);
useGMV |= S.m_GMV.Name == typeName;
}
return (!(useScalar && useGMV));
}
示例7: CanImplement
/// <summary>
/// Checks if this FunctionGenerator can implement a certain function.
/// </summary>
/// <param name="S">The specification of the algebra.</param>
/// <param name="F">The function to be implemented.</param>
/// <returns>true if 'F' can be implemented</returns>
public override bool CanImplement(Specification S, G25.fgs F)
{
return ((F.Name == "div") && (F.MatchNbArguments(2) &&
S.IsFloatType(F.ArgumentTypeNames[1])));
}
示例8: GetFunctionName
/// <summary>
/// Returns the name of a generated function (for example <c>gp_mv_mv</c>).
/// If the function is not found, a DependencyException is thrown.
///
/// The function is found by looking through all G25.FGS in the specification.
/// </summary>
/// <param name="S">The spec.</param>
/// <param name="functionName">Basic name of the function to be found.</param>
/// <param name="argumentTypes">Names of the arguments types (not mangled).</param>
/// <param name="returnTypeName">Name of the return type (can be null or "" for default return type).</param>
/// <param name="FT">Floating point type.</param>
/// <param name="metricName">(optional, can be null for don't care)</param>
/// <returns>The mangled name of the function.</returns>
public static string GetFunctionName(Specification S, string functionName, string[] argumentTypes, string returnTypeName, G25.FloatType FT, string metricName)
{
fgs F = S.FindFunctionEx(functionName, argumentTypes, returnTypeName, new String[] { FT.type }, metricName);
if (F == null) // error: function not found
{
string exStr = "G25.CG.Shared.Util.GetFunctionName(): cannot find function " + functionName + " with arguments (";
for (int i = 0; i < argumentTypes.Length; i++)
{
if (i > 0) exStr = exStr + ", ";
exStr = exStr + argumentTypes[i];
}
exStr = exStr + ") and using floating point type " + FT.type;
if (metricName != null)
{
exStr = exStr + " and using metric " + metricName;
}
throw new DependencyException(exStr);
}
else
{
argumentTypes = F.ArgumentTypeNames;
string mangledFuncName = F.OutputName;
if (S.OutputC())
{
// add mangled argument types to function name
string[] mangledArgumentTypes = new string[argumentTypes.Length];
for (int i = 0; i < argumentTypes.Length; i++)
{
if (Util.DontAppendTypename(argumentTypes[i]))
continue;
mangledArgumentTypes[i] = (S.IsFloatType(argumentTypes[i])) ? FT.type : FT.GetMangledName(S, argumentTypes[i]);
}
mangledFuncName = Util.AppendTypenameToFuncName(S, FT, F.OutputName, mangledArgumentTypes);
//mangledFuncName = FT.GetMangledName(S, mangledFuncName);
}
else if (argumentTypes.Length == 0)
{
// test to apply mangling when no arguments are present.
mangledFuncName = FT.GetMangledName(S, mangledFuncName);
}
return mangledFuncName;
}
}