46 template <
typename Real>
49 public ApprQuery<Real, ApprPolynomial4<Real>, std::array<Real, 4>>
60 bool Fit(std::vector<std::array<Real, 4>>
const& observations,
61 std::vector<int>
const&
indices);
66 Real
Error(std::array<Real, 4>
const& observation)
const;
92 template <
typename Real>
106 mXDomain[0] = std::numeric_limits<Real>::max();
108 mYDomain[0] = std::numeric_limits<Real>::max();
110 mZDomain[0] = std::numeric_limits<Real>::max();
117 template <
typename Real>
123 template <
typename Real>
125 std::vector<std::array<Real, 4>>
const& observations,
126 std::vector<int>
const&
indices)
128 if (indices.size() > 0)
130 int s, i0, j0, k0, n0, i1, j1, k1, n1;
133 int numSamples =
static_cast<int>(indices.size());
140 for (s = 0; s < numSamples; ++
s)
142 Real
x = observations[indices[
s]][0];
143 Real
y = observations[indices[
s]][1];
144 Real
z = observations[indices[
s]][2];
152 xPower[
s][0] = (Real)1;
153 for (i0 = 1; i0 <= twoXDegree; ++i0)
155 xPower[
s][i0] = x * xPower[
s][i0 - 1];
158 yPower[
s][0] = (Real)1;
159 for (j0 = 1; j0 <= twoYDegree; ++j0)
161 yPower[
s][j0] = y * yPower[
s][j0 - 1];
164 zPower[
s][0] = (Real)1;
165 for (k0 = 1; k0 <= twoZDegree; ++k0)
167 zPower[
s][k0] = z * zPower[
s][k0 - 1];
183 for (s = 0; s < numSamples; ++
s)
185 Real
w = observations[indices[
s]][3];
186 sum += w * xPower[
s][i0] * yPower[
s][j0] *
200 for (s = 0; s < numSamples; ++
s)
202 sum += xPower[
s][i0 + i1] *
217 bool hasNonzero =
false;
218 for (
int i = 0; i <
mSize; ++i)
221 if (coefficients[i] != (Real)0)
233 template <
typename Real>
237 Real
w =
Evaluate(observation[0], observation[1], observation[2]);
238 Real error =
std::abs(w - observation[3]);
242 template <
typename Real>
248 template <
typename Real>
254 template <
typename Real>
260 template <
typename Real>
266 template <
typename Real>
std::array< Real, 2 > mZDomain
std::vector< Real > mParameters
Real Evaluate(Real x, Real y, Real z) const
bool Fit(std::vector< std::array< Real, 4 >> const &observations, std::vector< int > const &indices)
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
std::array< Real, 2 > const & GetZDomain() const
ApprPolynomial4(int xDegree, int yDegree, int zDegree)
std::vector< Real > const & GetParameters() const
int GetMinimumRequired() const
Real Error(std::array< Real, 4 > const &observation) const
GLubyte GLubyte GLubyte GLubyte w
std::array< Real, 2 > const & GetYDomain() const
GLsizei GLenum const void * indices
GLdouble GLdouble GLdouble z
std::vector< Real > mYZCoefficient
Quaternion< Real > Inverse(Quaternion< Real > const &d)
std::array< Real, 2 > mXDomain
std::vector< Real > mZCoefficient
std::array< Real, 2 > mYDomain
std::array< Real, 2 > const & GetXDomain() const