public double Evaluate(Vector input)
        {
            Vector innerVector = new Vector(1);

            innerVector[0] = InnerFunction.Evaluate(input);
            return(OuterFunction.Evaluate(innerVector));
        }
Example #2
0
        public float Evaluate(float x)
        {
            float y = x;

            if (InnerFunction != null)
            {
                y = InnerFunction.Evaluate(x);
            }
            y = EvaluateThis(y);
            if (OuterFunction != null)
            {
                y = OuterFunction.Evaluate(y);
            }
            return(y);
        }
Example #3
0
        public CallTipInfo(InnerFunction innerFunction)
        {
            StringBuilder sb      = new StringBuilder(innerFunction.Name).Append("(");
            bool          trimEnd = false;

            foreach (Parameter parameter in innerFunction.Parameters)
            {
                int start = sb.Length;

                if (parameter.ByRef)
                {
                    sb.Append("ref ");
                }
                if (parameter.VaArgs)
                {
                    sb.Append("params ");
                }
                sb.Append(parameter.Name);

                if (parameter.DefaultValue != null)
                {
                    switch (parameter.DefaultValue.Class.ClassID)
                    {
                    case ClassID.Date:
                        sb.AppendFormat(" = `{0}`", parameter.DefaultValue);
                        break;

                    case ClassID.String:
                        sb.AppendFormat(" = '{0}'", parameter.DefaultValue);
                        break;

                    default:
                        sb.AppendFormat(" = {0}", parameter.DefaultValue);
                        break;
                    }
                }

                parameters.Add(new ParameterInfo(start, sb.Length, parameter.VaArgs));
                sb.Append(", ");
                trimEnd = true;
            }

            if (trimEnd)
            {
                sb.Remove(sb.Length - 2, 2);
            }
            Text = sb.Append(")").ToString();
        }
Example #4
0
        public Matrix <PF> ComputeParametersJacobian(IFD input)
        {
            if (OuterFunction.ParametersCount > 0 && InnerFunction.ParametersCount > 0)
            {
                Matrix <PF> outerParamsJacobian = OuterFunction.ComputeParametersJacobian(InnerFunction.Compute(input));
                Matrix <PF> outerVarsJacobian   = OuterFunction.ComputeVariablesJacobian(InnerFunction.Compute(input));
                Matrix <PF> innerParamsJacobian = InnerFunction.ComputeParametersJacobian(input);

                return(Matrix <PF> .ConcatRows(outerParamsJacobian, outerVarsJacobian *innerParamsJacobian));
            }
            else if (OuterFunction.ParametersCount == 0)
            {
                Matrix <PF> outerVarsJacobian   = OuterFunction.ComputeVariablesJacobian(InnerFunction.Compute(input));
                Matrix <PF> innerParamsJacobian = InnerFunction.ComputeParametersJacobian(input);

                return(outerVarsJacobian * innerParamsJacobian);
            }
            else
            {
                return(OuterFunction.ComputeParametersJacobian(InnerFunction.Compute(input)));
            }
        }
Example #5
0
 public void GetAllParametersOptimizationScales(PF[] buffer, int startIndex)
 {
     OuterFunction.GetAllParametersOptimizationScales(buffer, startIndex);
     InnerFunction.GetAllParametersOptimizationScales(buffer, startIndex + OuterFunction.ParametersCount);
 }
Example #6
0
 public void SetAllParameters(PF[] paramValues, int startIndex)
 {
     OuterFunction.SetAllParameters(paramValues, startIndex);
     InnerFunction.SetAllParameters(paramValues, startIndex + OuterFunction.ParametersCount);
 }
Example #7
0
 public Matrix <PF> ComputeVariablesJacobian(IFD input)
 {
     return(OuterFunction.ComputeVariablesJacobian(InnerFunction.Compute(input)) * InnerFunction.ComputeVariablesJacobian(input));
 }
Example #8
0
 public OFR Compute(IFD input)
 {
     return(OuterFunction.Compute(InnerFunction.Compute(input)));
 }
 /// <summary>
 /// Initializes a new instance of InnerFunctionCall
 /// </summary>
 /// <param name="function">The inner function to call</param>
 /// <param name="arguments">The list of arguments</param>
 public InnerFunctionCall(InnerFunction function, params Expression[] arguments)
     : base(arguments)
 {
     Function = function;
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InnerExpression"/> class.
 /// </summary>
 /// <param name="funName">Name of the fun.</param>
 /// <param name="paramsBody">The params body.</param>
 /// <param name="res">The res.</param>
 public InnerExpression(string funName, string paramsBody, IResourceDependency res)
 {
     SetResourceDependency(res);
     this.IsFunction = true;
     this._equalFun = new InnerFunction(funName, paramsBody, res);
     this.TagDefinition = this._equalFun.TagDefinition;
 }
Example #11
0
            /// <summary>
            /// 获取改参数的真实值
            /// </summary>
            public object GetValue()
            {
                //Util.Debug(false, "Get Param Value:[" + this.ParamDefine + "] Is Fun:" + IsFunction.ToString());
                if (this.ParamDefine == null) return null;

                if (IsExpression == true)
                {
                    InnerExpression exp = new InnerExpression(this.ParamDefine, GetResourceDependency());
                    return exp.GetValue();
                }
                else if (IsFunction == true)
                {
                    int idx = this.ParamDefine.IndexOf('(');
                    string funName = (idx == 0) ? null : this.ParamDefine.Substring(0, idx);
                    //Util.Debug(false, this.ParamDefine.Substring(idx + 1).TrimEnd(')'));
                    InnerFunction fun = new InnerFunction(funName,
                        this.ParamDefine.Substring(idx+1).TrimEnd(')'),
                        this.GetResourceDependency());
                    return fun.Execute();
                }
                else
                {
                    #region 字符型
                    if (this.ParamDefine.StartsWith("\"") && this.ParamDefine.EndsWith("\""))
                    {
                        return this.ParamDefine.Trim('"');
                    }
                    else if (this.ParamDefine.StartsWith("'") && this.ParamDefine.EndsWith("'"))
                    {
                        return this.ParamDefine.Trim('\'');
                    }
                    #endregion

                    if (this.ParamDefine.StartsWith("%") && this.ParamDefine.EndsWith("%"))
                    {
                        #region 已定义资源数据
                        string define = string.Concat("{#", this.ParamDefine, "#}");
                        if (this.Res != null && Res.IsDefined(define))
                        {
                            return Res.GetDefinition(define);
                        }
                        else
                        {
                            return "";
                        }
                        #endregion
                    }
                    else if (this.ParamDefine.StartsWith("$") && this.ParamDefine.EndsWith("$"))
                    {
                        #region 系统标签
                        SystemTag sysTag = new SystemTag(string.Concat("{#", this.ParamDefine, "#}"));
                        sysTag.SetResourceDependency(GetResourceDependency());
                        return sysTag.ToString();
                        #endregion
                    }
                    else
                    {
                        #region 布尔及数字型
                        if (string.Compare(this.ParamDefine, "true", true) == 0)
                        {
                            return true;
                        }
                        else if (string.Compare(this.ParamDefine, "false", true) == 0)
                        {
                            return false;
                        }
                        else
                        {
                            if (Regex.IsMatch(this.ParamDefine, @"^[\d,]+$", RegexOptions.Compiled))
                            {
                                try
                                {
                                    double dec = double.Parse(this.ParamDefine);
                                    return dec;
                                }
                                catch (Exception)
                                {
                                    return 0;
                                }
                            }
                            else
                            {
                                return this.ParamDefine;
                            }
                        }
                        #endregion
                    }
                }
            }