Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
NthOrderPolynomial.cpp
1
5
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
15using namespace std;
16namespace Isis {
17
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
BasisFunction(const QString &name, int numVars, int numCoefs)
Creates a BasisFunction object.
std::vector< double > p_terms
A vector of the terms in the equation.
int Variables() const
Returns the number of variables in the equation.
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
void Expand(const std::vector< double > &vars)
This is the the overriding virtual function that provides the expansion into the nth order polynomial...
NthOrderPolynomial(int degree)
Create an NthOrderPolynomial.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.