lcsim/src/Jama
diff -u -r1.3 -r1.4
--- Matrix.java 19 Oct 2005 10:33:04 -0000 1.3
+++ Matrix.java 27 Jun 2006 01:51:39 -0000 1.4
@@ -50,7 +50,7 @@
</DL>
@author The MathWorks, Inc. and the National Institute of Standards and Technology.
-@version 5 August 1998 $Id: Matrix.java,v 1.3 2005/10/19 10:33:04 jstrube Exp $
+@version 5 August 1998 $Id: Matrix.java,v 1.4 2006/06/27 01:51:39 jstrube Exp $
*/
public class Matrix implements Cloneable, java.io.Serializable {
@@ -248,23 +248,23 @@
return vals;
}
- /** Get row dimension.
- @return m, the number of rows.
+ /**
+ @return the number of rows.
*/
public int getRowDimension () {
return m;
}
- /** Get column dimension.
- @return n, the number of columns.
+ /**
+ @return the number of columns.
*/
public int getColumnDimension () {
return n;
}
- /** Get a single element.
+ /**
@param i Row index.
@param j Column index.
@return A(i,j)
@@ -275,7 +275,7 @@
return A[i][j];
}
- /** Get a submatrix.
+ /** Returns a submatrix.
@param i0 Initial row index
@param i1 Final row index
@param j0 Initial column index
@@ -299,7 +299,7 @@
return X;
}
- /** Get a submatrix.
+ /** Returns a submatrix.
@param r Array of row indices.
@param c Array of column indices.
@return A(r(:),c(:))
@@ -321,7 +321,7 @@
return X;
}
- /** Get a submatrix.
+ /** Returns a submatrix.
@param i0 Initial row index
@param i1 Final row index
@param c Array of column indices.
@@ -344,7 +344,7 @@
return X;
}
- /** Get a submatrix.
+ /** Returns a submatrix.
@param r Array of row indices.
@param j0 Initial column index
@param j1 Final column index
@@ -367,7 +367,7 @@
return X;
}
- /** Set a single element.
+ /** Sets a single element.
@param i Row index.
@param j Column index.
@param s A(i,j).
@@ -378,7 +378,7 @@
A[i][j] = s;
}
- /** Set a submatrix.
+ /** Sets a submatrix.
@param i0 Initial row index
@param i1 Final row index
@param j0 Initial column index
@@ -399,7 +399,7 @@
}
}
- /** Set a submatrix.
+ /** Sets a submatrix.
@param r Array of row indices.
@param c Array of column indices.
@param X A(r(:),c(:))
@@ -418,7 +418,7 @@
}
}
- /** Set a submatrix.
+ /** Sets a submatrix.
@param r Array of row indices.
@param j0 Initial column index
@param j1 Final column index
@@ -438,7 +438,7 @@
}
}
- /** Set a submatrix.
+ /** Sets a submatrix.
@param i0 Initial row index
@param i1 Final row index
@param c Array of column indices.
@@ -458,8 +458,9 @@
}
}
- /** Matrix transpose.
- @return A'
+ /**
+ * Returns the transpose of the matrix. The elements of this matrix remain unchanged.
+ * @return a new matrix A<sup>T</sup>
*/
public Matrix transpose () {
@@ -760,6 +761,24 @@
}
return X;
}
+
+ /**
+ * Calculates the vector y = A.x
+ * @param x
+ * @return a new vector y
+ */
+ public double[] times(double[] x) {
+ if (n != x.length)
+ throw new IllegalArgumentException("dimensions do not match");
+ double[] result = new double[m];
+
+ for (int i=0; i<m; i++) {
+ for (int j=0; j<n; j++) {
+ result[i] += A[i][j] * x[j];
+ }
+ }
+ return result;
+ }
/** LU Decomposition
@return LUDecomposition