Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B8500200B11 for ; Mon, 30 May 2016 00:57:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id AC086160A2C; Sun, 29 May 2016 22:57:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F08D7160A07 for ; Mon, 30 May 2016 00:57:13 +0200 (CEST) Received: (qmail 73375 invoked by uid 500); 29 May 2016 22:57:13 -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 73364 invoked by uid 99); 29 May 2016 22:57:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 May 2016 22:57:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id E40D12C1F5A for ; Sun, 29 May 2016 22:57:12 +0000 (UTC) Date: Sun, 29 May 2016 22:57:12 +0000 (UTC) From: "Gilles (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (MATH-1170) Add more in-place operations to RealMatrix and RealVector MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sun, 29 May 2016 22:57:14 -0000 [ https://issues.apache.org/jira/browse/MATH-1170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Gilles resolved MATH-1170. -------------------------- Resolution: Incomplete Old issue, no patch, not discussed on the ML. > Add more in-place operations to RealMatrix and RealVector > --------------------------------------------------------- > > Key: MATH-1170 > URL: https://issues.apache.org/jira/browse/MATH-1170 > Project: Commons Math > Issue Type: Wish > Reporter: Brian > Priority: Minor > > It would be nice if for some methods of RealMatrix and RealVector there were in-place versions of the methods - that would use the existing structures rather than creating new ones. In some situations it might be more efficient to use the same vector instead of creating many temporary ones each time which then have to be garbage collected, so it would be nice to provide the option. > An example of a method that could benefit from in-place versions: RealVector.add. > There was also a question on stack overflow about this for matrix operations: > http://stackoverflow.com/questions/20529484/performing-in-place-calculations-with-commons-maths-realmatrix > There is also a lot of precedents for this kind of behavior, in other languages. > In other languages, this is sometimes handled behind the scenes - when a self-assignment is found, a new variable is not created - in order to improve performance. E.g., some functional languages perform such optimizations behind the scenes, and it is used in MATLAB: > http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/ > http://undocumentedmatlab.com/blog/internal-matlab-memory-optimizations > In some ways directly providing the option for in-place operations is preferable because then we could control when it is applied. It could be used where appropriate within the internals of other methods as well. > Similarly there is also a convention in Ruby to have a special version of a method, marked with an exclamation point to indicate it is "dangerous" - usually meaning it changes its input - so-called "bang methods". Many of these are built into the core Ruby, e.g., sort/sort! for arrays, upcase/upcase!, chomp/chomp!, and reverse/reverse! for strings. -- This message was sent by Atlassian JIRA (v6.3.4#6332)