CLsqFit:SetBasisFunc


The SetBasisFunc method selects the basis function to use for the fit. This function selects one of the two built-in basis functions or a function you specify in the script. This topic and the details of parameter passing are discussed in Basis Functions.

Syntax

CLsqFit:SetBasisFunc( selection )

where

    selection is a number or string specifying the basis function. To use a built-in basis function, pass its number. To specify a basis function declared in the script, pass its name as a string.

  

This function takes either a number of string value to select the basis function. Mira interprets a number value as a built-in basis function. A string is interpreted as the name of a function in the script:

 

1

The built-in (default) n-dimensional polynomial basis function.

2

The built-in hyperplane basis function.

(else)

The name of a basis function defined in the script.

Note that the value returned by GetBasisFunc is always a string. The number index 1 or 2 is returned as a string as is the name of a basis function declared in the script.

Examples

The following script selects the built-in hyperplane basis function.

L = CLsqFit:new()

-- create a CLsqFit object

 

-- no function declared, n-dimensional polynomial (1) assumed

L:SetBasisFunc( 2 )

-- select built-in function 2, the Hyperplane

sName = L:GetBasisFunc()

 

Printf( "Func= '%s'\n", sName )

-- result: Func= '2'

To next example declares a basis function in the script and then registers it for use. This function, named "Line", fits a line:

function Line( n, c )

-- declare the basis function

  b = {}

-- declare an array for the basis vector

  b[1] = 1

-- basis vector element [1] is 1

  b[2] = c[1]

-- basis vector element [2] is c[1]

  return b

-- return the basis vector

end

-- end of the basis function

L = CLsqFit:new()

-- create a CLsqFit object

L:SetBasisFunc( "Line" )

-- register the script function "Line"

sName = L:GetBasisFunc()

 

Printf( "Func= '%s'\n", sName )

-- result: Func= 'Line'

Related Topics

GetBasisFunc

GetBasisDim

Basis Functions

CLsqFit class