Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 845 invoked from network); 10 Oct 2004 18:00:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Oct 2004 18:00:39 -0000 Received: (qmail 90531 invoked by uid 500); 10 Oct 2004 18:00:36 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 90420 invoked by uid 500); 10 Oct 2004 18:00:35 -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 90407 invoked by uid 500); 10 Oct 2004 18:00:35 -0000 Received: (qmail 90404 invoked by uid 99); 10 Oct 2004 18:00:35 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 10 Oct 2004 11:00:35 -0700 Received: (qmail 741 invoked by uid 1718); 10 Oct 2004 18:00:33 -0000 Date: 10 Oct 2004 18:00:33 -0000 Message-ID: <20041010180033.738.qmail@minotaur.apache.org> From: psteitz@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/linear RealMatrixImpl.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N psteitz 2004/10/10 11:00:33 Modified: math/src/java/org/apache/commons/math/linear RealMatrixImpl.java Log: Formatting, javadoc, plus fix for toString to handle empty matrix. Revision Changes Path 1.32 +21 -19 jakarta-commons/math/src/java/org/apache/commons/math/linear/RealMatrixImpl.java Index: RealMatrixImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/linear/RealMatrixImpl.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- RealMatrixImpl.java 10 Oct 2004 05:23:16 -0000 1.31 +++ RealMatrixImpl.java 10 Oct 2004 18:00:33 -0000 1.32 @@ -88,15 +88,15 @@ } /** - * Create a new RealMatrix using the data as the underlying + * Create a new RealMatrix using the input array as the underlying * data array. *

* The input array is copied, not referenced. * * @param d data for new matrix - * @throws IllegalArgumentException if data is not rectangular (not all - * rows have the same length) or data is empty - * @throws NullPointerException if data is null + * @throws IllegalArgumentException if data is not rectangular + * (not all rows have the same length) or empty + * @throws NullPointerException if data is null */ public RealMatrixImpl(double[][] d) { int nRows = d.length; @@ -344,9 +344,9 @@ */ public RealMatrix getSubMatrix(int startRow, int endRow, int startColumn, int endColumn) throws MatrixIndexException { - if (startRow < 0 || startRow > endRow || endRow > data.length - || startColumn < 0 || startColumn > endColumn - || endColumn > data[0].length ) { + if (startRow < 0 || startRow > endRow || endRow > data.length || + startColumn < 0 || startColumn > endColumn || + endColumn > data[0].length ) { throw new MatrixIndexException( "invalid row or column index selection"); } @@ -849,20 +849,22 @@ public String toString() { StringBuffer res = new StringBuffer(); res.append("RealMatrixImpl{"); - for (int i = 0; i < data.length; i++) { - if (i > 0) - res.append(","); - res.append("{"); - for (int j = 0; j < data[0].length; j++) { - if (j > 0) + if (data != null) { + for (int i = 0; i < data.length; i++) { + if (i > 0) res.append(","); - res.append(data[i][j]); - } //for - res.append("}"); - } //for + res.append("{"); + for (int j = 0; j < data[0].length; j++) { + if (j > 0) + res.append(","); + res.append(data[i][j]); + } + res.append("}"); + } + } res.append("}"); return res.toString(); - } //toString + } /** * Returns true iff object is a --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org