epfl.pdf
Class VectorPriorProb

java.lang.Object
  |
  +--epfl.pdf.VectorPriorProb
All Implemented Interfaces:
VectorReader

public class VectorPriorProb
extends java.lang.Object
implements VectorReader

A vector reader with prior probabilities. Each vector read in the underlying stream has an associated probability which is stored in priorProb. It uses the last vector component as a probability :
in.read() -> v(size components ..., prior probability)
and returns a new vector whose size is one less.


Constructor Summary
VectorPriorProb(VectorReader in)
          Creates a new vector reader.
 
Method Summary
 void close()
          Closes the stream
 int period()
          Returns the stream period
 double priorProb()
          Returns the prior probability from the current read vector
 double[] read()
          Reads a vector in stream
 int size()
          Returns the stream size (vector size)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorPriorProb

public VectorPriorProb(VectorReader in)
Creates a new vector reader.
Parameters:
in - the underlying vector reader
The stream size is equal to in.size() - 1
The prior probability is always read in last component.
Method Detail

read

public double[] read()
              throws java.io.IOException
Reads a vector in stream
Specified by:
read in interface VectorReader
Throws:
java.io.IOException - if the stream is closed or if it is unable to read size doubles

priorProb

public double priorProb()
Returns the prior probability from the current read vector

size

public int size()
Returns the stream size (vector size)
Specified by:
size in interface VectorReader

period

public int period()
Returns the stream period
Specified by:
period in interface VectorReader
Returns:
0 if the stream is not periodic

close

public void close()
           throws java.io.IOException
Closes the stream
Specified by:
close in interface VectorReader
Throws:
java.io.IOException - an IO error occurs