Isis 3 Programmer Reference
PolynomialBivariate.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include <iostream>
8 #include "PolynomialBivariate.h"
9 
10 namespace Isis {
18  Isis::BasisFunction("PolynomialBivariate", 2, ((degree + 1) * (degree + 2)) / 2) {
19  p_degree = degree;
20  }
21 
29  void PolynomialBivariate::Expand(const std::vector<double> &vars) {
30  std::vector<std::vector<double> > terms;
31  terms.resize(p_degree + 1);
32  terms[0].push_back(1.0);
33  for(int i = 1; i <= p_degree; i++) {
34  for(int t = 0; t < (int)terms[i-1].size(); t++) {
35  terms[i].push_back(terms[i-1][t] * vars[0]);
36  if(t == ((int)terms[i-1].size() - 1)) {
37  terms[i].push_back(terms[i-1][t] * vars[1]);
38  }
39  }
40  }
41 
42  p_terms.clear();
43  for(int i = 0; i <= p_degree; i++) {
44  for(int t = 0; t < (int)terms[i].size(); t++) {
45  p_terms.push_back(terms[i][t]);
46  }
47  }
48  }
49 } // end namespace isis
50 
Isis::BasisFunction
Generic linear equation class.
Definition: BasisFunction.h:48
Isis::PolynomialBivariate::PolynomialBivariate
PolynomialBivariate(int degree)
Create a PolynomialBivariate object.
Definition: PolynomialBivariate.cpp:17
Isis::PolynomialBivariate::p_degree
int p_degree
The order/degree of the polynomial.
Definition: PolynomialBivariate.h:47
Isis::PolynomialBivariate::Expand
void Expand(const std::vector< double > &vars)
This is the the overriding virtual function that provides the expansion of the two input variables in...
Definition: PolynomialBivariate.cpp:29
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