/usr/include/itpp/signal/fastica.h is in libitpp-dev 4.3.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | /*!
* \file
* \brief Definition of FastICA (Independent Component Analysis) for IT++
* \author Francois Cayre and Teddy Furon
*
* -------------------------------------------------------------------------
*
* Copyright (C) 1995-2010 (see AUTHORS file for a list of contributors)
*
* This file is part of IT++ - a C++ library of mathematical, signal
* processing, speech processing, and communications classes and functions.
*
* IT++ is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* IT++ is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with IT++. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*
* This is IT++ implementation of the original Matlab package FastICA.
*
* This code is Copyright (C) 2004 by:
* Francois CAYRE and Teddy FURON
* TEMICS Project
* INRIA/Rennes (IRISA)
* Campus Universitaire de Beaulieu
* 35042 RENNES cedex FRANCE
*
* Email: firstname.lastname@irisa.fr
*
* Matlab package is Copyright (C) 1998 by:
* Jarmo HURRI, Hugo GAVERT, Jaakko SARELA and Aapo HYVARINEN
* Laboratory of Information and Computer Science
* Helsinki University of Technology
*
* URL: http://www.cis.hut.fi/projects/ica/fastica/about.shtml
*
* If you use results given by this FastICA software in an article for
* a scientific journal, conference proceedings or similar, please
* include the following original reference in the bibliography:
*
* A. Hyvarinen, Fast and Robust Fixed-Point Algorithms for
* Independent Component Analysis, IEEE Transactions on Neural
* Networks 10(3):626-634, 1999
*
* Differences with the original Matlab implementation:
* - no GUI
* - return something even in the case of a convergence problem
* - optimization of SVD decomposition (performed 2 times in Matlab,
* only 1 time in IT++)
* - default approach is SYMM with non-linearity POW3
*/
#ifndef FASTICA_H
#define FASTICA_H
#include <itpp/base/mat.h>
#include <itpp/itexports.h>
//! Use deflation approach : compute IC one-by-one in a Gram-Schmidt-like fashion
#define FICA_APPROACH_DEFL 2
//! Use symmetric approach : compute all ICs at a time
#define FICA_APPROACH_SYMM 1
//! Use x^3 non-linearity
#define FICA_NONLIN_POW3 10
//! Use tanh(x) non-linearity
#define FICA_NONLIN_TANH 20
//! Use Gaussian non-linearity
#define FICA_NONLIN_GAUSS 30
//! Use skew non-linearity
#define FICA_NONLIN_SKEW 40
//! Set random start for Fast_ICA
#define FICA_INIT_RAND 0
//! Set predefined start for Fast_ICA
#define FICA_INIT_GUESS 1
//! Eigenvalues of the covariance matrix lower than FICA_TOL are discarded for analysis
#define FICA_TOL 1e-9
namespace itpp
{
/*!
\addtogroup fastica
*/
//---------------------- FastICA --------------------------------------
/*!
\brief Fast_ICA Fast Independent Component Analysis (Fast ICA)
\ingroup fastica
The software is based upon original FastICA for Matlab from
A. Hyvarinen. Fast and Robust Fixed-Point Algorithms for
Independent Component Analysis. IEEE Transactions on Neural
Networks, 10(3), pp. 626-634, 1999.
Example:
\code
FastICA fastica(sources);
fastica.set_nrof_independent_components(sources.rows());
fastica.set_non_linearity( FICA_NONLIN_TANH );
fastica.set_approach( FICA_APPROACH_DEFL );
fastica.separate();
mat ICs = fastica.get_independent_components();
\endcode
*/
class ITPP_EXPORT Fast_ICA
{
public:
/*!
\brief Constructor
Construct a Fast_ICA object with mixed signals to separate.
\param ma_mixed_sig (Input) Mixed signals to separate
*/
Fast_ICA(mat ma_mixed_sig);
/*!
\brief Explicit launch of main FastICA function
Explicit launch of the Fast_ICA algorithm.
\returns true if algorithm converged and false otherwise
*/
bool separate(void);
/*!
\brief Set approach : FICA_APPROACH_DEFL or FICA_APPROACH_SYMM (default)
Set approach to use : FICA_APPROACH_SYMM (symmetric) or FICA_APPROACH_DEFL (deflation). The symmetric approach computes all ICs at a time, whereas the deflation approach computes them one by one.
\param in_approach (Input) Type of approach to use
*/
void set_approach(int in_approach);
/*!
\brief Set number of independent components to separate
Set the number of ICs to compute.
\param in_nrIC (Input) Number of ICs to compute
*/
void set_nrof_independent_components(int in_nrIC);
/*!
\brief Set non-linearity
Set non-linearity to use : FICA_NONLIN_POW3 (default), FICA_NONLIN_TANH, FICA_NONLIN_GAUSS, FICA_NONLIN_SKEW
\param in_g (Input) Non-linearity. Can be selected from FICA_NONLIN_POW3, FICA_NONLIN_TANH, FICA_NONLIN_GAUSS or FICA_NONLIN_SKEW
*/
void set_non_linearity(int in_g);
/*!
\brief Set fine tuning
Set fine tuning true or false.
\param in_finetune (Input) Boolean (true or false)
*/
void set_fine_tune(bool in_finetune);
/*!
\brief Set \f$a_1\f$ parameter
Set internal parameter \f$a_1\f$ of Fast_ICA (See reference paper).
\param fl_a1 (Input) Parameter \f$a_1\f$ from reference paper
*/
void set_a1(double fl_a1);
/*!
\brief Set \f$a_2\f$ parameter
Set internal parameter \f$a_2\f$ of Fast_ICA (See reference paper).
\param fl_a2 (Input) Parameter \f$a_2\f$ from reference paper
*/
void set_a2(double fl_a2);
/*!
\brief Set \f$\mu\f$ parameter
Set internal parameter \f$\mu\f$ of Fast_ICA (See reference paper).
\param fl_mu (Input) Parameter \f$\mu\f$ from reference paper
*/
void set_mu(double fl_mu);
/*!
\brief Set convergence parameter \f$\epsilon\f$
Set \f$\epsilon\f$ parameter for convergence precision.
\param fl_epsilon (Input) \f$\epsilon\f$ is convergence precision
*/
void set_epsilon(double fl_epsilon);
/*!
\brief Set sample size
Set the percentage of samples to take into account at every iteration.
\param fl_sampleSize (Input) Percentage of data to take into account at every iteration
*/
void set_sample_size(double fl_sampleSize);
/*!
\brief Set stabilization mode true or off
Set stabilization mode.
\param in_stabilization (Input) Set stabilization true or false
*/
void set_stabilization(bool in_stabilization);
/*!
\brief Set maximum number of iterations
Set maximum number of iterations for Fast_ICA.
\param in_maxNumIterations (Input) Maximum number of iterations to go through
*/
void set_max_num_iterations(int in_maxNumIterations);
/*!
\brief Set maximum number of iterations for fine tuning
Set maximum numberr of iterations for fine tuning.
\param in_maxFineTune (Input) Maximum number of iterations for fine tuning stage
*/
void set_max_fine_tune(int in_maxFineTune);
/*!
\brief Set first eigenvalue index to take into account
Set first eigenvalue index to take into account.
\param in_firstEig (Input) First eigenvalue index to take into account
*/
void set_first_eig(int in_firstEig);
/*!
\brief Set last eigenvalue index to take into account
Set last eigenvalue index to take into account.
\param in_lastEig (Input) Last eigenvalue index to take into account
*/
void set_last_eig(int in_lastEig);
/*!
\brief If true, only perform Principal Component Analysis (default = false)
Wether to perform PCA only or PCA+ICA.
\param in_PCAonly (Input) True = PCA only, false = PCA+ICA (default)
*/
void set_pca_only(bool in_PCAonly);
/*!
\brief Set initial guess matrix instead of random (default)
Set initial matrix instead of random matrix.
\param ma_initGuess (Input) Initial guess matrix
*/
void set_init_guess(mat ma_initGuess);
/*!
\brief Get mixing matrix
Return mixing matrix.
\return Mixing matrix
*/
mat get_mixing_matrix();
/*!
\brief Get separating matrix
Return separating matrix.
\return Separating matrix
*/
mat get_separating_matrix();
/*!
\brief Get separated signals
Return separated signals (Independent Components).
\return ICs
*/
mat get_independent_components();
/*!
\brief Get number of independent components
Return number of ICs.
\return Number of ICs
*/
int get_nrof_independent_components();
/*!
\brief Get nrIC first columns of the de-whitening matrix
Return principal eigenvectors.
\return Principal eigenvectors
*/
mat get_principal_eigenvectors();
/*!
\brief Get the whitening matrix
Return whitening matrix.
\return Whitening matrix
*/
mat get_whitening_matrix();
/*!
\brief Get the de-whitening matrix
Return dewhitening matrix.
\return Dewhitening matrix
*/
mat get_dewhitening_matrix();
/*!
\brief Get whitened signals
Return whitened signals.
\return Whitened signals
*/
mat get_white_sig();
private:
int approach, numOfIC, g, initState;
bool finetune, stabilization, PCAonly;
double a1, a2, mu, epsilon, sampleSize;
int maxNumIterations, maxFineTune;
int firstEig, lastEig;
mat initGuess;
mat mixedSig, A, W, icasig;
mat whiteningMatrix;
mat dewhiteningMatrix;
mat whitesig;
mat E, VecPr;
vec D;
}; // class Fast_ICA
} // namespace itpp
#endif // #ifndef FASTICA_H
|