NnmfPack  2.1
Functions
mlsa_cpu.h File Reference

File with functions to calcule NNMF using the mlsa algorithm for CPUs. More...

Go to the source code of this file.

Functions

int dmlsa_cpu (const int m, const int n, const int k, const double *A, double *W, double *H, const int uType, const int nIter)
 dmlsa_cpu performs NNMF using betadivergence when beta=2 using double precision More...
 
int smlsa_cpu (const int m, const int n, const int k, const float *A, float *W, float *H, const int uType, const int nIter)
 smlsa_cpu performs NNMF using betadivergence when beta=2 using simple precision More...
 
void ddotdiv_x86 (const int n, const double *x, const double *y, double *__restrict__ z)
 This function calls the appropiate funtions to performs double precision element-wise z[i]=z[i]*x[i]/y[i] for all positions of x, y and z. More...
 
void sdotdiv_x86 (const int n, const float *x, const float *y, float *__restrict__ z)
 This function calls the appropiate funtions to performs simple precision element-wise z[i]=z[i]*x[i]/y[i] for all positions of x, y and z. More...
 

Detailed Description

File with functions to calcule NNMF using the mlsa algorithm for CPUs.

Header file for using the mlsa algorithm with CPU.

Author
Information Retrieval and Parallel Computing Group (IRPCG)
University of Oviedo, Spain
Interdisciplinary Computation and Communication Group (INCO2)
Universitat Politecnica de Valencia, Spain.
Contact: nnmfp.nosp@m.ack@.nosp@m.gmail.nosp@m..com
Date
12/03/18

Definition in file mlsa_cpu.h.

Function Documentation

◆ ddotdiv_x86()

void ddotdiv_x86 ( const int  n,
const double *  x,
const double *  y,
double *__restrict__  z 
)

This function calls the appropiate funtions to performs double precision element-wise z[i]=z[i]*x[i]/y[i] for all positions of x, y and z.

Parameters
n(input) Number of elements of x, y and z
x(input) Double precision input vector/matrix (1D column-major)
y(input) Double precision input vector/matrix (1D column-major)
z(inout) Double precision input/output vector/matrix (1D column-major)

Definition at line 471 of file mlsa_cpu.c.

◆ dmlsa_cpu()

int dmlsa_cpu ( const int  m,
const int  n,
const int  k,
const double *  A,
double *  W,
double *  H,
const int  uType,
const int  nIter 
)

dmlsa_cpu performs NNMF using betadivergence when beta=2 using double precision

The algorithm is
  repit nIter times
    STEP 1
      L=W*H
      B=W'A
      C=W'*L
      H=H(.
)B(./)C

    STEP 2
      L=W*H
      D=A*H'
      E=L*H'
      W=W(.*)D(./)E
    end repit
End algorithm

To save some FLOPs and RAM a modified Lee and Seung version is used, so we have Step 1: L=W'*W, C=L*H and then B=W'*A; Step 2: L=H*H', E=W*L and D=A*H'. W'*W (H*H') and L*H (W*L) can do in parallel with W'*A (A*H'). Because dgemm works fine we don't use threads to do in parallel.

In real live B and C are (k*n) matrices used in STEP 1, and D and E are (m*k) matrices used in STEP 2. B/C and D/E are independent. For this reason only 2 matrices are declared to save space. They are matrices B and C with size max(m,n)*k

Parameters
m(input) Number of rows of matrix A and matrix W
n(input) Number of columns of matrix A and matrix H
k(input) Number of columns of matrix W and rows of H
A(input) Double precision input matrix of (m * n) number of elements stored using 1D column-major
W(inout) Double precision input/output matrix of (m * k) number of elements stored using 1D column-major
H(inout) Double precision input/output matrix of (k * n) number of elements stored using 1D column-major
uType(input) It can be UpdateAll (W and H are updated), UpdateW (only H is updated) or UpdateH (only W is updated)
nIter(input) Number of iterations
Returns
: 0 if all is OK, -1 otherwise

Definition at line 74 of file mlsa_cpu.c.

◆ sdotdiv_x86()

void sdotdiv_x86 ( const int  n,
const float *  x,
const float *  y,
float *__restrict__  z 
)

This function calls the appropiate funtions to performs simple precision element-wise z[i]=z[i]*x[i]/y[i] for all positions of x, y and z.

Parameters
n(input) Number of elements of x, y and z
x(input) Simple precision input vector/matrix (1D column-major)
y(input) Simple precision input vector/matrix (1D column-major)
z(inout) Simple precision input/output vector/matrix (1D column-major)

Definition at line 509 of file mlsa_cpu.c.

◆ smlsa_cpu()

int smlsa_cpu ( const int  m,
const int  n,
const int  k,
const float *  A,
float *  W,
float *  H,
const int  uType,
const int  nIter 
)

smlsa_cpu performs NNMF using betadivergence when beta=2 using simple precision

Parameters
m(input) Number of rows of matrix A and matrix W
n(input) Number of columns of matrix A and matrix H
k(input) Number of columns of matrix W and rows of H
A(input) Simple precision input matrix of (m * n) number of elements stored using 1D column-major
W(inout) Simple precision input/output matrix of (m * k) number of elements stored using 1D column-major
H(inout) Simple precision input/output matrix of (k * n) number of elements stored using 1D column-major
uType(input) It can be UpdateAll (W and H are updated), UpdateW (only H is updated) or UpdateH (only W is updated)
nIter(input) Number of iterations
Returns
: 0 if all is OK, -1 otherwise

Definition at line 275 of file mlsa_cpu.c.