commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r771266 - in /commons/proper/math/trunk/src/java/org/apache/commons/math/linear: SparseFieldMatrix.java SparseFieldVector.java
Date Mon, 04 May 2009 10:42:16 GMT
Author: luc
Date: Mon May  4 10:42:16 2009
New Revision: 771266

URL: http://svn.apache.org/viewvc?rev=771266&view=rev
Log:
minor style fixes (braces, javadoc ...)

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldMatrix.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldVector.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldMatrix.java?rev=771266&r1=771265&r2=771266&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldMatrix.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldMatrix.java
Mon May  4 10:42:16 2009
@@ -44,7 +44,7 @@
     
 
     /**
-     * Creates a matrix with no data
+     * Creates a matrix with no data.
      * @param field field to which the elements belong
      */
     public SparseFieldMatrix(final Field<T> field) {
@@ -63,7 +63,7 @@
      * @throws IllegalArgumentException if row or column dimension is not positive
      */
     public SparseFieldMatrix(final Field<T> field,
-                                  final int rowDimension, final int columnDimension)
+                             final int rowDimension, final int columnDimension)
         throws IllegalArgumentException {
         super(field, rowDimension, columnDimension);
         this.rowDimension = rowDimension;
@@ -72,10 +72,10 @@
     }
     
     /**
-     * Copy construtor.
+     * Copy constructor.
      * @param other The instance to copy
      */
-    public SparseFieldMatrix(SparseFieldMatrix<T> other){
+    public SparseFieldMatrix(SparseFieldMatrix<T> other) {
         super(other.getField(), other.getRowDimension(), other.getColumnDimension());
         rowDimension = other.getRowDimension();
         columnDimension = other.getColumnDimension();
@@ -83,7 +83,7 @@
     }
 
     /**
-     * Generic copy construtor.
+     * Generic copy constructor.
      * @param other The instance to copy
      */
     public SparseFieldMatrix(FieldMatrix<T> other){
@@ -91,8 +91,8 @@
         rowDimension = other.getRowDimension();
         columnDimension = other.getColumnDimension();
         entries = new OpenIntToFieldHashMap<T>(getField());
-        for(int i=0; i < rowDimension; i++){
-            for(int j=0; j < columnDimension; j++){
+        for (int i = 0; i < rowDimension; i++) {
+            for (int j = 0; j < columnDimension; j++) {
                 setEntry(i, j, other.getEntry(i, j));
             }
         }

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldVector.java?rev=771266&r1=771265&r2=771266&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldVector.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseFieldVector.java
Mon May  4 10:42:16 2009
@@ -43,7 +43,7 @@
 
     /**
      * Build a 0-length vector.
-     * <p>Zero-length vectors may be used to initialized construction of vectors
+     * <p>Zero-length vectors may be used to initialize construction of vectors
      * by data gathering. We start with zero-length and use either the {@link
      * #SparseFieldVector(SparseFieldVector<T>, int)} constructor
      * or one of the <code>append</code> method ({@link #append(Field<T>)},
{@link
@@ -87,7 +87,7 @@
     public SparseFieldVector(Field<T> field, int dimension, int expectedSize) {
         this.field = field;
         virtualSize = dimension;
-        entries = new OpenIntToFieldHashMap<T> (field,expectedSize);
+        entries = new OpenIntToFieldHashMap<T>(field,expectedSize);
     }
 
     /**
@@ -127,10 +127,10 @@
     }
     
     /**
-     * Optimzed method to add sparse vectors
+     * Optimized method to add sparse vectors.
      * @return The sum of <code>this</code> and <code>v</code>
      * @throws IllegalArgumentException If the dimensions don't match
-*/
+     */
     public FieldVector<T> add(SparseFieldVector<T> v) throws IllegalArgumentException
{
         checkVectorDimensions(v.getDimension());
         SparseFieldVector<T> res = (SparseFieldVector<T>)copy();
@@ -173,11 +173,11 @@
 
     /** {@inheritDoc} */
     public FieldVector<T> append(FieldVector<T> v) {
-        if(v instanceof SparseFieldVector)
-            return append((SparseFieldVector<T>)v);
-        else
+        if (v instanceof SparseFieldVector) {
+            return append((SparseFieldVector<T>) v);
+        } else {
             return append(v.toArray());
-            
+        }   
     }
 
     /** {@inheritDoc} */
@@ -231,7 +231,7 @@
 
     /** {@inheritDoc} */
     public FieldVector<T> ebeDivide(FieldVector<T> v)
-            throws IllegalArgumentException {
+        throws IllegalArgumentException {
         checkVectorDimensions(v.getDimension());
         SparseFieldVector<T> res = new SparseFieldVector<T>(this);
         OpenIntToFieldHashMap<T>.Iterator iter = res.entries.iterator();
@@ -390,7 +390,7 @@
     }
 
      /**
-      * Optimized method to compute outer product when both vectors are sparse
+      * Optimized method to compute outer product when both vectors are sparse.
       * @param v vector with which outer product should be computed
       * @return the square matrix outer product between instance and v
       * @throws IllegalArgumentException if v is not the same size as {@code this}
@@ -436,6 +436,7 @@
             return outerProduct(v.toArray());
     }
 
+    /** {@inheritDoc} */
     public FieldVector<T> projection(FieldVector<T> v)
     throws IllegalArgumentException {
         checkVectorDimensions(v.getDimension());
@@ -564,10 +565,11 @@
 
     /** {@inheritDoc} */
     public FieldVector<T> add(FieldVector<T> v) throws IllegalArgumentException
{
-        if(v instanceof SparseFieldVector)
+        if (v instanceof SparseFieldVector) {
             return add((SparseFieldVector<T>)v);
-        else
+        } else {
             return add(v.toArray());
+        }
     }
 
     /** Build an array of elements.
@@ -598,22 +600,34 @@
 
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+
+        if (obj == null) {
             return false;
-        if (!(obj instanceof SparseFieldVector))
+        }
+
+        if (!(obj instanceof SparseFieldVector)) {
             return false;
+        }
+
         SparseFieldVector<T> other = (SparseFieldVector<T>) obj;
         if (field == null) {
-            if (other.field != null)
+            if (other.field != null) {
                 return false;
-        } else if (!field.equals(other.field))
+            }
+        } else if (!field.equals(other.field)) {
             return false;
-        if (virtualSize != other.virtualSize)
+        }
+        if (virtualSize != other.virtualSize) {
             return false;
+        }
+
         OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
         while (iter.hasNext()) {
             iter.advance();



Mime
View raw message