PLearn 0.1
Public Member Functions | Protected Attributes
PLearn::IntStreamVMatrix Class Reference

#include <IntStream.h>

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

List of all members.

Public Member Functions

 IntStreamVMatrix ()
 IntStreamVMatrix (IntStream &s, int window_size, int dummy_input, int eos)
virtual void getRow (int i, Vec v) const
 These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine)

Protected Attributes

PP< IntStreamstream
 where the data actually is
int position
 position in the stream corresponding to the current window
int dummy_input
int end_of_sequence_symbol

Detailed Description

Definition at line 100 of file IntStream.h.


Constructor & Destructor Documentation

PLearn::IntStreamVMatrix::IntStreamVMatrix ( ) [inline]

Definition at line 116 of file IntStream.h.

{}
PLearn::IntStreamVMatrix::IntStreamVMatrix ( IntStream s,
int  window_size,
int  dummy_input,
int  eos 
)

Definition at line 55 of file IntStream.cc.

References PLearn::RowBufferedVMatrix::current_row, dummy_input, and PLearn::TVec< T >::fill().

    : RowBufferedVMatrix(s.size(),window_size), stream(&s), position(-1), 
      dummy_input(dummyinput), end_of_sequence_symbol(eos)
{
    current_row.fill(dummy_input);
}

Here is the call graph for this function:


Member Function Documentation

void PLearn::IntStreamVMatrix::getRow ( int  i,
Vec  v 
) const [virtual]

These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine)

Copies row i into v (which must have appropriate length equal to the VMat's width).

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 62 of file IntStream.cc.

References PLearn::RowBufferedVMatrix::current_row, dummy_input, end_of_sequence_symbol, i, j, PLERROR, position, stream, USE_JS_HACK, and PLearn::VMatrix::width().

{
    if (i==position+1) // most frequent case
    {
        int j=1;
        if (current_row[width()-1]==end_of_sequence_symbol)
        {
            for (;j<width()-1;j++) current_row[j-1]=dummy_input;
            current_row[j++ - 1]=end_of_sequence_symbol;
        }
        else
            for (;j<width();j++)
                current_row[j-1]=current_row[j];
#if USE_JS_HACK
        {
            real next=stream->next();
            if (next>=MAX_VOC_SIZE) next = MAX_VOC_SIZE-1;
            current_row[j-1] = next;
        }
#else
        current_row[j-1]=stream->next();
#endif
    }
    else if (i!=position) 
    {
        if (i>=width())
        {
            stream->seek(i-width()+1);
            for (int j=0;j<width();j++)
#if USE_JS_HACK
            {
                real next=stream->next();
                if (next>=MAX_VOC_SIZE) next = MAX_VOC_SIZE-1;
                current_row[j] = next;
            }
#else
            current_row[j]=stream->next();
#endif
        } else
        {
            if (i<0) PLERROR("IntStreamVMat::getRow at row %d < 0!",i);
            stream->seek(0);
            int j=0;
            for (;j<width()-i-1;j++)
                current_row[j]=dummy_input;
            for (;j<width();j++)
#if USE_JS_HACK
            {
                real next=stream->next();
                if (next>=MAX_VOC_SIZE) next = MAX_VOC_SIZE-1;
                current_row[j] = next;
            }
#else
            current_row[j]=stream->next();
#endif
        }
    }
    position=i;
    v << current_row;
}

Here is the call graph for this function:


Member Data Documentation

current_row is a window on the stream, with current_row[width()-1] being the element at position 'position' of the stream. Note also that the first width()-1 elements of current row when at position 0 or "end of sequence" are filled with a special value, dummy_input:

Definition at line 109 of file IntStream.h.

Referenced by getRow(), and IntStreamVMatrix().

When the end_of_sequence_symbol is encountered, the symbols that follow are "isolated" from the symbols that precede, i.e. when this symbol moves from element width()-1 to width()-1, the elements that precede are replaced by 'dummy_input'.

Definition at line 114 of file IntStream.h.

Referenced by getRow().

position in the stream corresponding to the current window

Definition at line 103 of file IntStream.h.

Referenced by getRow().

where the data actually is

Definition at line 102 of file IntStream.h.

Referenced by getRow().


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