![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
NormL2 is the sub-class of Norm that spheriphies the data according to the l2 norm.
#include <norml2.h>


Public Member Functions | |
| GurlsOptionsList * | execute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt) throw (gException) |
| Spheriphies the data according to the l2 norm. | |
Static Public Member Functions | |
| static Norm< T > * | factory (const std::string &id) throw (BadNormCreation) |
| Factory function returning a pointer to the newly created object. | |
| GurlsOptionsList * gurls::NormL2< T >::execute | ( | const gMat2D< T > & | X, |
| const gMat2D< T > & | Y, | ||
| const GurlsOptionsList & | opt | ||
| ) | throw (gException) [virtual] |
| X | input data matrix |
| Y | not used |
| opt | not used |
Implements gurls::Norm< T >.
Definition at line 75 of file norml2.h.
{
const unsigned long m = X.rows();
const unsigned long n = X.cols();
gMat2D<T>* retX = new gMat2D<T>(m, n);
copy(retX->getData(), X.getData(), retX->getSize());
T *rx_it = retX->getData();
const T epsilon = std::numeric_limits<T>::epsilon();
const T one = (T)1.0;
T norm2;
// for j = 1:size(X,1)
for(unsigned long j=0; j<m; ++j, ++rx_it)
{
// X(j,:) = X(j,:)/(norm(X(j,:)) + eps);
norm2 = nrm2(n, rx_it, m) + epsilon;
scal(n, one/norm2, rx_it, m);
}
GurlsOptionsList* norm = new GurlsOptionsList("norm");
norm->addOpt("X", new OptMatrix<gMat2D<T> >(*retX));
return norm;
}
| static Norm<T>* gurls::Norm< T >::factory | ( | const std::string & | id | ) | throw (BadNormCreation) [inline, static, inherited] |
Definition at line 152 of file norm.h.
{
if(id == "l2")
return new NormL2<T>;
if(id == "zscore")
return new NormZScore<T>;
if(id == "testzscore")
return new NormTestZScore<T>;
throw BadNormCreation(id);
}