You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles (JIRA)" <ji...@apache.org> on 2016/05/29 22:57:12 UTC

[jira] [Resolved] (MATH-1170) Add more in-place operations to RealMatrix and RealVector

     [ 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)