Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 25786 invoked from network); 27 Dec 2009 19:17:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Dec 2009 19:17:53 -0000 Received: (qmail 78849 invoked by uid 500); 27 Dec 2009 19:17:52 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 78752 invoked by uid 500); 27 Dec 2009 19:17:52 -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 78632 invoked by uid 99); 27 Dec 2009 19:17:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Dec 2009 19:17:52 +0000 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, 27 Dec 2009 19:17:50 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 72697234C04C for ; Sun, 27 Dec 2009 11:17:29 -0800 (PST) Message-ID: <1785907581.1261941449467.JavaMail.jira@brutus.apache.org> Date: Sun, 27 Dec 2009 19:17:29 +0000 (UTC) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Subject: [jira] Resolved: (MATH-312) RealVector interface could use some iterators (dense and sparse) and generic map() and collect() methods. In-Reply-To: <1073865216.1256802419429.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Phil Steitz resolved MATH-312. ------------------------------ Resolution: Fixed Looks good now. Thanks! > RealVector interface could use some iterators (dense and sparse) and generic map() and collect() methods. > --------------------------------------------------------------------------------------------------------- > > Key: MATH-312 > URL: https://issues.apache.org/jira/browse/MATH-312 > Project: Commons Math > Issue Type: New Feature > Affects Versions: 2.0 > Environment: all > Reporter: Jake Mannix > Fix For: 2.1 > > Attachments: MATH-312.patch, MATH-312.patch > > > As discussed on the [math] list, there are other projects out there which would love to get a chance to standardize on using commons-math for things like linear algebra primitives, as it would build a common base to build upon. But to do that, some well-known and used techniques for dealing with vectors, for one thing, are missing. Most glaringly is the treatment of sparse vectors: giving no Iterator for non-default values means external clients lose the advantage of sparseness - only internal methods can skip around. > Extending the RealVector interface with sparse (and dense) iterator methods would fix this: > {code} > double getDefaultValue(); > Iterator iterator(); > Iterator nonDefaultIterator(); > {code} > but there is another way to deal with vector data as well: instead of passing iterators around, and worrying about all the lovely ConcurrentModification and unsupported "remove" methods (which aren't the end of the world), we can instead expose generic map functions: > {code} > RealVector map(UnivariateRealFunction f); > RealVector mapToSelf(UnivariateRealFunction f); > {code} > where RealVector mapToSelf(UnivariateRealFunction), which applies the function to the vector's entries (checking whether the function preserves the default value up front allows it to chose between the sparse or dense iterator), and map just applies mapToSelf to a copy. > This doesn't exhaust all possible places where Iterators could be used helpfully (there's also combining two vectors together via a {code}map(BinaryRealFunction, RealVector other){code} which could be specialized nonlinear forms of addition or subtraction, and {code}double collect(UnivariateRealFunction, BinaryRealFunction){code} which uses the iterates over all of the entries, applying the first unary function to each entry, and then applying the binary function to combine this value with the previous accumulated value - with "pow(2)", and "+" as the two functions, you get L2 norm, with "abs()" and "+", you get L1 norm, etc...) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.