commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Maisonobe (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-570) Change some constructors of ArrayFieldVector to accept FieldVector
Date Tue, 10 May 2011 18:33:47 GMT

    [ https://issues.apache.org/jira/browse/MATH-570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13031291#comment-13031291
] 

Luc Maisonobe commented on MATH-570:
------------------------------------

The difference between a dedicated constructor and an explicit instanceof check is that one
is done at compile time and the other one at run time.
When I wrote that, I thought it would help the optimizer produce directly more efficient code.
I'm not sure anymore this is true (dynamic optimization in modern JVM is really smart to detect
the types by itself). So I agree with you, an explicit test is better. In fact, it would be
more or less similar to our own copyArray boolean flag.

So +1 to simplify these constructors if nobody disagree. We should copy the data, not wrap
it because FieldVector instances are mutable.

> Change some constructors of ArrayFieldVector to accept FieldVector
> ------------------------------------------------------------------
>
>                 Key: MATH-570
>                 URL: https://issues.apache.org/jira/browse/MATH-570
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Arne Plöse
>            Priority: Minor
>
> the constructor     public ArrayFieldVector(T[] v1, ArrayFieldVector<T> v2) {
>  ... 
> }
> takes an ArrayFieldVector.
> but the same can be easier archieved with this 
>     public ArrayFieldVector(T[] v1, FieldVector<T> v2) {
>         this(v1, v2 == null ? null : v2.getData());
>     }
> this goes for all other constructors...
> P.S. I donk know if copying the data in getData is an issue ... for this the named constructor
may make sense...

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message