Yes, your right, We should rather use just getEntry(x,y) and getRowDimension/getColumnDimension shouldn't we.


Phil Steitz wrote:
I understand what you are trying to do here and support the basic
idea, but I don't know if this will work in general. What happens
when we want to add a sparse matrix to a RealMatrixImpl? J made the
point that we can't always require getDataRef to be supported. Given
this, for the RealMatrixImp x RealMatrixImpl case, why not just cast
the RealMatrix operand to a RealMatrixImpl (since getDataRef is
defined there)?

I think we can use a strategy that doesn't require getDataRef now that you've jogged my memory.


This could be done with the current impl.  I don't
fully see the value of the additional interface.


Agreed, I'll change it in my work so the interface is unnecessary, it will look more like this:


Index: RealMatrixImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/linear/RealMatrixImpl.java,v
retrieving revision 1.32
diff -u -r1.32 RealMatrixImpl.java
--- RealMatrixImpl.java 10 Oct 2004 18:00:33 -0000 1.32
+++ RealMatrixImpl.java 11 Oct 2004 23:51:52 -0000
@@ -160,10 +160,9 @@
int rowCount = this.getRowDimension();
int columnCount = this.getColumnDimension();
double[][] outData = new double[rowCount][columnCount];
- double[][] mData = m.getData();
for (int row = 0; row < rowCount; row++) {
for (int col = 0; col < columnCount; col++) {
- outData[row][col] = data[row][col] + mData[row][col];
+ outData[row][col] = data[row][col] + m.getEntry(row,col);
}
}
return new RealMatrixImpl(outData);
@@ -184,10 +183,9 @@
int rowCount = this.getRowDimension();
int columnCount = this.getColumnDimension();
double[][] outData = new double[rowCount][columnCount];
- double[][] mData = m.getData();
for (int row = 0; row < rowCount; row++) {
for (int col = 0; col < columnCount; col++) {
- outData[row][col] = data[row][col] - mData[row][col];
+ outData[row][col] = data[row][col] - m.getEntry(row,col);
}
}
return new RealMatrixImpl(outData);
@@ -242,14 +240,13 @@
int nRows = this.getRowDimension();
int nCols = m.getColumnDimension();
int nSum = this.getColumnDimension();
- double[][] mData = m.getData();
double[][] outData = new double[nRows][nCols];
double sum = 0;
for (int row = 0; row < nRows; row++) {
for (int col = 0; col < nCols; col++) {
sum = 0;
for (int i = 0; i < nSum; i++) {
- sum += data[row][i] * mData[i][col];
+ sum += data[row][i] * m.getEntry(i,col);
}
outData[row][col] = sum;
}
@@ -715,16 +712,14 @@
int nColB = b.getColumnDimension();
int nRowB = b.getRowDimension();


-        // Apply permutations to b
-        double[][] bv = b.getData();
+        // Apply permutations to b\
         double[][] bp = new double[nRowB][nColB];
         for (int row = 0; row < nRowB; row++) {
             for (int col = 0; col < nColB; col++) {
-                bp[row][col] = bv[permutation[row]][col];
+                bp[row][col] = b.getEntry(permutation[row],col);
             }
         }
-        bv = null;
-
+
         // Solve LY = b
         for (int col = 0; col < nCol; col++) {
             for (int i = col + 1; i < nCol; i++) {

-Mark

--
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to