Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 5429 invoked from network); 4 Oct 2004 01:03:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 4 Oct 2004 01:03:40 -0000 Received: (qmail 48469 invoked by uid 500); 4 Oct 2004 01:03:36 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 48388 invoked by uid 500); 4 Oct 2004 01:03:36 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 48375 invoked by uid 99); 4 Oct 2004 01:03:36 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from [128.186.38.55] (HELO bio.fsu.edu) (128.186.38.55) by apache.org (qpsmtpd/0.28) with ESMTP; Sun, 03 Oct 2004 18:03:34 -0700 Received: from [146.201.34.234] (dial1384.acns.fsu.edu [146.201.34.234]) by bio.fsu.edu (8.12.6p2/8.12.6) with ESMTP id i941AmtI069380 for ; Sun, 3 Oct 2004 21:10:53 -0400 (EDT) (envelope-from kim@kimvdlinde.com) Message-ID: <4160A14E.4080200@kimvdlinde.com> Date: Sun, 03 Oct 2004 21:03:10 -0400 From: Kim van der Linde User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [math] RC2 Release Plan References: <41607255.3070500@steitz.com> In-Reply-To: <41607255.3070500@steitz.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-MailScanner: Found to be clean X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Phil, As I do not have any CVS set up, so I do it this way: > 4) Add the following new methods to both RealMatrix and BigMatrix > interfaces: > RealMatrix getSubMatrix (int startRow, int endRow, int startColumn, > int endColumn) > RealMatrix getSubMatrix (int[] rows, int[] columns) > RealMatrix getRowMatrix(int row) > RealMatrix getColumnMatrix(int row) > RealMatrix createRowMatrix(double[] row) > RealMatrix createColumnMatrix(double[] column) /** * 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 + 1, endColumn - startColumn + 1); 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; } /** * Get a submatrix. Rows and columns are indicated * counting from 0 to n-1. * * @param rows Array of row indices. * @param columns Array of column indices. * @return The subMatrix containing the data of the * specified rows and columns * @exception MatrixIndexException matrix dimension * mismatch */ public RealMatrix getSubMatrix(int[] selectedRows, int[] selectedColumns) throws MatrixIndexException { RealMatrix subMatrix = new RealMatrix(selectedRows.length, selectedColumns.length); double[][] subMatrixData = subMatrix.getDataRef(); try { for (int i = 0; i < selectedRows.length; i++) { for (int j = 0; j < selectedColumns.length; j++) { subMatrixData[i][j] = data[selectedRows[i]][selectedColumns[j]]; } } } catch (ArrayIndexOutOfBoundsException e) { throw new MatrixIndexException("matrix dimension mismatch"); } return subMatrix; } /** * Returns the entries in row number row * as a Matrix object. * * @param row the row to be fetched * @return RealMatrix with only one row * @throws MatrixIndexException if the specified row is * greater than the number of rows in this * matrix */ public Matrix getRowMatrix(int row) throws MatrixIndexException { if (!isValidCoordinate(row, 0)) { throw new MatrixIndexException( "illegal row argument"); } double[][] out = new double[1][columns]; for (int y = 0; y < columns; y++) { out[0][y] = data[row][y]; } return new RealMatrix (out); } /** * Returns the entries in column number col * as a RealMatrix object. * * @param col column to fetch * @return RealMatrix with only one column * @throws MatrixIndexException if the specified column * is greater than the number of columns in * this matrix */ public RealMatrix getColumnMatrix(int col) throws MatrixIndexException { if (!isValidCoordinate(0, col)) { throw new MatrixIndexException( "illegal row argument"); } double[][] out = new double[rows][1]; for (int y = 0; y < rows; y++) { out[y][0] = data[y][col]; } return new RealMatrix (out); } I do not have ready to use code for the last two methods. I might have missed to add some 'Real's before the Matrix names.... Cheers, Kim -- 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