Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 48877 invoked from network); 14 Dec 2008 17:38:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Dec 2008 17:38:12 -0000 Received: (qmail 72418 invoked by uid 500); 14 Dec 2008 17:38:19 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 72085 invoked by uid 500); 14 Dec 2008 17:38:19 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 71922 invoked by uid 99); 14 Dec 2008 17:38:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Dec 2008 09:38:18 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Dec 2008 17:38:04 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7E83B234C3C9 for ; Sun, 14 Dec 2008 09:37:44 -0800 (PST) Message-ID: <1309459096.1229276264517.JavaMail.jira@brutus> Date: Sun, 14 Dec 2008 09:37:44 -0800 (PST) From: "Ismael Juma (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (MATH-230) Implement Sparse Matrix Support In-Reply-To: <108625321.1228076264569.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12656416#action_12656416 ] Ismael Juma commented on MATH-230: ---------------------------------- Thanks, that is indeed what I meant by the API. I didn't have a chance to look at the implementation in detail, but seems right. > Implement Sparse Matrix Support > ------------------------------- > > Key: MATH-230 > URL: https://issues.apache.org/jira/browse/MATH-230 > Project: Commons Math > Issue Type: Improvement > Affects Versions: 2.0 > Environment: N/A > Reporter: Sujit Pal > Assignee: Luc Maisonobe > Priority: Minor > Fix For: 2.0 > > Attachments: math-230.diff, patch-2.txt, RealMatrixImplPerformanceTest.java, SparseRealMatrix.java, SparseRealMatrixTest.java > > > I needed a way to deal with large sparse matrices using commons-math RealMatrix, so I implemented it. The SparseRealMatrixImpl is a subclass of RealMatrixImpl, and the backing data structure is a Map, where Point is a struct like inner-class which exposes two int parameters row and column. I had to make some changes to the existing components to keep the code for SparseRealMatrixImpl clean. Here are the details. > 1) RealMatrix.java: > - added a new method setEntry(int, int, double) to set data into a matrix > 2) RealMatrixImpl.java: > - changed all internal calls to data[i][j] to getEntry(i,j). > - for some methods such as add(), subtract(), premultiply(), etc, there > was code that checked for ClassCastException and had two versions, > one for a generic RealMatrix and one for a RealMatrixImpl. This has > been changed to have only one that operates on a RealMatrix. The > result is something like auto-type casting. So if: > RealMatrixImpl.add(RealMatrix) returns a RealMatrixImpl > SparseRealMatrixImpl.add(RealMatrix) returns a SparseRealMatrixImpl > 3) SparseRealMatrixImpl added as a subclass of RealMatrixImpl. > 4) LUDecompositionImpl changed to use a clone of the passed in RealMatrix > instead of its data[][] block, and now it uses clone.getEntry(row,col) > calls instead of data[row][col] calls. > 5) LUDecompositionImpl returned RealMatrixImpl for getL(), getU(), getP() > and solve(). It now returns the same RealMatrix impl that is passed > in through its constructor for these methods. > 6) New test for SparseRealMatrixImpl, mimics the tests in RealMatrixImplTest, > 7) New static method to create SparseRealMatrixImpl out of a double[][] in > MatrixUtils.createSparseRealMatrix(). > but using SparseRealMatrixImpl. > 8) Verified that all JUnit tests pass. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.