Hi Phil,

I discovered this morning that I messed up the bug fix, it just created another. The correct code is here under....:

RealMatrix getSubMatrix (int startRow, int endRow, int startColumn,
int endColumn)


/**
 * Get a submatrix. Rows and columns are indicated
 * counting from 0 to n-1.
 *
 * @param startRow Initial row index
 * @param endRow Final row index
 * @param startColumn Initial column index
 * @param endColumn Final column index
 * @return The subMatrix containing the data of the
 *         specified rows and columns
 * @exception MatrixIndexException matrix dimension
 *                mismatch
 */
public RealMatrix getSubMatrix(int startRow, int endRow, int startColumn,
            int endColumn) throws MatrixIndexException
{
  RealMatrix subMatrix = new RealMatrix(endRow - startRow,
                                   endColumn - startColumn);
  double[][] subMatrixData = subMatrix.getDataRef();
  try
  {
    for (int i = startRow; i < endRow; i++)
    {
       for (int j = startColumn; j < endColumn; j++)
       {
         subMatrixData[i - startRow][j - startColumn] = data[i][j];
       }
    }
  }
  catch (ArrayIndexOutOfBoundsException e)
  {
    throw new MatrixIndexException("matrix dimension mismatch");
  }
  return subMatrix;
}

--
http://www.kimvdlinde.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to