PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes
PLearn::SelectColumnsVMatrix Class Reference

selects variables (columns) from a source matrix according to given vector of indices. More...

#include <SelectColumnsVMatrix.h>

Inheritance diagram for PLearn::SelectColumnsVMatrix:
Inheritance graph
[legend]
Collaboration diagram for PLearn::SelectColumnsVMatrix:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SelectColumnsVMatrix ()
 Default constructor.
 SelectColumnsVMatrix (VMat the_source, TVec< string > the_fields, bool the_extend_with_missing=false, bool call_build_=true)
 The appropriate fieldinfos are copied upon construction.
 SelectColumnsVMatrix (VMat the_source, TVec< int > the_indices, bool call_build_=true)
 The appropriate fieldinfos are copied upon construction Here the indices will be shared for efficiency.
 SelectColumnsVMatrix (VMat the_source, Vec the_indices)
 Here the indices will be copied locally into an integer vector.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SelectColumnsVMatrixdeepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual real get (int i, int j) const
 These methods are implemented by buffering calls to getNewRow.
virtual void getSubRow (int i, int j, Vec v) const
 fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive)
virtual void reset_dimensions ()
 In case the dimensions of an underlying VMat has changed, recompute it.
virtual const map< string, real > & getStringToRealMapping (int col) const
 Returns the string->real mapping for column 'col'.
virtual const map< real, string > & getRealToStringMapping (int col) const
 Returns the real->string mapping for column 'col'.
virtual real getStringVal (int col, const string &str) const
 Returns value associated with a string (or MISSING_VALUE if there's no association for this string).
virtual string getValString (int col, real val) const
 Returns the string associated with value val for field# col.
virtual PP< DictionarygetDictionary (int col) const
 Return the Dictionary object for a certain field, or a null pointer if there isn't one.
virtual void getValues (int row, int col, Vec &values) const
 Gives the possible values for a certain field in the VMatrix.
virtual void getValues (const Vec &input, int col, Vec &values) const
 Gives the possible values of a certain field (column) given the input.

Static Public Member Functions

static string _classname_ ()
 SelectColumnsVMatrix.
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Public Attributes

bool extend_with_missing
TVec< intindices
TVec< string > fields
PPath save_fields
bool fields_partial_match
bool fields_regex
bool inverse_fields_selection
bool warn_non_selected_field

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void getNewRow (int i, const Vec &v) const
 Must be implemented in subclasses: default version returns an error.
void getIndicesFromFields ()
 fill this.indices from this.fields We do the partial match if this.fields_partial_match is true.

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares this class' options.

Protected Attributes

TVec< intsel_indices
 Final column indices to be selected.

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Private Attributes

Vec sinput
 Input vector for source VMatrix.

Detailed Description

selects variables (columns) from a source matrix according to given vector of indices.

NC: removed the unused field raw_sample.

Definition at line 56 of file SelectColumnsVMatrix.h.


Member Typedef Documentation


Constructor & Destructor Documentation

PLearn::SelectColumnsVMatrix::SelectColumnsVMatrix ( )

Default constructor.

Definition at line 63 of file SelectColumnsVMatrix.cc.

PLearn::SelectColumnsVMatrix::SelectColumnsVMatrix ( VMat  the_source,
TVec< string >  the_fields,
bool  the_extend_with_missing = false,
bool  call_build_ = true 
)

The appropriate fieldinfos are copied upon construction.

Here the indices will be shared for efficiency. But you should not modify them afterwards!

Definition at line 71 of file SelectColumnsVMatrix.cc.

References build_().

                                                            :
    inherited(the_source, call_build_),
    extend_with_missing(the_extend_with_missing),
    fields(the_fields),
    fields_partial_match(false),
    fields_regex(false),
    inverse_fields_selection(false),
    warn_non_selected_field(false)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:

PLearn::SelectColumnsVMatrix::SelectColumnsVMatrix ( VMat  the_source,
TVec< int the_indices,
bool  call_build_ = true 
)

The appropriate fieldinfos are copied upon construction Here the indices will be shared for efficiency.

But you should not modify them afterwards!

Definition at line 87 of file SelectColumnsVMatrix.cc.

References build_().

                                                            :
    inherited(the_source, call_build_),
    extend_with_missing(false),
    indices(the_indices),
    fields_partial_match(false),
    fields_regex(false),
    inverse_fields_selection(false),
    warn_non_selected_field(false)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:

PLearn::SelectColumnsVMatrix::SelectColumnsVMatrix ( VMat  the_source,
Vec  the_indices 
)

Here the indices will be copied locally into an integer vector.

Definition at line 102 of file SelectColumnsVMatrix.cc.

References build_(), indices, PLearn::TVec< T >::length(), PLearn::TVec< T >::resize(), and PLearn::SourceVMatrix::source.

    : extend_with_missing(false),
      fields_partial_match(false),
      fields_regex(false),
      inverse_fields_selection(false),
      warn_non_selected_field(false)
{
    source = the_source;
    indices.resize(the_indices.length());
    // copy the real the_indices into the integer indices
    indices << the_indices;
    build_();
}

Here is the call graph for this function:


Member Function Documentation

string PLearn::SelectColumnsVMatrix::_classname_ ( ) [static]
OptionList & PLearn::SelectColumnsVMatrix::_getOptionList_ ( ) [static]
RemoteMethodMap & PLearn::SelectColumnsVMatrix::_getRemoteMethodMap_ ( ) [static]
bool PLearn::SelectColumnsVMatrix::_isa_ ( const Object o) [static]
Object * PLearn::SelectColumnsVMatrix::_new_instance_for_typemap_ ( ) [static]
StaticInitializer SelectColumnsVMatrix::_static_initializer_ & PLearn::SelectColumnsVMatrix::_static_initialize_ ( ) [static]
void PLearn::SelectColumnsVMatrix::build ( ) [virtual]
void PLearn::SelectColumnsVMatrix::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::GetInputVMatrix, PLearn::ShuffleColumnsVMatrix, and PLearn::VariableDeletionVMatrix.

Definition at line 227 of file SelectColumnsVMatrix.cc.

References PLearn::TVec< T >::append(), PLearn::VMatrix::computeMissingSizeValue(), extend_with_missing, PLearn::VMatrix::fieldinfos, PLearn::VMat::fieldName(), PLearn::VMatrix::fieldNames(), fields, PLearn::TVec< T >::fill(), getIndicesFromFields(), i, indices, PLearn::VMatrix::inputsize_, inverse_fields_selection, PLearn::PPath::isEmpty(), PLearn::TVec< T >::isNotEmpty(), j, PLearn::VMat::length(), PLearn::TVec< T >::length(), PLearn::VMatrix::length_, MISSING_VALUE, PLCHECK, PLERROR, PLWARNING, PLearn::TVec< T >::resize(), PLearn::save(), save_fields, sel_indices, sinput, PLearn::TVec< T >::size(), PLearn::SourceVMatrix::source, PLearn::VMatrix::targetsize(), PLearn::VMatrix::targetsize_, PLearn::tostring(), PLearn::VMatrix::updateMtime(), warn_non_selected_field, PLearn::VMatrix::weightsize(), PLearn::VMatrix::weightsize_, PLearn::VMatrix::width(), PLearn::VMat::width(), and PLearn::VMatrix::width_.

Referenced by build(), and SelectColumnsVMatrix().

{
    if (source) {
        updateMtime(source);
        if (fields.isNotEmpty()) {
            getIndicesFromFields();
        }
        
        //we inverse the selection
        if(inverse_fields_selection){
            TVec<int> newindices;
            for (int i = 0;i<source.width();i++){
                bool found=false;
                for(int j=0;j<indices.size();j++)
                    if(indices[j]==i){
                        found = true;
                        break;
                    }
                if(!found)
                    newindices.append(i);
            }
            sel_indices = newindices;
        } else
            sel_indices = indices;

        if(warn_non_selected_field){
            TVec<string> v;
            for(int i=0;i<source.width();i++)
            {
                bool found=false;
                for(int j=0;j<sel_indices.size();j++)
                    if(sel_indices[j]==i){
                        found=true;
                        break;
                    }
                if(!found)
                    v.append(source.fieldName(i));
            }
            if(v.size()>0)
                PLWARNING("In SelectColumnsVMatrix::build_() - There are %d"
                          " columns in the source matrix that we do not "
                          "select: %s",v.size(),tostring(v).c_str());
        }

        // Copy matrix dimensions
        width_ = sel_indices.length();
        length_ = source->length();

        if(!extend_with_missing)
            // The new width cannot exceed the old one.
            PLCHECK(source->width() >= width_);

        //if we don't add new columns and the source columns type are emtpy,
        //they should be empty in this matrix if they are not already set.
        if(targetsize_<0 && !extend_with_missing && source->targetsize()==0)
            targetsize_=0;
        if(weightsize_<0 && !extend_with_missing && source->weightsize()==0)
            weightsize_=0;
        computeMissingSizeValue(false);

#if 0
        // Disabled for now, since it gives way too many false positives in
        // some cases. Todo: figure out a way to warn in a useful way when
        // a SelectColumnsVMatrix is given as a train or test set to a learner,
        // with inputsize and friends not set manually.

        // Give warning if inputsize, and friends are not specified, since we
        // can't just copy the values from the underlying VMat. A smarter
        // version of this class could Figure out the right size for inputsize,
        // targetsize and weightsize, at least for some cases (for example when
        // the indices are nondecreasing).
        if (inputsize_ < 0 || targetsize_ < 0 || weightsize_ < 0)
            PLWARNING("In SelectColumnsVMatrix::build_ inputsize, targetsize or weightsize "
                      "not set. You may want to set them yourself in the .plearn file.");
#endif

        // Copy the appropriate VMFields
        fieldinfos.resize(width());
        if (source->getFieldInfos().size() > 0) {
            for (int i=0; i<width(); ++i) {
                int col = sel_indices[i];
                if (col == -1) {
                    if (extend_with_missing)
                        // This must be because it is a field that did not exist in
                        // the source VMat.
                        fieldinfos[i] = VMField(fields[i]);
                    else
                        PLERROR("In SelectColumnsVMatrix::build_ - '-1' is not a valid value in indices");
                } else {
                    fieldinfos[i] = source->getFieldInfos(col);
                }
            }
        }

        sinput.resize(width());
        sinput.fill(MISSING_VALUE);

        if(!save_fields.isEmpty())
            PLearn::save(save_fields, fieldNames());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::SelectColumnsVMatrix::classname ( ) const [virtual]
void PLearn::SelectColumnsVMatrix::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::GetInputVMatrix, PLearn::ShuffleColumnsVMatrix, and PLearn::VariableDeletionVMatrix.

Definition at line 157 of file SelectColumnsVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), extend_with_missing, fields, fields_partial_match, fields_regex, indices, inverse_fields_selection, PLearn::VMatrix::length_, PLearn::OptionBase::nosave, PLearn::redeclareOption(), save_fields, warn_non_selected_field, and PLearn::VMatrix::width_.

Referenced by PLearn::VariableDeletionVMatrix::declareOptions(), and PLearn::ShuffleColumnsVMatrix::declareOptions().

{
    declareOption(ol, "fields", &SelectColumnsVMatrix::fields, OptionBase::buildoption,
                  "The names of the fields to extract (will override 'indices' if provided). Can\n"
                  "be a range of the form Field_1-Field_n, if 'extend_with_missing' is false.");

    declareOption(ol, "save_fields", &SelectColumnsVMatrix::save_fields,
                  OptionBase::buildoption,
        "Optional file where the fieldnames of this VMatrix should be saved.");

    declareOption(ol, "fields_partial_match", &SelectColumnsVMatrix::fields_partial_match, OptionBase::buildoption,
                  "If set to 1, then a field will be kept iff it contains one of the strings from 'fields'.");

    declareOption(ol, "fields_regex", &SelectColumnsVMatrix::fields_regex, OptionBase::buildoption,
                  "If set to 1, then a field will be kept iff it match one of the strings from 'fields'. A match is when the two string is equal or when fields end with a *, we allow any end.");

    declareOption(ol, "indices", &SelectColumnsVMatrix::indices, OptionBase::buildoption,
                  "The array of column indices to extract.");

    declareOption(ol, "extend_with_missing", &SelectColumnsVMatrix::extend_with_missing, OptionBase::buildoption,
                  "If set to 1, then fields specified in the 'fields' option that do not exist\n"
                  "in the source VMatrix will be filled with missing values.");

    declareOption(ol, "inverse_fields_selection",
                  &SelectColumnsVMatrix::inverse_fields_selection,
                  OptionBase::buildoption,
        "If set to true, the selection is reversed. This provides an easy\n"
        "way to specify columns we do not want.");

    declareOption(ol, "warn_non_selected_field",
                  &SelectColumnsVMatrix::warn_non_selected_field,
                  OptionBase::buildoption,
                  "If set to true, we generate a PLWARNING with all fields "
                  "that are not selected.");

    inherited::declareOptions(ol);

    redeclareOption(ol, "length", &SelectColumnsVMatrix::length_,
                    OptionBase::nosave,
                    "Taken from source");

    redeclareOption(ol, "width", &SelectColumnsVMatrix::width_,
                    OptionBase::nosave,
                    "Computed from parameter");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const PPath& PLearn::SelectColumnsVMatrix::declaringFile ( ) [inline, static]
SelectColumnsVMatrix * PLearn::SelectColumnsVMatrix::deepCopy ( CopiesMap copies) const [virtual]
real PLearn::SelectColumnsVMatrix::get ( int  i,
int  j 
) const [virtual]

These methods are implemented by buffering calls to getNewRow.

returns element (i,j)

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 119 of file SelectColumnsVMatrix.cc.

References j, PLearn::VMatrix::length_, MISSING_VALUE, PLERROR, sel_indices, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

                                                 {
#ifdef BOUNDCHECK
    if(i>=length_ ||j>=width_||i<0||j<0)
        PLERROR("In SelectColumnsVMatrix::getSubRow - "
                "requested index: (%d,%d) but width of %d and length of %d",
                i,j,width_,length_);
#endif
    int col;
    col = sel_indices[j];
    if (col == -1)
        return MISSING_VALUE;
    return source->get(i, col);
}
PP< Dictionary > PLearn::SelectColumnsVMatrix::getDictionary ( int  col) const [virtual]

Return the Dictionary object for a certain field, or a null pointer if there isn't one.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 462 of file SelectColumnsVMatrix.cc.

References PLERROR, sel_indices, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
    int the_col;
    the_col = sel_indices[col];
    if (the_col == -1)
        return 0;
    return source->getDictionary(the_col);
}
void PLearn::SelectColumnsVMatrix::getIndicesFromFields ( ) [protected]

fill this.indices from this.fields We do the partial match if this.fields_partial_match is true.

Definition at line 329 of file SelectColumnsVMatrix.cc.

References PLearn::TVec< T >::append(), PLearn::endl(), extend_with_missing, fields, fields_partial_match, fields_regex, PLearn::VMatrix::find(), PLearn::VMat::getFieldIndex(), i, indices, inverse_fields_selection, j, PLearn::TVec< T >::length(), PLearn::pl_islong(), PLERROR, PLWARNING, PLearn::TVec< T >::resize(), PLearn::TVec< T >::size(), PLearn::SourceVMatrix::source, PLearn::string_begins_with(), and PLearn::tostring().

Referenced by build_().

                                               {
            // Find out the indices from the fields.
    indices.resize(0);
    if (!fields_partial_match && ! fields_regex) {
        TVec<string> missing_field;
        for (int i = 0; i < fields.length(); i++) {
            string the_field = fields[i];
            int the_index = source->fieldIndex(the_field);  // string only
            if (!extend_with_missing && the_index == -1) {
                // The_field does not exist AS A STRING in the vmat
                // It may be of the form FIELD1-FIELDN (a range of fields).
                size_t pos = the_field.find('-');
                bool ok = false;
                if (pos != string::npos) {
                    string field1 = the_field.substr(0, pos);
                    string fieldn = the_field.substr(pos + 1);
                    int the_index1 = source->getFieldIndex(field1);  // either string or number
                    int the_indexn = source->getFieldIndex(fieldn);  // either string or number
                    if (the_index1 >= 0 && the_indexn > the_index1) {
                        // Indeed, this is a range.
                        ok = true;
                        for (int j = the_index1; j <= the_indexn; j++)
                            indices.append(j);
                    }
                }
                // OR it may be a number by itself only
                else if (pl_islong(the_field) &&
                         (the_index = source->getFieldIndex(the_field)) != -1)
                {
                    ok = true;
                    indices.append(the_index);
                }
                if (!ok && !inverse_fields_selection)
                    PLERROR("In SelectColumnsVMatrix::build_ - Unknown field \"%s\" in source VMat;\n"
                            "    (you may want to use the 'extend_with_missing' option)", the_field.c_str());
                else if(!ok)
                    PLWARNING("In SelectColumnsVMatrix::build_ - Unknown field \"%s\" in source VMat;\n"
                              " as we want to ignore this field, we ignore this error.", the_field.c_str());
                    
            } else
                indices.append(the_index);
            if(extend_with_missing && the_index == -1)
                missing_field.append(the_field);
        }
        if(missing_field.size()>0){
            PLWARNING("In SelectColumnsVMatrix::build_() - We are"
                      " adding %d columns to the source matrix with missing values."
                      " The columns names are: %s",missing_field.size(),
                      tostring(missing_field).c_str());
        }

    } else if(fields_regex) {
        // We need to check whether or not we should add each field.
        TVec<string> source_fields = source->fieldNames();
        for (int j = 0; j < fields.length(); j++){
            string f = fields[j];
            if(f[f.size()-1]=='*'){
                f.resize(f.size()-1);//remove the last caracter (*)
                for (int i = 0; i < source_fields.length(); i++)
                    if (string_begins_with(source_fields[i],f)) {
                        // We want to add this field.
                        indices.append(i);
                        DBG_MODULE_LOG<<fields[j]<<" matched "<<source_fields[i]<<endl;
                    }
            }else{
                for (int i = 0; i < source_fields.length(); i++)
                    if(source_fields[i]==f){
                        indices.append(i);
                        //their should be only one fields with a given name
                        break;
                    }
            }
        }
    } else {
        // We need to check whether or not we should add each field.
        TVec<string> source_fields = source->fieldNames();
        for (int i = 0; i < source_fields.length(); i++)
            for (int j = 0; j < fields.length(); j++)
                if (source_fields[i].find(fields[j]) != string::npos) {
                    // We want to add this field.
                    indices.append(i);
                    DBG_MODULE_LOG<<fields[j]<<" matched "<<source_fields[i]<<endl;
                    break;
                }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::SelectColumnsVMatrix::getNewRow ( int  i,
const Vec v 
) const [inline, protected, virtual]

Must be implemented in subclasses: default version returns an error.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 109 of file SelectColumnsVMatrix.h.

{ getSubRow(i, 0, v); }
OptionList & PLearn::SelectColumnsVMatrix::getOptionList ( ) const [virtual]
OptionMap & PLearn::SelectColumnsVMatrix::getOptionMap ( ) const [virtual]
const map< real, string > & PLearn::SelectColumnsVMatrix::getRealToStringMapping ( int  col) const [virtual]

Returns the real->string mapping for column 'col'.

Reimplemented from PLearn::VMatrix.

Definition at line 442 of file SelectColumnsVMatrix.cc.

References sel_indices, and PLearn::SourceVMatrix::source.

                                                                                  {
    int the_col;
    static map<real, string> empty_mapping;
    the_col = sel_indices[col];
    if (the_col == -1)
        return empty_mapping;
    return source->getRealToStringMapping(the_col);
}
RemoteMethodMap & PLearn::SelectColumnsVMatrix::getRemoteMethodMap ( ) const [virtual]
const map< string, real > & PLearn::SelectColumnsVMatrix::getStringToRealMapping ( int  col) const [virtual]

Returns the string->real mapping for column 'col'.

Reimplemented from PLearn::VMatrix.

Definition at line 419 of file SelectColumnsVMatrix.cc.

References sel_indices, and PLearn::SourceVMatrix::source.

                                                                                  {
    int the_col;
    static map<string, real> empty_mapping;
    the_col = sel_indices[col];
    if (the_col == -1)
        return empty_mapping;
    return source->getStringToRealMapping(the_col);
}
real PLearn::SelectColumnsVMatrix::getStringVal ( int  col,
const string &  str 
) const [virtual]

Returns value associated with a string (or MISSING_VALUE if there's no association for this string).

Reimplemented from PLearn::VMatrix.

Definition at line 431 of file SelectColumnsVMatrix.cc.

References MISSING_VALUE, sel_indices, and PLearn::SourceVMatrix::source.

                                                                         {
    int the_col;
    the_col = sel_indices[col];
    if (the_col == -1)
        return MISSING_VALUE;
    return source->getStringVal(the_col, str);
}
void PLearn::SelectColumnsVMatrix::getSubRow ( int  i,
int  j,
Vec  v 
) const [virtual]

fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive)

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 136 of file SelectColumnsVMatrix.cc.

References PLearn::TVec< T >::length(), PLearn::VMatrix::length_, MISSING_VALUE, PLERROR, sel_indices, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
#ifdef BOUNDCHECK
    if(i>=length_ ||j>=width_||i<0||j<0)
        PLERROR("In SelectColumnsVMatrix::getSubRow - "
                "requested index: (%d,%d) but width of %d and length of %d",
                i,j,width_,length_);
#endif
    int col;
    for(int jj=0; jj<v.length(); jj++) {
        col = sel_indices[j+jj];
        if (col == -1)
            v[jj] = MISSING_VALUE;
        else
            v[jj] = source->get(i, col);
    }
}

Here is the call graph for this function:

string PLearn::SelectColumnsVMatrix::getValString ( int  col,
real  val 
) const [virtual]

Returns the string associated with value val for field# col.

Or returns "" if no string is associated.

Reimplemented from PLearn::VMatrix.

Definition at line 454 of file SelectColumnsVMatrix.cc.

References sel_indices, and PLearn::SourceVMatrix::source.

                                                                 {
    int the_col;
    the_col = sel_indices[col];
    if (the_col == -1)
        return "";
    return source->getValString(the_col, val);
}
void PLearn::SelectColumnsVMatrix::getValues ( int  row,
int  col,
Vec values 
) const [virtual]

Gives the possible values for a certain field in the VMatrix.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 474 of file SelectColumnsVMatrix.cc.

References PLERROR, PLearn::TVec< T >::resize(), sel_indices, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
    int the_col;
    the_col = sel_indices[col];
    if (the_col == -1)
        values.resize(0);
    else
        source->getValues(row,the_col,values);
}

Here is the call graph for this function:

void PLearn::SelectColumnsVMatrix::getValues ( const Vec input,
int  col,
Vec values 
) const [virtual]

Gives the possible values of a certain field (column) given the input.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 486 of file SelectColumnsVMatrix.cc.

References i, PLearn::TVec< T >::length(), PLERROR, PLearn::TVec< T >::resize(), sel_indices, sinput, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
    int the_col;
    the_col = sel_indices[col];
    if (the_col == -1)
        values.resize(0);
    else
    {
        for(int i=0; i<sel_indices.length(); i++)
            sinput[sel_indices[i]] = input[i];
        source->getValues(sinput, the_col, values);
    }
}

Here is the call graph for this function:

void PLearn::SelectColumnsVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::GetInputVMatrix, PLearn::ShuffleColumnsVMatrix, and PLearn::VariableDeletionVMatrix.

Definition at line 206 of file SelectColumnsVMatrix.cc.

References PLearn::deepCopyField(), fields, indices, PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy(), sel_indices, and sinput.

Referenced by PLearn::VariableDeletionVMatrix::makeDeepCopyFromShallowCopy(), and PLearn::ShuffleColumnsVMatrix::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void PLearn::SelectColumnsVMatrix::reset_dimensions ( ) [inline, virtual]

In case the dimensions of an underlying VMat has changed, recompute it.

Reimplemented from PLearn::VMatrix.

Definition at line 118 of file SelectColumnsVMatrix.h.

References i, and PLERROR.

    {
        source->reset_dimensions(); length_=source->length();
        for (int i=0;indices.length();i++)
            if (indices[i]>=source->width())
                PLERROR("SelectColumnsVMatrix::reset_dimensions, underlying source not wide enough (%d>=%d)",
                        indices[i],source->width());
    }

Member Data Documentation

Definition at line 75 of file SelectColumnsVMatrix.h.

Referenced by declareOptions(), and getIndicesFromFields().

Definition at line 76 of file SelectColumnsVMatrix.h.

Referenced by build_(), declareOptions(), and getIndicesFromFields().

Definition at line 73 of file SelectColumnsVMatrix.h.

Referenced by build_(), and declareOptions().

Input vector for source VMatrix.

Definition at line 64 of file SelectColumnsVMatrix.h.

Referenced by build_(), getValues(), and makeDeepCopyFromShallowCopy().


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