Vespucci  1.0.0
denoise.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 *******************************************************************************/
20 #include "Math/Smoothing/denoise.h"
21 #include "mlpack/methods/quic_svd/quic_svd.hpp"
22 arma::mat Vespucci::Math::Smoothing::SVDDenoise(const arma::mat &X, arma::uword k, arma::mat &U, arma::vec &s, arma::mat &V)
23 {
24  arma::svds(U, s, V, arma::sp_mat(X), k);
25  return -1 * U * diagmat(s) * V.t();
26 }
27 
28 arma::mat Vespucci::Math::Smoothing::QUICSVDDenoise(const arma::mat &X, double epsilon, arma::mat &U, arma::vec &s, arma::mat &V, arma::uword &rank)
29 {
30  arma::mat s_mat;
31  mlpack::svd::QUIC_SVD(X, U, V, s_mat, epsilon, 0.1);
32  rank = U.n_cols;
33  s = s_mat.diag(0);
34  return U * s_mat * V.t();
35 }
VESPUCCI_EXPORT bool svds(const arma::mat &X, arma::uword k, arma::mat &U, arma::vec &s, arma::mat &V)
Vespucci::Math::DimensionReduction::svds Finds a few largest singular values of the arma::matrix X...
Definition: svds.cpp:24
VESPUCCI_EXPORT arma::mat QUICSVDDenoise(const arma::mat &X, double epsilon, arma::mat &U, arma::vec &s, arma::mat &V, arma::uword &rank)
Definition: denoise.cpp:28
VESPUCCI_EXPORT arma::mat SVDDenoise(const arma::mat &X, arma::uword k, arma::mat &U, arma::vec &s, arma::mat &V)
Definition: denoise.cpp:22