forked from devray/mbICA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added doxygen comments to icaseparator.h and nonlnearities.h.
- Loading branch information
Showing
2 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,63 @@ | ||
/** | ||
* @file | ||
* @author Pawel Zubrycki <[email protected]> | ||
* @author Stanisław Janikowski <[email protected]> | ||
* | ||
* @section DESCRIPTION | ||
* | ||
* Class that provides easy way to count independent components. | ||
**/ | ||
|
||
#ifndef ICASEPARATOR_H | ||
#define ICASEPARATOR_H | ||
|
||
#include <armadillo> | ||
|
||
namespace mbica { | ||
/** | ||
* Class that provides easy way to count independent components. | ||
**/ | ||
class ICASeparator | ||
{ | ||
public: | ||
/** | ||
* Constructor. | ||
* | ||
* @param A Mixing matrix. | ||
* @param W Unmixing matrix. | ||
**/ | ||
ICASeparator(arma::mat A, arma::mat W) | ||
: A_(A), W_(W) {A.save("A.mat", arma::arma_ascii); W.save("W.mat", arma::arma_ascii);} | ||
: A_(A), W_(W) { | ||
A.save("A.mat", arma::arma_ascii); | ||
W.save("W.mat", arma::arma_ascii); | ||
} | ||
|
||
/** | ||
* Method that unmix given signal. | ||
* | ||
* @param X Matrix with mixed signal. | ||
* @return Matrix with unmixed signal. | ||
**/ | ||
arma::mat operator()(arma::mat X) { | ||
return W_ * X; | ||
} | ||
|
||
arma::mat operator()(arma::mat X); | ||
/** | ||
* Method that mixes given signals | ||
* | ||
* @param S Matrix to be mixed. | ||
* @return Matrix with mixed data. | ||
*/ | ||
arma::mat mixSignals(arma::mat S) { | ||
return A_ * S; | ||
} | ||
|
||
/// Getter of mixing matrix. | ||
const arma::mat &getA() const { | ||
return A_; | ||
} | ||
|
||
/// Getter of unmixing matrix. | ||
const arma::mat &getW() const { | ||
return W_; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
/** | ||
* @file | ||
* @author Pawel Zubrycki <[email protected]> | ||
* @author Stanisław Janikowski <[email protected]> | ||
* | ||
* @section DESCRIPTION | ||
* | ||
* File with preimplemented nonlinearities used in FastICA algorithm. | ||
* | ||
* @note New nonlinearites don't have to inherit from Nonlinearity class. | ||
* They just have to provide G() and dG() methods. | ||
**/ | ||
|
||
#ifndef NONLINEARITIES_H | ||
#define NONLINEARITIES_H | ||
|
||
|
@@ -6,19 +19,30 @@ | |
namespace mbica { | ||
namespace nonlinearities { | ||
|
||
/** | ||
* Base class for preimplemented nonlinearities. | ||
*/ | ||
class Nonlinearity { | ||
public: | ||
/// Method returning value of function. | ||
arma::mat G() { return g_; } | ||
/// Method returning value of derivative of function. | ||
arma::mat dG() { return dg_; } | ||
|
||
protected: | ||
/// Protected constructor to prevent from creating Nonlinearity objects. | ||
Nonlinearity(){} | ||
|
||
protected: | ||
arma::mat g_; | ||
arma::mat dg_; | ||
}; | ||
|
||
/** | ||
* Class implementing power function on matrix elements. | ||
* | ||
* @param a Exponent. | ||
**/ | ||
template<int a=3> | ||
class Pow: public Nonlinearity{ | ||
public: | ||
|
@@ -28,6 +52,15 @@ class Pow: public Nonlinearity{ | |
} | ||
}; | ||
|
||
|
||
/** | ||
* Class implementing tanh nonlinearity. | ||
* | ||
* @note Class uses fraction a/b as a parameter. | ||
* | ||
* @param a Numerator of parameter. | ||
* @param b Denominator of parameter. | ||
**/ | ||
template<int a=1, int b=1> | ||
class TanH: public Nonlinearity{ | ||
public: | ||
|
@@ -38,6 +71,14 @@ class TanH: public Nonlinearity{ | |
} | ||
}; | ||
|
||
/** | ||
* Class implementing gauss nonlinearity. | ||
* | ||
* @note Class uses fraction a/b as a parameter. | ||
* | ||
* @param a Numerator of parameter. | ||
* @param b Denominator of parameter. | ||
**/ | ||
template<int a=1, int b=1> | ||
class Gauss: public Nonlinearity{ | ||
public: | ||
|
@@ -49,6 +90,7 @@ class Gauss: public Nonlinearity{ | |
} | ||
}; | ||
|
||
/// Typedef to provide compatibility with Octave packet. | ||
typedef Pow<2> Skew; | ||
} | ||
} | ||
|