CLsqFit:GetPolyCoefIndex
The GetPolyCoefIndex method converts the n-th dimension polynomial coefficient index to a single index in the coefficient table. Use this method with the n-dimensional polynomial basis function when the number of basis dimensions is higher than 1. Then the polynomial dimension is greater than 1, this method is needed for getting the index to pass to GetCoef, GetCoefErr, ForceCoef, and other methods since they accept only a single index argument..
nValue = CLsqFit:GetPolyCoefIndex( nIndex1, nIndex2, ... ) |
nIndex1, etc., are indices for the polynomial dimension. Up to 10 indices are allowed.
This function converts the n-dimensional polynomial coefficient index into a single value. The polynomial coefficients are stored in a table based on a hierarchy where the first index is the most rapidly varying index, the second index is second most rapidly varying, and so on. For example, if fitting 5 x 3 coefficients to a 2-dimensional polynomial, the coefficients are stored in 3 rows of 5 values. This method does not check that each dimensional index is within bounds, but rather only that the final result is in the range defined by the limits 1 and GetNumCoefs.
The following script retrieves the number of dimensions used by the basis function being fit.
|
-- create a CLsqFit object |
|
-- Declare a 4x3 polynomial fit in 2 dimensions |
|
-- fetch the index of 3, 2 |
|
-- result: n = 8 ( element 3 in row 2 with row length 5) |
|
-- fetch the index of 12, 4 (out of bounds) |
|
-- result: n = 6 (out of bounds returns 1 or max index) |
The next script sets a polynomial fit of 3 dimensions and retrieves the index of a point:
|
-- create a CLsqFit object |
|
-- Declare a 7x3x5 polynomial (7 cols, 3 rows, 5 planes) |
|
-- fetch the index of indices 1, 2, 4 |
|
-- result: n = 71 (column 1 in row 2 in plane 4) |
The final script sets a polynomial of 1 dimension and retrieves the index of a point: In this case, calling GetPolyCoefIndex returns the same index as is passed as an argument:
|
-- create a CLsqFit object |
|
-- Declare a 9 coef polynomial in 1 dimension |
|
-- fetch the index of index 6 |
|
-- result: n = 6 |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.