commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/linear RealMatrixImpl.java
Date Sun, 10 Oct 2004 18:00:33 GMT
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 <code>data</code> as the underlying
  +     * Create a new RealMatrix using the input array as the underlying
        * data array.
        * <p>
        * 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 <code>data</code> is not rectangular
  +     *  (not all rows have the same length) or empty
  +     * @throws NullPointerException if <code>data</code> 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 <code>object</code> is a 
  
  
  

---------------------------------------------------------------------
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