Le 15/03/2013 22:36, Luc Maisonobe a écrit : > Le 15/03/2013 21:21, Becksfort, Jared a écrit : >> >> >> -----Original Message----- From: Becksfort, Jared Sent: Monday, March >> 11, 2013 12:28 PM To: Commons Developers List Subject: RE: [math] >> Scaling arrays. . >> >> On 3/11/13 8:21 AM, Becksfort, Jared wrote: >>> Hi Phil, >>> >>>> What exactly *is* it and what are the use cases? >>> Just a method to multiply each element in an array by a number and >>> return either a copy of the array or do it in place. Maybe there >>> can be one method for either way: >>> >>> public static double[] scale(double val, final double[] arr) { >>> double[] newArr = new double[arr.length]; for (int i = 0; i < >>> arr.length; i++) { newArr[i] = arr[i] * val; } return newArr; } >>> >>> public static void scaleInPlace(double val, final double[] arr) { >>> for (int i = 0; i < arr.length; i++) { arr[i] *= val; } } >>> >>>> ...use cases >>> I imagine they are pretty varied. These methods could be used any >>> time you want to multiply all elements in an array by a number >>> without writing a loop each time. I am using this in some >>> optimization code that I am submitting but figured it would be >>> broadly applicable enough to just be put in the MathArrays class. >>> >>> Jared >>> >>> -----Original Message----- From: Phil Steitz >>> [mailto:phil.ste...@gmail.com] Sent: Sunday, March 10, 2013 2:19 >>> PM To: Commons Developers List Subject: Re: [math] Scaling arrays. >>> . >>> >>> On 3/8/13 12:14 PM, Becksfort, Jared wrote: >>>> Hello, >>>> >>>> I may be missing it somewhere, but I am surprised there is no >>>> function for scaling arrays in MathArrays.java or somewhere >>>> else. >>>> >>>> - Am I stupidly missing it? >>> Probably not. Closest thing is probably normalize in MathArrays. >>>> - Is there a reason it is not in there? >>> Probably no; though you will find that most vector / array >>> algebraic operations are implemented on the objects in the linear >>> package, rather than directly on double[]s. >>>> - Shall I add it? >> >>> +1 to add this >> >>> Created an issue and submitted patches for MathArrays.java and >>> MathArraysTest.java >> >>> https://issues.apache.org/jira/browse/MATH-946 >> >>> Jared >> >>> Phil What exactly *is* it and what are the use cases? >>> >>> Phil >>>> Thanks, Jared >> >> Hello, >> > > Hi Jared, > >> Does anyone know if these changes might be committed to the >> repository? Some upcoming changes I am submitting for another issue >> rely on it. It is not too much trouble for me to remove the >> dependencies, but if this is going in then I may as well use it. > > I will look at this tomorrow morning (European time) and will probably > commit it if nobody does it before.
Well, it seems Phil did it just a few minutes ago ;-) Luc > > best regards, > Luc > >> >> https://issues.apache.org/jira/browse/MATH-946 >> >> Thanks, Jared >> >> >> >> Email Disclaimer: www.stjude.org/emaildisclaimer Consultation >> Disclaimer: www.stjude.org/consultationdisclaimer >> >> >> --------------------------------------------------------------------- >> >> > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> For additional commands, e-mail: dev-h...@commons.apache.org >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org