[
https://issues.apache.org/jira/browse/MATH-1538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17127626#comment-17127626
]
Gilles Sadowski commented on MATH-1538:
---------------------------------------
> I don't think different use-case can affect this.
The rationale for my remark is that although this little loop may be 7% faster,
the overall impact (in realistic calls to the method) might well be negligible.
And then IMHO, readability of the code is an important criterion too: Your way
of filling the array is not obvious (to me), and one could wonder about the
necessity to modify the code.
I would not object however on using a (self-documenting) method (to be defined
e.g. in utility class {{MathArrays}}):
{code:java}
/**
* Fill array with alternate values.
*
* @param arr Array to fill.
* @param x Value to copy to even slots.
* @param y Value to copy to odd slots.
*/
public void fill(double[] arr, double x, double y) {
// ...
}
{code}
> refine some codes dealing with filling an array with its first and second
> elements.
> -----------------------------------------------------------------------------------
>
> Key: MATH-1538
> URL: https://issues.apache.org/jira/browse/MATH-1538
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Jin Xu
> Priority: Minor
> Time Spent: 40m
> Remaining Estimate: 0h
>
> [https://github.com/apache/commons-math/pull/144]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)