Isis 3 Programmer Reference
NthOrderPolynomial.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include <math.h>
8 #include <QString>
9 
10 #include "FileName.h"
11 #include "Constants.h"
12 #include "IException.h"
13 #include "NthOrderPolynomial.h"
14 
15 using namespace std;
16 namespace Isis {
17 
24  NthOrderPolynomial::NthOrderPolynomial(int degree) :
25  Isis::BasisFunction("NthOrderPolynomial", 2, degree) {
26  p_degree = degree;
27  }
28 
29 
38  void NthOrderPolynomial::Expand(const std::vector<double> &vars) {
39 
40  if((int) vars.size() != Variables()) {
41  QString mess = "Number of variables given (" + QString::number(vars.size())
42  + ") does not match expected (" + Variables() + ")!";
43  throw IException(IException::Programmer, mess, _FILEINFO_);
44  }
45 
46  double t1 = vars[0];
47  double t2 = vars[1];
48  p_terms.clear();
49  for (int i = p_degree; i >= 1; i--) {
50  p_terms.push_back(pow(t1, i) - pow(t2, i));
51  }
52  return;
53  }
54 } // end namespace isis
55 
Isis::BasisFunction
Generic linear equation class.
Definition: BasisFunction.h:48
Isis::NthOrderPolynomial::Expand
void Expand(const std::vector< double > &vars)
This is the the overriding virtual function that provides the expansion into the nth order polynomial...
Definition: NthOrderPolynomial.cpp:38
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::BasisFunction::Variables
int Variables() const
Returns the number of variables in the equation.
Definition: BasisFunction.h:72
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::BasisFunction::p_terms
std::vector< double > p_terms
A vector of the terms in the equation.
Definition: BasisFunction.h:127
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16