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 double norm_y = m_NormFactor[1] * static_cast<double>(index[1] - 1);
178 this->CalculateXCoef(norm_y, m_CoefficientArray);
184 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 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 double norm_y = m_NormFactor[1] * static_cast<double>(index[1] - 1);
202 this->CalculateXCoef(norm_y, m_CachedYCoef);
207 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);
242 for (
unsigned int dim = 0; dim < m_Dimension; ++dim)
257 for (
unsigned int dim = 0; dim < m_Dimension; ++dim)
259 if (m_Index[dim] < static_cast<int>(m_DomainSize[dim] - 1))
266 if (dim == m_Dimension - 1)
283 return m_MultivariateLegendrePolynomial->Evaluate(m_Index);
295 Print(std::ostream & os)
const;
299 PrintSelf(std::ostream & os,
Indent indent)
const;
312 unsigned int m_Dimension{};
313 unsigned int m_Degree{};
314 unsigned int m_NumberOfCoefficients{};
326 ITKPolynomials_EXPORT std::ostream &
327 operator<<(std::ostream & os,
const MultivariateLegendrePolynomial & poly);