39 template <
typename Real>
42 public ApprQuery<Real, ApprPolynomial2<Real>, std::array<Real, 2>>
53 bool Fit(std::vector<std::array<Real, 2>>
const& observations,
54 std::vector<int>
const&
indices);
59 Real
Error(std::array<Real, 2>
const& observation)
const;
76 template <
typename Real>
83 mXDomain[0] = std::numeric_limits<Real>::max();
88 template <
typename Real>
94 template <
typename Real>
96 std::vector<std::array<Real, 2>>
const& observations,
97 std::vector<int>
const&
indices)
99 if (indices.size() > 0)
104 int numSamples =
static_cast<int>(indices.size());
107 for (s = 0; s < numSamples; ++
s)
109 Real
x = observations[indices[
s]][0];
113 xPower[
s][0] = (Real)1;
114 for (i0 = 1; i0 <= twoDegree; ++i0)
116 xPower[
s][i0] = x * xPower[
s][i0 - 1];
124 for (i0 = 0; i0 <=
mDegree; ++i0)
127 for (s = 0; s < numSamples; ++
s)
129 Real
w = observations[indices[
s]][1];
130 sum += w * xPower[
s][i0];
135 for (i1 = 0; i1 <=
mDegree; ++i1)
138 for (s = 0; s < numSamples; ++
s)
140 sum += xPower[
s][i0 + i1];
149 bool hasNonzero =
false;
150 for (
int i = 0; i <
mSize; ++i)
153 if (coefficients[i] != (Real)0)
166 template <
typename Real>
171 Real error =
std::abs(w - observation[1]);
175 template <
typename Real>
181 template <
typename Real>
187 template <
typename Real>
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
std::array< Real, 2 > const & GetXDomain() const
Real Evaluate(Real x) const
std::vector< Real > const & GetParameters() const
std::vector< Real > mParameters
bool Fit(std::vector< std::array< Real, 2 >> const &observations, std::vector< int > const &indices)
GLubyte GLubyte GLubyte GLubyte w
GLsizei GLenum const void * indices
ApprPolynomial2(int degree)
int GetMinimumRequired() const
std::array< Real, 2 > mXDomain
Quaternion< Real > Inverse(Quaternion< Real > const &d)
Real Error(std::array< Real, 2 > const &observation) const