planc
Parallel Lowrank Approximation with Non-negativity Constraints
Public Member Functions | List of all members
planc::NCPFactors Class Reference

#include <ncpfactors.hpp>

Public Member Functions

 NCPFactors (const UVEC &i_dimensions, const int &i_k, bool trans)
 constructor that takes the dimensions of every mode, low rank k All the factors will be initialized with random uniform number More...
 
 ~NCPFactors ()
 
int rank () const
 returns low rank More...
 
UVEC dimensions () const
 dimensions of every mode More...
 
MATfactor (const int i_n) const
 factor matrix of a mode i_n More...
 
int modes () const
 returns number of modes More...
 
VEC lambda () const
 returns the lambda vector More...
 
void set (const int i_n, const MAT &i_factor)
 Set the mode i_n with the given factor matrix. More...
 
void set_lambda (const VEC &new_lambda)
 sets the lambda vector More...
 
void gram (MAT *o_UtU)
 Return the hadamard of the factor grams. More...
 
void gram_leave_out_one (const unsigned int i_n, MAT *o_UtU)
 Returns the hadamard of the factor grams except i_n. More...
 
MAT krp_leave_out_one (const unsigned int i_n)
 KRP leaving out the mode i_n. More...
 
void krp_leave_out_one (const unsigned int i_n, MAT *o_krp)
 khatrirao leaving out one. More...
 
void krp (const UVEC i_modes, MAT *o_krp)
 KRP of the given vector of modes. More...
 
void rankk_tensor (Tensor &out)
 Construct the rank k tensor out of the factor matrices Determine the KRP of the n-1 modes leaving out 0 and multiply with the mode 0 factor matrix. More...
 
void printinfo ()
 prints just the information about the factors. More...
 
void print ()
 prints the entire NCPFactors including the factor matrices More...
 
void print (const unsigned int i_n)
 print the ith factor matrix alone More...
 
void trans (NCPFactors &factor_t)
 Transposes the entire factor matrix. More...
 
void normalize ()
 only during initialization. Reset's all lambda. More...
 
void normalize (int mode)
 Column normalizes the factor matrix of the given mode and replaces the existing lambda. More...
 
void normalize_rows (unsigned int mode)
 Row normalizes the factor matrix of the given mode and replaces the existing lambda. More...
 
void randu (const int i_seed)
 initializes the local tensor with the given seed. More...
 
void zeros ()
 this is for reinitializing zeros across different processors. More...
 

Detailed Description

Definition at line 22 of file ncpfactors.hpp.

Constructor & Destructor Documentation

◆ NCPFactors()

planc::NCPFactors::NCPFactors ( const UVEC i_dimensions,
const int &  i_k,
bool  trans 
)
inline

constructor that takes the dimensions of every mode, low rank k All the factors will be initialized with random uniform number

Parameters
[in]vectorof dimension for every mode.
[in]lowrank
[in]trans.takes true or false. Transposes every factor.

Definition at line 41 of file ncpfactors.hpp.

◆ ~NCPFactors()

planc::NCPFactors::~NCPFactors ( )
inline

Definition at line 84 of file ncpfactors.hpp.

Member Function Documentation

◆ dimensions()

UVEC planc::NCPFactors::dimensions ( ) const
inline

dimensions of every mode

Definition at line 98 of file ncpfactors.hpp.

◆ factor()

MAT& planc::NCPFactors::factor ( const int  i_n) const
inline

factor matrix of a mode i_n

Definition at line 100 of file ncpfactors.hpp.

◆ gram()

void planc::NCPFactors::gram ( MAT o_UtU)
inline

Return the hadamard of the factor grams.

Parameters
[out]UtUis a kxk matrix

Definition at line 123 of file ncpfactors.hpp.

◆ gram_leave_out_one()

void planc::NCPFactors::gram_leave_out_one ( const unsigned int  i_n,
MAT o_UtU 
)
inline

Returns the hadamard of the factor grams except i_n.

Parameters
[in]i_nith mode that will be excluded in the factor grams
[out]UtUis a kxk matrix

Definition at line 139 of file ncpfactors.hpp.

◆ krp()

void planc::NCPFactors::krp ( const UVEC  i_modes,
MAT o_krp 
)
inline

KRP of the given vector of modes.

It can be any subset of the modes.

Parameters
[in]Subsetof modes
[out]KRPof product of dimensions of the given modes by k

Definition at line 239 of file ncpfactors.hpp.

◆ krp_leave_out_one() [1/2]

MAT planc::NCPFactors::krp_leave_out_one ( const unsigned int  i_n)
inline

KRP leaving out the mode i_n.

Parameters
[in]modei_n
Returns
MAT of size product of dimensions except i_n by k

Definition at line 154 of file ncpfactors.hpp.

◆ krp_leave_out_one() [2/2]

void planc::NCPFactors::krp_leave_out_one ( const unsigned int  i_n,
MAT o_krp 
)
inline

khatrirao leaving out one.

we are using the implementation from tensor toolbox. Always krp for mttkrp is computed in reverse. Hence assuming the same. The order of the computation is same a tensor tool box. size of krp must be product of all dimensions leaving out nxk

Parameters
[in]i_nmode that will be excluded
[out]m_dimensions[i_n]xk

Definition at line 171 of file ncpfactors.hpp.

◆ lambda()

VEC planc::NCPFactors::lambda ( ) const
inline

returns the lambda vector

Definition at line 104 of file ncpfactors.hpp.

◆ modes()

int planc::NCPFactors::modes ( ) const
inline

returns number of modes

Definition at line 102 of file ncpfactors.hpp.

◆ normalize() [1/2]

void planc::NCPFactors::normalize ( )
inline

only during initialization. Reset's all lambda.

Definition at line 329 of file ncpfactors.hpp.

◆ normalize() [2/2]

void planc::NCPFactors::normalize ( int  mode)
inline

Column normalizes the factor matrix of the given mode and replaces the existing lambda.

Parameters
[in]modeof the factor matrix that will be column normalized

Definition at line 346 of file ncpfactors.hpp.

◆ normalize_rows()

void planc::NCPFactors::normalize_rows ( unsigned int  mode)
inline

Row normalizes the factor matrix of the given mode and replaces the existing lambda.

Parameters
[in]modeof the factor matrix that will be row normalized

Definition at line 358 of file ncpfactors.hpp.

◆ print() [1/2]

void planc::NCPFactors::print ( )
inline

prints the entire NCPFactors including the factor matrices

Definition at line 302 of file ncpfactors.hpp.

◆ print() [2/2]

void planc::NCPFactors::print ( const unsigned int  i_n)
inline

print the ith factor matrix alone

Parameters
[in]i_nthe mode for which the factor matrix to be printed

Definition at line 314 of file ncpfactors.hpp.

◆ printinfo()

void planc::NCPFactors::printinfo ( )
inline

prints just the information about the factors.

it will NOT print the factor

Definition at line 296 of file ncpfactors.hpp.

◆ randu()

void planc::NCPFactors::randu ( const int  i_seed)
inline

initializes the local tensor with the given seed.

this is for reinitializing random numbers across different processors.

Parameters
[in]i_seed

Definition at line 371 of file ncpfactors.hpp.

◆ rank()

int planc::NCPFactors::rank ( ) const
inline

returns low rank

Definition at line 96 of file ncpfactors.hpp.

◆ rankk_tensor()

void planc::NCPFactors::rankk_tensor ( Tensor out)
inline

Construct the rank k tensor out of the factor matrices Determine the KRP of the n-1 modes leaving out 0 and multiply with the mode 0 factor matrix.

Parameters
[out]Rank-ktensor

Definition at line 282 of file ncpfactors.hpp.

◆ set()

void planc::NCPFactors::set ( const int  i_n,
const MAT i_factor 
)
inline

Set the mode i_n with the given factor matrix.

Parameters
[in]i_nmode for which given factor matrix will be updated
[in]i_factorfactor matrix

Definition at line 112 of file ncpfactors.hpp.

◆ set_lambda()

void planc::NCPFactors::set_lambda ( const VEC new_lambda)
inline

sets the lambda vector

Definition at line 117 of file ncpfactors.hpp.

◆ trans()

void planc::NCPFactors::trans ( NCPFactors factor_t)
inline

Transposes the entire factor matrix.

Parameters
[out]factor_tthat contains the transpose of every factor matrix.

Definition at line 323 of file ncpfactors.hpp.

◆ zeros()

void planc::NCPFactors::zeros ( )
inline

this is for reinitializing zeros across different processors.

Definition at line 382 of file ncpfactors.hpp.


The documentation for this class was generated from the following file: