21 #ifndef otbTimeSeriesLSFF_h
22 #define otbTimeSeriesLSFF_h
24 #include "vnl/algo/vnl_matrix_inverse.h"
25 #include "vnl/vnl_transpose.h"
26 #include "vnl/vnl_matrix.h"
58 template <
class TSeriesType,
class TTimeFunction,
class TDateType = TSeriesType,
class TWeightType = TSeriesType>
78 TSeriesType outSeries;
79 for (
unsigned int i = 0; i <
m_DoySeries.Size(); ++i)
80 outSeries[i] = estFunction.GetValue(
m_DoySeries[i]);
86 for (
unsigned int i = 0; i <
doy.Size(); ++i)
92 for (
unsigned int i = 0; i < weights.Size(); ++i)
103 TTimeFunction estFunction;
105 unsigned int nbCoefs = estFunction.GetCoefficients().Size();
108 vnl_matrix<double> A(nbDates, nbCoefs);
109 vnl_matrix<double> b(nbDates, 1);
113 typename TTimeFunction::CoefficientsType tmpCoefs;
114 for (
unsigned int j = 0; j < nbCoefs; ++j)
117 for (
unsigned int i = 0; i < nbDates; ++i)
120 for (
unsigned int j = 0; j < nbCoefs; ++j)
123 estFunction.SetCoefficients(tmpCoefs);
130 vnl_matrix<double> atainv = vnl_matrix_inverse<double>(vnl_transpose(A) * A);
132 vnl_matrix<double> atainvat = atainv * vnl_transpose(A);
133 vnl_matrix<double> c = atainvat * b;
135 for (
unsigned int j = 0; j < nbCoefs; ++j)
136 tmpCoefs[j] = c.get(j, 0);
137 estFunction.SetCoefficients(tmpCoefs);