Ejemplo n.º 1
0
        public static object acq_interpolator_scattered_create(
            [ExcelArgument(Description = "nodes")] double[,] x,
            [ExcelArgument(Description = "function values ")]  double[] y,
            [ExcelArgument(Description = "scales")]  object scales,
            [ExcelArgument(Description = "multiquadrics")] object method)
        {
            if (ExcelDnaUtil.IsInFunctionWizard())
            {
                return(ExcelError.ExcelErrorRef);
            }
            else
            {
                return(ACQ.Excel.Handles.GlobalCache.CreateHandle(m_tag, new object[] { x, y, scales, method, "acq_interpolator_scattered_create" },
                                                                  (objectType, parameters) =>
                {
                    ACQ.Math.Interpolation.ScatteredInterpolationInterface interpolator = construct_interpolator(x, y, scales, method);

                    if (interpolator == null)
                    {
                        return ExcelError.ExcelErrorNull;
                    }
                    else
                    {
                        return interpolator;
                    }
                }));
            }
        }
Ejemplo n.º 2
0
        private static ACQ.Math.Interpolation.ScatteredInterpolationInterface construct_interpolator(double[,] x, double[] y, object input_scales, object method)
        {
            ACQ.Math.Interpolation.ScatteredInterpolationInterface interpolator = null;
            try
            {
                ACQ.Math.Interpolation.enRadialBasisFunction rbf_function = ExcelHelper.CheckEnum <ACQ.Math.Interpolation.enRadialBasisFunction>(method, ACQ.Math.Interpolation.enRadialBasisFunction.Linear);

                double[] scales = null; //null argument is ok

                if (!(input_scales is ExcelMissing) && input_scales != null)
                {
                    if (input_scales is double)
                    {
                        double const_scale = (double)input_scales;
                        scales = new double[x.GetLength(1)];

                        for (int i = 0; i < scales.Length; i++)
                        {
                            scales[i] = const_scale;
                        }
                    }
                    else if (input_scales is object[])
                    {
                        object[] vect_scale = input_scales as object[];
                        scales = new double[x.GetLength(1)];

                        for (int i = 0; i < scales.Length; i++)
                        {
                            if (i < vect_scale.Length && vect_scale[i] is double)
                            {
                                scales[i] = (double)vect_scale[i];
                            }
                            else
                            {
                                scales[i] = 1.0;
                            }
                        }
                    }
                }

                interpolator = new ACQ.Math.Interpolation.RbfInterpolation(x, y, rbf_function, scales, 0.0);
            }
            catch (Exception ex)
            {
                LogDisplay.WriteLine("Error: " + ex.ToString());
            }
            return(interpolator);
        }