Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2B9F2E66D for ; Fri, 15 Mar 2013 21:48:01 +0000 (UTC) Received: (qmail 3307 invoked by uid 500); 15 Mar 2013 21:48:00 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 3163 invoked by uid 500); 15 Mar 2013 21:48:00 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 3154 invoked by uid 99); 15 Mar 2013 21:48:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Mar 2013 21:48:00 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of phil.steitz@gmail.com designates 209.85.160.49 as permitted sender) Received: from [209.85.160.49] (HELO mail-pb0-f49.google.com) (209.85.160.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Mar 2013 21:47:55 +0000 Received: by mail-pb0-f49.google.com with SMTP id xa12so4311890pbc.8 for ; Fri, 15 Mar 2013 14:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=X/FnFFhsYrYpf24HPikdVOzVn7X0jkytAM0gScPUrBE=; b=wr1Ld2R/bqymCTqQScXzL4+cQy34xrHNdrGKqS+c5SPNHhCG0bM3+o9no8TbPqwe1j 4TYOhCJhvlgy/WtfemIxXz7aJJSuBxlllHtu2MUA2qlQCTjxFUGrPP5q4t5K5lec2MkT /xRJ12EzdkwcEulLBOuwvrXRdlYUyxjqGl0jwDRq9xlc9rxHNrCkTjzJIN0RxC3myufa Y1jcg08LJFOOZeqXJDHPfA3Aoi31pYSrKyzXfpELX0lT6dbHKp0HgNbXSidbqN7YDKue 5HkLVD65042HMImVqph+XosU/DPYb30nRGQrg6L7o+SUp5OH+wli40kSbwgRyjO7BgUh oBkA== X-Received: by 10.68.87.129 with SMTP id ay1mr19772898pbb.105.1363384054910; Fri, 15 Mar 2013 14:47:34 -0700 (PDT) Received: from [192.168.2.107] (ip72-208-109-243.ph.ph.cox.net. [72.208.109.243]) by mx.google.com with ESMTPS id ri1sm10560602pbc.16.2013.03.15.14.47.32 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Mar 2013 14:47:34 -0700 (PDT) Message-ID: <514396F3.8010206@gmail.com> Date: Fri, 15 Mar 2013 14:47:31 -0700 From: Phil Steitz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: Commons Developers List Subject: Re: [math] Scaling arrays References: <8172D639BA76A14AA5C9DE7E13E0CEBE4DC82FDBB4@10.stjude.org> <513CDC8B.2090401@gmail.com> <8172D639BA76A14AA5C9DE7E13E0CEBE4DC86937B6@10.stjude.org> <513DFA0A.8000701@gmail.com> <8172D639BA76A14AA5C9DE7E13E0CEBE4DC8AAA3C5@10.stjude.org> In-Reply-To: <8172D639BA76A14AA5C9DE7E13E0CEBE4DC8AAA3C5@10.stjude.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 3/15/13 1:21 PM, Becksfort, Jared wrote: > > -----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.steitz@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, > > 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. > > https://issues.apache.org/jira/browse/MATH-946 Patches just applied. Many thanks. One small thing that will make it easier in the future is to create patches from the top-level /trunk directory. Thanks! Phil > > Thanks, > Jared > > > > Email Disclaimer: www.stjude.org/emaildisclaimer > Consultation Disclaimer: www.stjude.org/consultationdisclaimer > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org