Beispiel #1
0
        /// <summary>
        /// Updates the underlying interpolation mode, if needed.
        /// </summary>
        private void UpdateModel()
        {
            switch (this.interpolationType)
            {
            // Right now only the Least Squares requires this operation to be done.
            case EInterpolationType.LEAST_SQUARES:
                this.quadraticModel = new Fairmat.Optimization.QuadraticModel();

                // Unroll matrix and coordinate vectors in order to make it suitable
                // for the Quadratic model implementation.
                int    n     = this.values.R * this.values.C;
                Matrix xy    = new Matrix(n, 2);
                Vector z     = new Vector(n);
                int    count = 0;
                for (int x = 0; x < this.coordinatesX.Length; x++)
                {
                    for (int y = 0; y < this.coordinatesY.Length; y++)
                    {
                        xy[count, Range.All] = ((Matrix) new Vector()
                        {
                            this[x, -1], this[-1, y]
                        }).T;
                        z[count]             = this[x, y];
                        count++;
                    }
                }

                this.quadraticModel.Estimate(xy.ToArray() as double[, ], z.ToArray() as double[]);
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Updates the underlying interpolation mode, if needed.
        /// </summary>
        private void UpdateModel()
        {
            switch (this.interpolationType)
            {
                // Right now only the Least Squares requires this operation to be done.
                case EInterpolationType.LEAST_SQUARES:
                    this.quadraticModel = new Fairmat.Optimization.QuadraticModel();

                    // Unroll matrix and coordinate vectors in order to make it suitable
                    // for the Quadratic model implementation.
                    int n = this.values.R * this.values.C;
                    Matrix xy = new Matrix(n, 2);
                    Vector z = new Vector(n);
                    int count = 0;
                    for (int x = 0; x < this.coordinatesX.Length; x++)
                    {
                        for (int y = 0; y < this.coordinatesY.Length; y++)
                        {
                            xy[count, Range.All] = ((Matrix)new Vector() { this[x, -1], this[-1, y] }).T;
                            z[count] = this[x, y];
                            count++;
                        }
                    }

                    this.quadraticModel.Estimate(xy.ToArray() as double[,], z.ToArray() as double[]);
                    break;
                default:
                    break;
            }
        }