18 #ifndef itkMultivariateLegendrePolynomial_h
19 #define itkMultivariateLegendrePolynomial_h
25 #include "ITKPolynomialsExport.h"
126 return m_NumberOfCoefficients;
130 const DomainSizeType &
145 : m_Required{ required }
165 GetCoefficients()
const;
172 if (m_Dimension == 2)
174 if (index[1] != m_PrevY)
177 const double norm_y = m_NormFactor[1] * static_cast<double>(index[1] - 1);
178 this->CalculateXCoef(norm_y, m_CoefficientArray);
184 const double norm_x = m_NormFactor[0] * static_cast<double>(index[0] - 1);
186 return LegendreSum(norm_x, m_Degree, m_CachedXCoef);
188 else if (m_Dimension == 3)
190 if (index[2] != m_PrevZ)
193 const double norm_z = m_NormFactor[2] * static_cast<double>(index[2] - 1);
194 this->CalculateYCoef(norm_z, m_CoefficientArray);
198 if (index[1] != m_PrevY)
201 const double norm_y = m_NormFactor[1] * static_cast<double>(index[1] - 1);
202 this->CalculateXCoef(norm_y, m_CachedYCoef);
207 const double norm_x = m_NormFactor[0] * static_cast<double>(index[0] - 1);
208 return this->LegendreSum(norm_x, m_Degree, m_CachedXCoef);
215 GetNumberOfCoefficients(
unsigned int dimension,
unsigned int degree);
228 : m_MultivariateLegendrePolynomial(polynomial)
229 , m_Dimension(m_MultivariateLegendrePolynomial->GetDimension())
230 , m_DomainSize(m_MultivariateLegendrePolynomial->GetDomainSize())
233 m_Index.resize(m_Dimension);
234 std::fill(m_Index.begin(), m_Index.end(), 0);
241 for (
unsigned int dim = 0; dim < m_Dimension; ++dim)
256 for (
unsigned int dim = 0; dim < m_Dimension; ++dim)
258 if (m_Index[dim] < static_cast<int>(m_DomainSize[dim] - 1))
265 if (dim == m_Dimension - 1)
282 return m_MultivariateLegendrePolynomial->Evaluate(m_Index);
290 bool m_IsAtEnd{
false };
294 Print(std::ostream & os)
const;
298 PrintSelf(std::ostream & os,
Indent indent)
const;
301 LegendreSum(
const double x,
int n,
const CoefficientArrayType & coef,
int offset = 0);
304 CalculateXCoef(
double norm_y,
const CoefficientArrayType & coef);
307 CalculateYCoef(
double norm_z,
const CoefficientArrayType & coef);
311 unsigned int m_Dimension{};
312 unsigned int m_Degree{};
313 unsigned int m_NumberOfCoefficients{};
325 ITKPolynomials_EXPORT std::ostream &
326 operator<<(std::ostream & os,
const MultivariateLegendrePolynomial & poly);