Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
/**
 * Basic vector interface.
 */
public interface Vector {

  /**
   * Size of the vector
   * 
   * @return size of the vector
   */
  public int size();

  /**
   * Gets the value of index
   * 
   * @param index
   * @return v(index)
   */
  public double get(int index);

  /**
   * Sets the value of index
   * 
   * @param index
   * @param value
   */
  public void set(int index, double value);

  /**
   * Sets the vector
   * 
   * @param v
   * @return x = v
   */
  public Vector set(Vector v);

  /**
   * Addsx the= valuealpha to* v(index)
   * 
   * @param indexalpha
   * @param value v
   * @return x = alpha * v
   */
  public voidVector addset(intdouble indexalpha, doubleVector valuev);
  
  /**
   * xAdds =the alpha*vvalue + xto v(index)
   * 
   * @param alphaindex
   * @param v
   * @return x = alpha*v + x
   *value
   */
  public Vectorvoid add(doubleint alphaindex, Vectordouble vvalue);

  /**
   * x = alpha*v + x
   * 
   * @param alpha
   * @param v
   * @return x = alpha*v + x
   */
  public Vector add(double alpha, Vector v);

  /**
   * x dot= v + x
   * 
   * @param v
   * @return x dot= v
 + x
   */
  public doubleVector dotadd(Vector v);

  /**
   * vx =dot alpha*v 
   * 
   * @param alphav
   * @return vx =dot alpha*v
   */
  public Vectordouble scaledot(doubleVector alphav);
  
  /**
   * v Returns= a sub-vector.alpha*v 
   * 
   * @param i0alpha
 the index of* the@return firstv element
=   * @param i1 the index of the last element
   * @return v[i0:i1]alpha*v
   */
  public Vector subVectorscale( int i0, int i1 double alpha); 
  
  /**
   * ComputesReturns the given norm of the vectora sub-vector.
   * 
   * @param typei0 the index of the first element
   * @param i1 the index of the last element
   * @return v[i0:i1]
   */
  public Vector subVector( int i0, int i1 ); 
  
  /**
   * Computes the given norm of the vector
   * 
   * @param type
   * @return norm of the vector
   */
  public double norm(Norm type);

  /**
   * Supported vector-norms.
   */
  enum Norm {

    /** Sum of the absolute values of the entries */
    One,

    /** The root of sum of squares */
    Two,

    /**
 The robust norm of *the Asvector the*/
 2 norm may overflowTwoRobust,

 an overflow resistant version/** isLargest also
entry in absolute value */
 * available. Note thatInfinity
 it may}

 be slower./**
   * Returns an */iterator
   * TwoRobust,

    /** Largest@return entryiterator
 in absolute value */
  public Iterator<Writable> Infinityiterator();
  }

  /**
   * Returns the an iterator{@link org.apache.hadoop.io.MapWritable}
   * 
   * @return iterator the entries of vector
   */
  public Iterator<Writable>MapWritable iteratorgetEntries();
}

Matrix

No Format
/**
 * Basic matrix interface.
 */
public interface Matrix {

  /**
   * Gets the double value of (i, j)
   * 
   * @param i ith row of the matrix
   * @param j jth column of the matrix
   * @return the value of entry
   * @throws IOException
   */
  public double get(int i, int j) throws IOException;

  /**
   * Gets the vector of row
   * 
   * @param i the row index of the matrix
   * @return the vector of row
   * @throws IOException
   */
  public Vector getRow(int i) throws IOException;

  /**
   * Gets the vector of column
   * 
   * @param j the column index of the matrix
   * @return the vector of column
   * @throws IOException
   */
  public Vector getColumn(int j) throws IOException;

  /**
   * Get the number of row of the matrix from the meta-data column
   * 
   * @return a number of rows of the matrix
   * @throws IOException
   */
  public int getRows() throws IOException;

  /**
   * Get the number of column of the matrix from the meta-data column
   * 
   * @return a number of columns of the matrix a number of columns of the matrix
   * @throws IOException
   */
  public int getColumns() throws IOException;

  /**
   * Gets the label of the row
   * 
   * @throws IOException
   */
  public String getRowLabel(int getColumns(i) throws IOException;

  /**
   * Gets the label of the rowcolumn
   * 
   * @throws IOException
   */
  public String getRowLabelgetColumnLabel(int ij) throws IOException;

  /**
   * Gets the label of the column /**
   * Return the matrix path. 
   * (in hbase, path is the tablename. in filesystem, path may be a file path.)
   * 
   * @throws IOException @return the name of the matrix
   */
  public String getColumnLabelgetPath(int j) throws IOException;

  /**
   * Return the matrix path. 
   * (inSets hbase,the pathlabel isof the row
 tablename. in filesystem,* path
 may be a* file@param path.)i
   * @param name
   * @return the name of the matrix@throws IOException
   */
  public void setRowLabel(int i, String getPath() name) throws IOException;

  /**
   * Sets the label of the rowcolumn
   * 
   * @param ij
   * @param name
   * @throws IOException
   */
  public void setRowLabelsetColumnLabel(int ij, String name) throws IOException;

  /**
   * Sets the double labelvalue of the column(i, j)
   * 
   * @param i ith row of the matrix
   * @param j jth column of the matrix
   * @param name value the value of entry
   * @throws IOException
   */
  public void setColumnLabelset(int i, int j, Stringdouble namevalue) throws IOException;

  /**
   * Sets the double value of (i, j)
   * A=alpha*B
   * @param i ith row of the matrix
   * @param j jth column of the matrixalpha
   * @param B
 value the value* of@return entryA
   * @throws IOException
   */
  public voidMatrix set(intdouble ialpha, int j, double valueMatrix B) throws IOException;

  /**
   * A=alpha*B
   * 
   * @param alpha
   * @param B
   * @return A
   * @throws IOException
   */
  public Matrix set(double alpha, Matrix B) throws IOException;

  /**
   * Set  /**
   * A=Bthe row of a matrix to a given vector
   * 
   * @param Brow
   * @return@param Avector
   * @throws IOException
   */
  public Matrixvoid set(Matrix BsetRow(int row, Vector vector) throws IOException;

  /**
   * Set the rowcolumn of a matrix to a given vector
   * 
   * @param rowcolumn
   * @param vector
   * @throws IOException
   */
  public void setRowsetColumn(int rowcolumn, Vector vector) throws IOException;

  /**
   * SetSets the columndimension of a matrix to a given vector
   *  matrix
   * 
   * @param rows the number of rows
   * @param column
columns the number *of @param vectorcolumns
   * @throws IOException
   */
  public void setColumnsetDimension(int columnrows, Vectorint vectorcolumns) throws IOException;

  /**
   * Sets the dimension of matrixA(i, j) += value
   * 
   * @param i
 rows the number* of@param rowsj
   * @param columns the number of columnsvalue
   * @throws IOException
   */
  public void setDimensionadd(int rowsi, int j, double columnsvalue) throws IOException;

  /**
   * A(i, j) += value
B +  * A
   * @param i
   * @param jB
   * @param@return valueA
   * @throws IOException
   */
  public voidMatrix add(int i, int j, double valueMatrix B) throws IOException;

  /**
   * A = B + A alpha*B + A
   * 
   * @param alpha
   * @param B
   * @return A
   * @throws IOException
   */
  public Matrix add(double alpha, Matrix B) throws IOException;

  /**
   * AC = alphaA*B + A
   * 
   * @param alpha
   * @param B
   * @return AC
   * @throws IOException
   */
  public Matrix addmult(double alpha, Matrix B) throws IOException;

  /**
   * C = alpha*A*B + C
   * 
   * @param alpha
   * @param B
   * @param BC
   * @return C
   * @throws IOException
   */
  public Matrix multmultAdd(double alpha, Matrix B, Matrix C) throws IOException;

  /**
   * CComputes = alpha*A*B + C
   * the given norm of the matrix
   * @param alpha
   * @param Btype
   * @param@return C
norm of the * @return Cmatrix
   * @throws IOException
   */
  public Matrix multAdd(double alpha, Matrixpublic B, Matrix Cdouble norm(Norm type) throws IOException;

  /**
   * Computes the given norm of the matrix
   * 
   * @param type
   * @return norm Supported matrix-norms.
   */
  enum Norm {
    /** Maximum absolute row sum */
    One,

    /** The root of sum of the matrix
sum of squares * @throws/
 IOException
   */Frobenius,
  public double norm(Norm
 type) throws IOException;

  /**
 Largest entry in *absolute Supported matrix-norms.
value */
    */Infinity,
  enum Norm {
    /** Largest entry in absolute value.  */
    InfinityMaxvalue
  }

  /**
   * Save to a table or file
   * 
   * @param path
   * @return true if saved
   * @throws IOException
   */
  public boolean save(String path) throws IOException;

  /**
   * Returns the matrix type
   * 
   * @return the matrix type
   */
  public String getType();

  /**
   * Returns the sub matrix formed by selecting certain rows and
   * columns from a bigger matrix. The sub matrix is a in-memory operation only.
   * 
   * @param i0 the start index of row
   * @param i1 the end index of row
   * @param j0 the start index of column
   * @param j1 the end index of column
   * @return the sub matrix of matrix
   * @throws IOException
   */
  public SubMatrix subMatrix(int i0, int i1, int j0, int j1) throws IOException;

  /**
   * Close current matrix.
   * 
   * @throws Exception
   */
  public void close() throws IOException;
}