18 #ifndef itkMultivariateLegendrePolynomial_h
19 #define itkMultivariateLegendrePolynomial_h
25 #include "ITKPolynomialsExport.h"
105 {
return m_Dimension; }
118 {
return m_NumberOfCoefficients; }
122 {
return m_DomainSize; }
133 m_Required = required;
156 if ( m_Dimension == 2 )
158 if ( index[1] != m_PrevY )
161 double norm_y = m_NormFactor[1]
162 *
static_cast< double >( index[1] - 1 );
163 this->CalculateXCoef(norm_y, m_CoefficientArray);
169 double norm_x = m_NormFactor[0]
170 *
static_cast< double >( index[0] - 1 );
172 return LegendreSum(norm_x, m_Degree, m_CachedXCoef);
174 else if ( m_Dimension == 3 )
176 if ( index[2] != m_PrevZ )
179 double norm_z = m_NormFactor[2]
180 *
static_cast< double >( index[2] - 1 );
181 this->CalculateYCoef(norm_z, m_CoefficientArray);
185 if ( index[1] != m_PrevY )
188 double norm_y = m_NormFactor[1]
189 *
static_cast< double >( index[1] - 1 );
190 this->CalculateXCoef(norm_y, m_CachedYCoef);
195 double norm_x = m_NormFactor[0]
196 *
static_cast< double >( index[0] - 1 );
197 return this->LegendreSum(norm_x, m_Degree, m_CachedXCoef);
203 unsigned int GetNumberOfCoefficients();
206 unsigned int GetNumberOfCoefficients(
unsigned int dimension,
unsigned int degree);
218 m_MultivariateLegendrePolynomial(polynomial),
219 m_Dimension (m_MultivariateLegendrePolynomial->GetDimension()),
220 m_DomainSize (m_MultivariateLegendrePolynomial->GetDomainSize()),
223 m_Index.resize(m_Dimension);
224 std::fill(m_Index.begin(), m_Index.end(), 0);
230 for (
unsigned int dim = 0; dim < m_Dimension; dim++ )
237 {
return m_IsAtEnd; }
241 for (
unsigned int dim = 0; dim < m_Dimension; dim++ )
243 if ( m_Index[dim] < static_cast< int >( m_DomainSize[dim] - 1 ) )
250 if ( dim == m_Dimension - 1 )
265 {
return m_MultivariateLegendrePolynomial->Evaluate(m_Index); }
275 void Print(std::ostream & os);
278 void PrintSelf(std::ostream & os,
Indent indent)
const;
280 double LegendreSum(
const double x,
int n,
304 ITKPolynomials_EXPORT std::ostream &
operator<<(std::ostream & os,
unsigned int GetDimension() const
DomainSizeType m_DomainSize
MultivariateLegendrePolynomial * m_MultivariateLegendrePolynomial
DomainSizeType m_DomainSize
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
double Evaluate(IndexType &index)
std::vector< double > DoubleArrayType
CoefficientArrayType m_CachedYCoef
CoefficientArrayType m_CachedZCoef
SimpleForwardIterator(MultivariateLegendrePolynomial *polynomial)
std::vector< unsigned long > ULongArrayType
const DomainSizeType & GetDomainSize() const
signed long IndexValueType
2D and 3D multivariate Legendre Polynomial
CoefficientArrayType m_CoefficientArray
DoubleArrayType m_NormFactor
unsigned int GetDegree() const
std::vector< long > LongArrayType
unsigned int m_NumberOfCoefficients
CoefficientArrayType m_CachedXCoef
SimpleForwardIterator & operator++()
Control indentation during Print() invocation.
ULongArrayType DomainSizeType
DoubleArrayType CoefficientArrayType
unsigned int GetNumberOfCoefficients() const
Iterator which only supports forward iteration and Begin(), IsAtEnd(), and Get() method which work ju...
CoefficientVectorSizeMismatch(int given, int required)