Defines

AsciiFile.cpp File Reference

Go to the source code of this file.

Defines

#define GET_VECTOR(fname, mfname, sg_type)
#define GET_MATRIX(fname, conv, sg_type)
#define GET_SPARSEMATRIX(fname, conv, sg_type)
#define SET_VECTOR(fname, mfname, sg_type)
#define SET_MATRIX(fname, sg_type, fprt_type, type_str)
#define SET_SPARSEMATRIX(fname, sg_type, fprt_type, type_str)

Define Documentation

#define GET_MATRIX (   fname,
  conv,
  sg_type 
)

Definition at line 72 of file AsciiFile.cpp.

#define GET_SPARSEMATRIX (   fname,
  conv,
  sg_type 
)

Definition at line 185 of file AsciiFile.cpp.

#define GET_VECTOR (   fname,
  mfname,
  sg_type 
)
Value:
void CAsciiFile::fname(sg_type*& vec, int32_t& len) \
{                                                   \
    vec=NULL;                                       \
    len=0;                                          \
    int32_t num_feat=0;                             \
    int32_t num_vec=0;                              \
    mfname(vec, num_feat, num_vec);                 \
    if ((num_feat==1) || (num_vec==1))              \
    {                                               \
        if (num_feat==1)                            \
            len=num_vec;                            \
        else                                        \
            len=num_feat;                           \
    }                                               \
    else                                            \
    {                                               \
        delete[] vec;                               \
        vec=NULL;                                   \
        len=0;                                      \
        SG_ERROR("Could not read vector from"       \
                " file %s (shape %dx%d found but "  \
                "vector expected).\n", filename,    \
                num_vec, num_feat);                 \
    }                                               \
}

Definition at line 36 of file AsciiFile.cpp.

#define SET_MATRIX (   fname,
  sg_type,
  fprt_type,
  type_str 
)
Value:
void CAsciiFile::fname(const sg_type* matrix, int32_t num_feat, int32_t num_vec)    \
{                                                                                   \
    if (!(file && matrix))                                                          \
        SG_ERROR("File or matrix invalid.\n");                                      \
                                                                                    \
    for (int32_t i=0; i<num_vec; i++)                                               \
    {                                                                               \
        for (int32_t j=0; j<num_feat; j++)                                          \
        {                                                                           \
            sg_type v=matrix[num_feat*i+j];                                         \
            if (j==num_feat-1)                                                      \
                fprintf(file, type_str "\n", (fprt_type) v);                        \
            else                                                                    \
                fprintf(file, type_str " ", (fprt_type) v);                         \
        }                                                                           \
    }                                                                               \
}

Definition at line 729 of file AsciiFile.cpp.

#define SET_SPARSEMATRIX (   fname,
  sg_type,
  fprt_type,
  type_str 
)
Value:
void CAsciiFile::fname(const TSparse<sg_type>* matrix, int32_t num_feat, int32_t num_vec)   \
{                                                                                           \
    if (!(file && matrix))                                                                  \
        SG_ERROR("File or matrix invalid.\n");                                              \
                                                                                            \
    for (int32_t i=0; i<num_vec; i++)                                                       \
    {                                                                                       \
        TSparseEntry<sg_type>* vec = matrix[i].features;                                    \
        int32_t len=matrix[i].num_feat_entries;                                             \
                                                                                            \
        for (int32_t j=0; j<len; j++)                                                       \
        {                                                                                   \
            if (j<len-1)                                                                    \
            {                                                                               \
                fprintf(file, "%d:" type_str " ",                                           \
                        (int32_t) vec[j].feat_index+1, (fprt_type) vec[j].entry);           \
            }                                                                               \
            else                                                                            \
            {                                                                               \
                fprintf(file, "%d:" type_str "\n",                                          \
                        (int32_t) vec[j].feat_index+1, (fprt_type) vec[j].entry);           \
            }                                                                               \
        }                                                                                   \
    }                                                                                       \
}

Definition at line 761 of file AsciiFile.cpp.

#define SET_VECTOR (   fname,
  mfname,
  sg_type 
)
Value:
void CAsciiFile::fname(const sg_type* vec, int32_t len) \
{                                                           \
    mfname(vec, len, 1);                                    \
}

set functions - to pass data from shogun to the target interface

Definition at line 715 of file AsciiFile.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation