18#ifndef itkMultivariateLegendrePolynomial_h
19#define itkMultivariateLegendrePolynomial_h
25#include "ITKPolynomialsExport.h"
126 return m_NumberOfCoefficients;
130 const DomainSizeType &
145 : m_Required{ required }
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);
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);
312 unsigned int m_Dimension{};
313 unsigned int m_Degree{};
314 unsigned int m_NumberOfCoefficients{};
326ITKPolynomials_EXPORT std::ostream &
Control indentation during Print() invocation.
CoefficientVectorSizeMismatch(const vcl_size_t given, const vcl_size_t required)
Iterator which only supports forward iteration and Begin(), IsAtEnd(), and Get() method which work ju...
SimpleForwardIterator & operator++()
SimpleForwardIterator(MultivariateLegendrePolynomial *polynomial)
MultivariateLegendrePolynomial * m_MultivariateLegendrePolynomial
DomainSizeType m_DomainSize
2D and 3D multivariate Legendre Polynomial
void Print(std::ostream &os) const
ULongArrayType DomainSizeType
void SetCoefficients(const ParametersType &coefficients)
const CoefficientArrayType & GetCoefficients() const
Gets Legendre polynomials' coefficients.
void CalculateXCoef(double norm_y, const CoefficientArrayType &coef)
void PrintSelf(std::ostream &os, Indent indent) const
unsigned int GetNumberOfCoefficients(unsigned int dimension, unsigned int degree)
unsigned int GetDimension() const
void CalculateYCoef(double norm_z, const CoefficientArrayType &coef)
virtual ~MultivariateLegendrePolynomial()
unsigned int GetNumberOfCoefficients() const
unsigned int GetDegree() const
double Evaluate(IndexType &index)
DoubleArrayType CoefficientArrayType
const DomainSizeType & GetDomainSize() const
void SetCoefficients(const CoefficientArrayType &coefficients)
Sets the Legendre polynomials' parameters.
MultivariateLegendrePolynomial(unsigned int dimension, unsigned int degree, const DomainSizeType &domainSize)
std::vector< long > LongArrayType
double LegendreSum(const double x, int n, const CoefficientArrayType &coef, int offset=0)
std::vector< double > DoubleArrayType
std::vector< unsigned long > ULongArrayType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)