15 const std::vector<double> & y,
const std::vector<double> & w,
16 const double lambda,
const unsigned int s
20 throw std::invalid_argument(
"Whittaker(): length of y is zero.");
23 if(y.size() != w.size()) {
24 throw std::invalid_argument(
"Whittaker(): the sizes of y and w do not match.");
28 throw std::invalid_argument(
"Whittaker(): non-positive lambda value is given.");
32 throw std::invalid_argument(
"Whittaker(): s must be 1, 2, or 3.");
35 Eigen::VectorXd yy = Eigen::VectorXd::Map(y.data(), y.size());
36 Eigen::VectorXd ww = Eigen::VectorXd::Map(w.data(), w.size());
38 Eigen::SparseMatrix<double> I, D, lambdaDTD;
45 lambdaDTD = lambda * (D.transpose() * D);
49 std::vector<double> result(z.size());
50 Eigen::VectorXd::Map(result.data(), result.size()) = z;
const Derived::PlainObject Diff(const Eigen::MatrixBase< Derived > &m0, const int n=1, const Dir dir=Dir::RowWise)
Calculates the n-th discrete difference along the given axis.
const std::vector< double > Whittaker(const std::vector< double > &y, const std::vector< double > &w, const double lambda, const unsigned int s)
Performs Whittaker smoothing (std::vector<double> version, with weights).