commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kim van der Linde <...@kimvdlinde.com>
Subject I messed uo: was [math] RC2 Release Plan
Date Mon, 04 Oct 2004 13:46:34 GMT
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message