PLearn 0.1
Public Member Functions | Private Types
PLearn::SDBVMFieldDay Class Reference

#include <SDBVMat.h>

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

List of all members.

Public Member Functions

 SDBVMFieldDay (SDBVMSource source, real missing_values_mapping=MISSING_VALUE)
virtual void convertField (const SDBWithStats &sdb, const Row &row, const Vec &output) const
virtual int fieldWidth () const
 Width that the field occupies in the VMat.

Private Types

typedef SDBVMFieldSource1 inherited

Detailed Description

Convert a date according to the formula: ((year - 1990)*365+(month-1)*30+(day-1))/3650 which is approximately in the range [-1,1] for (1980-2000)

Definition at line 521 of file SDBVMat.h.


Member Typedef Documentation

Reimplemented from PLearn::SDBVMFieldSource1.

Definition at line 523 of file SDBVMat.h.


Constructor & Destructor Documentation

PLearn::SDBVMFieldDay::SDBVMFieldDay ( SDBVMSource  source,
real  missing_values_mapping = MISSING_VALUE 
) [inline]

Definition at line 526 of file SDBVMat.h.

        : inherited(source,missing_values_mapping,VMField::Continuous) {}

Member Function Documentation

void PLearn::SDBVMFieldDay::convertField ( const SDBWithStats sdb,
const Row theRow,
const Vec outputField 
) const [virtual]

Given a database row, convert the appropriate parts to a (preallocated) output vector of the correct width (given by fieldWidth). Replace MISSING_VALUEs by missing_values_mapping.

Implements PLearn::SDBVMField.

Definition at line 470 of file SDBVMat.cc.

References PLearn::SDBVMField::convertMissing(), d, PLearn::PDate::day, PLearn::float_to_date(), PLearn::SDBVMSource::getValue(), PLearn::PDate::month, PLearn::SDBVMFieldSource1::source_, and PLearn::PDate::year.

{
    real realval = source_.getValue(sdb,row);
    PDate d = float_to_date(realval);
    // compute a normalized day ranging approximately in [-1,1]
    // for (1980 - 2000).
    output[0] = ((d.year-1990)*365+(d.month-1)*30+(d.day-1))/3650.0;
    convertMissing(output);
}

Here is the call graph for this function:

int PLearn::SDBVMFieldDay::fieldWidth ( ) const [virtual]

Width that the field occupies in the VMat.

Implements PLearn::SDBVMField.

Definition at line 481 of file SDBVMat.cc.

{
    return 1;
}

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