# NMF Class Reference

Algorithm to calculate the Non-negative Matrix Factorization of a matrix of Real values. More...

#include <NMF.h>

List of all members.

## Public Member Functions

NMF (int inputSize=1024, int componentCount=3, int iterationCount=10, Real epsilon=1e-9)
~NMF ()
void process (const MatrixXR &frames, MatrixXR *gains, MatrixXR *components)
int inputSize () const
void setInputSize (int size, bool callSetup=true)
int componentCount () const
void setComponentCount (int count, bool callSetup=true)
int iterationCount () const
void setIterationCount (int count, bool callSetup=true)
Real epsilon () const
void setEpsilon (Real epsilon, bool callSetup=true)

## Detailed Description

Algorithm to calculate the Non-negative Matrix Factorization of a matrix of Real values.

This class represents an object to perform a Non-negative Matrix Factorization (NMF) on a matrix of Real values. Which is a useful technique for decomposing multichannel signals into linear independent components and their respective positive gains.

The algorithm estimates a set of M temporal independent components, each of which is represented as a single row in a matrix of the same number of columns as the input matrix. The algorithm also estimates a set of M time-varying positive gains, each of which is represented as a single column in a matrix with as many rows as the input matrix.

In order to implement the NMF an iterative multiplicative update rule is applied in order to minimize the distance from the multiplication of the gains and components matrices to the input matrix.

The distance minimized in this implementation is the Kullback-Liebler divergence.

INMF, ICA

## Constructor & Destructor Documentation

 NMF ( int inputSize = 1024, int componentCount = 3, int iterationCount = 10, Real epsilon = 1e-9 )

Constructs an NMF object with the specified inputSize, componentCount, iterationCount and epsilon settings.

Parameters:
 inputSize size of the inputs arrays, must be > 0. componentCount number of linearly independnet components to be estimated. iterationCount number of update iterations performed to solve the NMF. epsilon parameter of the solver to clip the minimum values at each update.

References setComponentCount(), setEpsilon(), setInputSize(), and setIterationCount().

 ~NMF ( )

Destroys the algorithm and frees its resources.

## Member Function Documentation

 void process ( const MatrixXR & frames, MatrixXR * gains, MatrixXR * components )

Performs an NMF on frames which represents multichannel signal where the rows are the time axis and the columns are the channels. Puts the resulting NMF components in the rows of components and the instantaneous gains of each components in gains.

Parameters:
 frames matrix of Real values. The number of columns of frames must be equal to the input size specified using setInputSize(). components pointer to a matrix of Real values for the components. The matrix should have the same number of rows as componentCount and inputSize columns. gains pointer to a matrix of Real positive values for the instantaneous gains of each component. The matrix should have the same number of rows as frames and componentCount columns.
Note that if the output matrices are not of the required sizes they will be resized, reallocating a new memory space if necessary.

 int inputSize ( ) const

Returns the size of the input arrays. The default is 1024.

setInputSize()

 void setInputSize ( int size, bool callSetup = true )

Specifies the size of the input. The given size must be higher than 0.

inputSize()

Referenced by NMF().

 int componentCount ( ) const

Returns the number of components to be calculated. The default is 3.

setComponentCount()

 void setComponentCount ( int count, bool callSetup = true )

Specifies the count of components to be calculated. The given count must be greater than 0.

componentCount()

Referenced by NMF().

 int iterationCount ( ) const

Returns the number of iterations of the solver. The default is 10.

setIterationCount()

 void setIterationCount ( int count, bool callSetup = true )

Specifies the count of iterations of the solver. The given count must be greater than 0.

iterationCount()

Referenced by NMF().

 Real epsilon ( ) const

Returns the epsilon. The default is 1e-6.

setEpsilon()

 void setEpsilon ( Real epsilon, bool callSetup = true )

Specifies the epsilon for the NMF solving update rule.