USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::BasisFunction Class Reference
[Math]

Generic linear equation class. More...

#include <BasisFunction.h>

Inherited by Isis::Basis1VariableFunction, Isis::Parabola, and Isis::PolynomialBivariate.

List of all members.

Public Member Functions

 BasisFunction (const std::string &name, int numVars, int numCoefs)
 Creates a BasisFunction object.
virtual ~BasisFunction ()
 Destroys the BasisFunction object.
void SetCoefficients (const std::vector< double > &coefs)
 Set the coefficients for the equation.
double Evaluate (const std::vector< double > &vars)
 Compute the equation using the input variables.
virtual void Expand (const std::vector< double > &vars)
 This is the function you should replace depending on your needs.
int Coefficients () const
 Returns the number of coefficients for the equation.
int Variables () const
 Returns the number of variables in the equation.
std::string Name () const
 Returns the name of the equation.
double Term (int c) const
 Returns the cth term.
double Coefficient (int i) const
 Returns the ith coefficient.

Protected Attributes

std::string p_name
 The name of the equation. Call it by using Name().
int p_numVars
 The number of variables in the equation. Call it by using Variables().
int p_numCoefs
 The number of coefficients in the equation.
std::vector< double > p_coefs
 A vector of the coefficients in the equation.
std::vector< double > p_terms
 A vector of the terms in the equation.

Detailed Description

Generic linear equation class.

This is a base class for generating "generic" equations for the Isis least squares fitting algorithm (IsisLSQ). It allows the programmer to set up equations in the form of:

\[ x = C1*T1 + C2*T2 + ... + CN*TN; \]

where C1-CN are coefficients and T1-TN are terms. Note that terms can be comprised of multiple variables and/or functions. For example,

\[ x = C1 + C2*y + C3*y**2; \]

\[ x = C1 + C2*y + C3*z + C4*y*z; \]

By deriving different functions off of this base class this allows the least squares class to be generalized.

Author:
2004-06-24 Jeff Anderson

Constructor & Destructor Documentation

Isis::BasisFunction::BasisFunction ( const std::string &  name,
int  numVars,
int  numCoefs 
)

Creates a BasisFunction object.

Parameters:
name Name of the BasisFunction. For example, "affine".
numVars Number of variables in the equation. For example:

\[ x = C1 + C2*y + C3*z \]

has two variables: y and z.

numCoefs Number of coefficients in the equation. For example:

\[ x = C1 + C2*y + C3*z \]

has three coefficients: C1, C2 & C3.

virtual Isis::BasisFunction::~BasisFunction (  )  [inline, virtual]

Destroys the BasisFunction object.


Member Function Documentation

double Isis::BasisFunction::Coefficient ( int  i  )  const [inline]

Returns the ith coefficient.

Parameters:
i The index for the desired coefficient.
Returns:
The ith coefficient

References p_coefs.

Referenced by Isis::AutoReg::ModelSurface(), Isis::OverlapNormalization::Solve(), and Isis::Affine::Solve().

int Isis::BasisFunction::Coefficients (  )  const [inline]

Returns the number of coefficients for the equation.

Returns:
The number of coefficients.

References p_numCoefs.

Referenced by Isis::OverlapNormalization::Solve().

double Isis::BasisFunction::Evaluate ( const std::vector< double > &  vars  ) 

Compute the equation using the input variables.

Parameters:
vars A vector of double values to use for the equation. After setting the coefficients, this can be invoked many times to compute output values given input values.
Returns:
The output value.

Referenced by Isis::SpicePosition::SetEphemerisTimePolyFunction().

void Isis::BasisFunction::Expand ( const std::vector< double > &  vars  )  [virtual]

This is the function you should replace depending on your needs.

It will expand the variables into the terms of the equation. For example,

\[ x = C1 + C2*y + C3*z + C4*y*z \]

must be expanded into the p_terms vector as (1.0, y, z, y*z). Note that the term expansion is not limited, you can use cos, sin, sqrt, abs, etc. This virtual method is automatically invoked by the Evaluate method. We provide a default expansion of p_terms = vars, just a linear combination of the variables.

Parameters:
vars A vector of double values to use for the expansion.

Reimplemented in Isis::Parabola, Isis::PolynomialBivariate, and Isis::PolynomialUnivariate.

std::string Isis::BasisFunction::Name (  )  const [inline]

Returns the name of the equation.

Returns:
The name of the equation.

References p_name.

void Isis::BasisFunction::SetCoefficients ( const std::vector< double > &  coefs  ) 

Set the coefficients for the equation.

Parameters:
coefs A vector of coefficients for the equation.

Referenced by Isis::SpicePosition::SetEphemerisTimePolyFunction(), and Isis::SpicePosition::SetPolynomial().

double Isis::BasisFunction::Term ( int  c  )  const [inline]

Returns the cth term.

This is only valid after a Evalute/Expand has been invoked. It represents the expansion of the variables into the ith term. For example,

\[ x = C1 + C2*x + C3*y + C4*x*y \]

would return x*y for the 3rd term (zero-based)

Parameters:
c The index for the desired coefficient.
Returns:
The cth term.

References p_terms.

int Isis::BasisFunction::Variables (  )  const [inline]

Returns the number of variables in the equation.

Returns:
The number of variables.

References p_numVars.


Member Data Documentation

std::vector<double> Isis::BasisFunction::p_coefs [protected]

A vector of the coefficients in the equation.

Call it by using Coefficient()

Referenced by Coefficient().

std::string Isis::BasisFunction::p_name [protected]

The name of the equation. Call it by using Name().

Referenced by Name().

The number of coefficients in the equation.

Call it by using Coefficients()

Referenced by Coefficients().

The number of variables in the equation. Call it by using Variables().

Referenced by Variables().

std::vector<double> Isis::BasisFunction::p_terms [protected]

A vector of the terms in the equation.

Call it by using Term()

Referenced by Term().


The documentation for this class was generated from the following files: