Vespucci  1.0.0
whittaker.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
22 
31 arma::vec Vespucci::Math::Smoothing::WhittakerSmooth(const arma::vec &x, double lambda, arma::uword penalty_order)
32 {
33 
34  arma::uword m = x.n_elem;
35  arma::mat E = arma::eye(m, m);
36  arma::mat D = Vespucci::Math::diff(E, penalty_order);
37  arma::vec filtered = solve(E + lambda*D.t()*D, x);
38 
39  //This is a version that would work if chol() could take a sparse input.
40  /*
41  arma::uword m = x.n_elem;
42  arma::sp_mat E = speye(m, m);
43  arma::sp_mat D = Vespucci::Math::diff(E, penalty_order);
44  arma::sp_mat F = E + lambda*D.t()*D;
45  arma::mat C = chol(F);
46  arma::vec z = solve(C, solve(C, x));
47  */
48  return filtered;
49 }
VESPUCCI_EXPORT arma::vec WhittakerSmooth(const arma::vec &x, double lambda, arma::uword penalty_order)
Vespucci::Math::WhittakerSmooth.
Definition: whittaker.cpp:31
T diff(const T &X, arma::uword deriv_order=1)
Vespucci::Math::diff.