Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2060997C7 for ; Mon, 13 Aug 2012 01:05:39 +0000 (UTC) Received: (qmail 46242 invoked by uid 500); 13 Aug 2012 01:05:38 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 46149 invoked by uid 500); 13 Aug 2012 01:05:38 -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 46138 invoked by uid 99); 13 Aug 2012 01:05:38 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Aug 2012 01:05:38 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 214C12C5AC8 for ; Mon, 13 Aug 2012 01:05:38 +0000 (UTC) Date: Mon, 13 Aug 2012 12:05:38 +1100 (NCT) From: "Gilles (JIRA)" To: issues@commons.apache.org Message-ID: <1448274303.323.1344819938137.JavaMail.jiratomcat@arcas> In-Reply-To: <1598960295.13928.1311318538612.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (MATH-628) use only SparseIterator, on RealVectors, that implement SpareRealVectors MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-628?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:all-tabpanel ] Gilles updated MATH-628: ------------------------ Fix Version/s: (was: 3.1) 3.2 =20 > use only SparseIterator, on RealVectors, that implement SpareRealVectors= =20 > ------------------------------------------------------------------------- > > Key: MATH-628 > URL: https://issues.apache.org/jira/browse/MATH-628 > Project: Commons Math > Issue Type: Improvement > Reporter: Arne Pl=C3=B6se > Priority: Minor > Fix For: 3.2 > > Attachments: ArrayRealVector.diff > > > the performance suffers badly if one tries to use SparseIterator when the= re is no sparse backing. > Currently there is only a check for ArrayRealvector, all other is suppose= d to be a SparseRealvector. > If one creates a new implementation of RealVector ... bang. > here is a performance test case: > {code} > package org.apache.commons.math.linear; > import java.util.Iterator; > import org.junit.Test; > /** > * > * @author aploese > */ > public class PerformanceTest { > final static int ITER =3D 100; > final static int VECTOR_SIZE =3D 2048; > final static double SPARSE_FILL_STATE =3D 0.8; > @Test > public void performanceSparseVectorOpenMap() { > System.out.println("performanceSparseVectorOpenMap"); > RealVector v =3D new OpenMapRealVector(VECTOR_SIZE); > for (int i =3D 0; i < v.getDimension() * SPARSE_FILL_STATE; i++) = { > v.setEntry(i, i); > } > for (int j =3D 0; j < ITER; j++) { > long t1 =3D System.nanoTime(); > double a =3D 0; > Iterator it =3D v.sparseIterator(); > RealVector.Entry e; > while (it.hasNext() && (e =3D it.next()) !=3D null) { > a +=3D e.getValue(); > } > long t2 =3D System.nanoTime(); > for (int i =3D 0; i < v.getDimension(); i++) { > a +=3D v.getEntry(i); > } > long t3 =3D System.nanoTime(); > System.out.println(String.format("OpenMap: %d\t%s\t| %s", j, = Long.toString(t2 - t1), Long.toString(t3 - t2))); > } > } > @Test > public void performanceSparseVectorArray() { > System.out.println("performanceSparseVectorArray"); > RealVector v =3D new ArrayRealVector(VECTOR_SIZE); > for (int i =3D 0; i < v.getDimension() * SPARSE_FILL_STATE; i++) = { > v.setEntry(i, i); > } > for (int j =3D 0; j < ITER; j++) { > long t1 =3D System.nanoTime(); > double a =3D 0; > Iterator it =3D v.sparseIterator(); > RealVector.Entry e; > while (it.hasNext() && (e =3D it.next()) !=3D null) { > a +=3D e.getValue(); > } > long t2 =3D System.nanoTime(); > for (int i =3D 0; i < v.getDimension(); i++) { > a +=3D v.getEntry(i); > } > long t3 =3D System.nanoTime(); > System.out.println(String.format("Array: %d\t%s\t| %s", j, Lo= ng.toString(t2 - t1), Long.toString(t3 - t2))); > } > } > {code} > Patch will follow. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira