Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 75593 invoked from network); 11 Oct 2004 19:10:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 11 Oct 2004 19:10:19 -0000 Received: (qmail 82544 invoked by uid 500); 11 Oct 2004 19:10:14 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 82431 invoked by uid 500); 11 Oct 2004 19:10:14 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 82418 invoked by uid 99); 11 Oct 2004 19:10:13 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [140.247.210.252] (HELO latte.harvard.edu) (140.247.210.252) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 11 Oct 2004 12:10:13 -0700 Received: from [192.168.1.3] (65-78-25-110.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com [::ffff:65.78.25.110]) (AUTH: PLAIN mdiggory, SSL: TLSv1/SSLv3,128bits,RC4-MD5) by latte.harvard.edu with esmtp; Mon, 11 Oct 2004 15:10:08 -0400 Message-ID: <416ADA90.6050305@latte.harvard.edu> Date: Mon, 11 Oct 2004 15:10:08 -0400 From: "Mark R. Diggory" Reply-To: mark_diggory@harvard.edu User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [math] RealMatrixImpl changes was: RE: cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/linear RealMatrixImplTest.java References: <95F1CCA52E317C49AB7AA71B16E8988B0C2396@mail2.tsd.biz> <416AD8C1.9000109@latte.harvard.edu> In-Reply-To: <416AD8C1.9000109@latte.harvard.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Phil, Heres a patch that shows the changes which would solve this copying issue in the current RealMatrixImpl. 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 19:09:03 -0000 @@ -48,7 +48,7 @@ * * @version $Revision: 1.32 $ $Date: 2004/10/10 18:00:33 $ */ -public class RealMatrixImpl implements RealMatrix, Serializable { +public class RealMatrixImpl implements RealMatrix, InternalMatrixSupport, Serializable { /** Serializable version identifier */ static final long serialVersionUID = 4237564493130426188L; @@ -160,7 +160,7 @@ int rowCount = this.getRowDimension(); int columnCount = this.getColumnDimension(); double[][] outData = new double[rowCount][columnCount]; - double[][] mData = m.getData(); + double[][] mData = ((InternalMatrixSupport)m).getDataRef(); for (int row = 0; row < rowCount; row++) { for (int col = 0; col < columnCount; col++) { outData[row][col] = data[row][col] + mData[row][col]; @@ -184,7 +184,7 @@ int rowCount = this.getRowDimension(); int columnCount = this.getColumnDimension(); double[][] outData = new double[rowCount][columnCount]; - double[][] mData = m.getData(); + double[][] mData = ((InternalMatrixSupport)m).getDataRef(); for (int row = 0; row < rowCount; row++) { for (int col = 0; col < columnCount; col++) { outData[row][col] = data[row][col] - mData[row][col]; @@ -242,7 +242,7 @@ int nRows = this.getRowDimension(); int nCols = m.getColumnDimension(); int nSum = this.getColumnDimension(); - double[][] mData = m.getData(); + double[][] mData = ((InternalMatrixSupport)m).getDataRef(); double[][] outData = new double[nRows][nCols]; double sum = 0; for (int row = 0; row < nRows; row++) { @@ -716,7 +716,7 @@ int nRowB = b.getRowDimension(); // Apply permutations to b - double[][] bv = b.getData(); + double[][] bv = ((InternalMatrixSupport)b).getDataRef(); double[][] bp = new double[nRowB][nColB]; for (int row = 0; row < nRowB; row++) { for (int col = 0; col < nColB; col++) { Index: InternalMatrixSupport.java =================================================================== RCS file: InternalMatrixSupport.java diff -N InternalMatrixSupport.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ InternalMatrixSupport.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/* + * Created on Oct 11, 2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.apache.commons.math.linear; + +/** + * @author Administrator + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public interface InternalMatrixSupport { + + /** + * Returns a reference to the underlying data array. + *

+ * Does not make a fresh copy of the underlying data. + * + * @return 2-dimensional array of entries + */ + public double[][] getDataRef(); + +} --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org