/* <class V>: AzSvect (sparse vector) | AzDvect (dense vector) */ template <class V> void apply(const V *v_x, AzDvect *v_pred) const { v_pred->reform(classNum()); double *pred = v_pred->point_u(); int cx; for (cx = 0; cx < classNum(); ++cx) { pred[cx] = ws*m_w.col(cx)->innerProduct(v_x); } }
template <class M> double test_classif(const M *m_x, const AzIntArr *ia_lab) const { if (classNum() == 1) return test_classif_bin<M>(m_x, ia_lab); else return test_classif_multi<M>(m_x, ia_lab); }
/* <class M>: AzSmat (sparse matrix) | AzDmat (dense matrix) */ template <class M> void apply(const M *m_x, AzDmat *m_pred) const { int data_size = m_x->colNum(); m_pred->reform(classNum(), data_size); int dx; for (dx = 0; dx < data_size; ++dx) apply(m_x->col(dx), m_pred->col_u(dx)); }
template <class V> double apply(const V *v_x) const { if (classNum() != 1) throw new AzException("AzsLmod::apply", "apply(x) is only for binary classification."); return ws*m_w.col(0)->innerProduct(v_x); }
//////////////////////////////////////////////////////////////////////////////// // parse - parses a declaration (s.a. TIntermediateRenderer::declare() for syntax // of type) // // Parameters: // name - optional name of the declaration (case sensitive) // type - type description of the declaration // isDef - true if the declarition a default declaration of the renderer // // Returns: // false - type could not be parsed // bool TParameterDeclaration::parse(const char *name, const char *type, bool isDef) { m_isDefault = isDef; m_name = name ? name : ""; m_fullname = type ? type : m_name.c_str(); m_isInline = false; if ( type ) { size_t pos = 0; while ( *type && isspace(*type) ) ++type; m_class = classNum(type, pos); if ( m_class ) type += pos; else m_class = CLASS_UNIFORM; pos = 0; while ( *type && isspace(*type) ) ++type; m_type = typeNum(type, pos); if ( m_type ) type += pos; /* else // if there is no default type (== 0) return false; */ pos = 0; while ( *type && isspace(*type) ) ++type; m_cardinality = cardinality(type, pos); if ( m_cardinality >= 1 ) type += pos; else m_cardinality = 1; pos = 0; while ( *type && isspace(*type) ) ++type; if ( !name || !*name ) { // RI_TOKEN name while ( *type && !isspace(*type) ) { if ( !m_isInline ) { m_name = ""; m_isInline = true; } m_name += *type; ++type; } if ( !m_name.length() ) return false; } // now only white space should follow while ( *type ) { if ( !isspace(*type) ) return false; ++type; } } else { m_class = 0; m_type = 0; m_cardinality = 0; } buildFullname(); return true; }