GURLS++  2.0.00
C++ Implementation of GURLS Matlab Toolbox
gurls::NormL2< T > Class Template Reference

NormL2 is the sub-class of Norm that spheriphies the data according to the l2 norm.

#include <norml2.h>

Inheritance diagram for gurls::NormL2< T >:
Collaboration diagram for gurls::NormL2< T >:

List of all members.

Public Member Functions

GurlsOptionsListexecute (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.

Detailed Description

template<typename T>
class gurls::NormL2< T >

Definition at line 61 of file norml2.h.


Member Function Documentation

template<typename T >
GurlsOptionsList * gurls::NormL2< T >::execute ( const gMat2D< T > &  X,
const gMat2D< T > &  Y,
const GurlsOptionsList opt 
) throw (gException) [virtual]
Parameters:
Xinput data matrix
Ynot used
optnot used
Returns:
spheriphied input data matrix

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;
}
template<typename T>
static Norm<T>* gurls::Norm< T >::factory ( const std::string &  id) throw (BadNormCreation) [inline, static, inherited]
Warning:
The returned pointer is a plain, un-managed pointer. The calling function is responsible of deallocating the object.

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);
    }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends