DenseMatrix.getRow() and getColumn() return deep copies of the data
-------------------------------------------------------------------

                 Key: MAHOUT-211
                 URL: https://issues.apache.org/jira/browse/MAHOUT-211
             Project: Mahout
          Issue Type: Bug
          Components: Matrix
    Affects Versions: 0.1
         Environment: all
            Reporter: Jake Mannix
            Priority: Minor
             Fix For: 0.3


As mentioned in the summary, DenseMatrix.getRow() returns a new 
DenseVector(values[row]) instead of just a shallow reference.  This is a) 
wasteful, and b) inconsistent with what SparseRowMatrix / SparseColumnMatrix 
do, which means that users who think they can mutate rows by calling getRow() 
are wrong for DenseMatrix, or conversely think they can modify the row at will 
are wrong for SparseRowMatrix.  

Either way, we need to be consistent.  I would suggest the contract be that you 
get a shallow view reference (meaning, it may be an actual reference to a real 
Vector, or it may be a virtual Vector, dynamically constructed, which is still 
backed by entries in the matrix), so that calling Matrix.getRow(row).set(col, 
value) has the same affect as Matrix.set(row, col, value).  If we don't do it 
this way, we should at least provide an api to get a shallow reference to rows.

Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to