Пример #1
0
        public static double solveString(string anMxParserString, Dictionary <string, object> vars)
        {
            string string_to_solve = anMxParserString;

            foreach (string key in vars.Keys)
            {
                string_to_solve = string_to_solve.Replace(key, vars[key].ToString());
            }
            return(MathStrings.solveString(string_to_solve));
        }
        public override double refractiveindex(double wavelength)
        {
            // Using cached results for increased performance
            if (this.refindices.ContainsKey(wavelength))
            {
                return(this.refindices[wavelength]);
            }

            string wlstring = wavelength.ToString("F99").TrimEnd("0".ToCharArray());

            double result = MathStrings.solveString(MathStrings.matlabToMxParserString(this.user_formula), new Dictionary <string, object>()
            {
                { "nm", "((" + wlstring + ")*1000000000)" },
                { "um", "((" + wlstring + ")*1000000)" },
                { "mm", "((" + wlstring + ")*1000)" },
                { "m", wlstring }
            });

            this.refindices[wavelength] = result;
            return(result);
        }