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 0E2317FFC for ; Fri, 2 Sep 2011 17:08:21 +0000 (UTC) Received: (qmail 52167 invoked by uid 500); 2 Sep 2011 17:08:20 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 52033 invoked by uid 500); 2 Sep 2011 17:08:19 -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 52025 invoked by uid 99); 2 Sep 2011 17:08:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2011 17:08:19 +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 (nike.apache.org: local policy) Received: from [193.74.71.26] (HELO hel.is.scarlet.be) (193.74.71.26) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2011 17:08:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1314983270; bh=oRl/ApLU0GqYGnCNKxW2SYHzN4SaFBYze51U3uyCszQ=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Transfer-Encoding:In-Reply-To; b=W8aq/qFbAiwqCjhZQL15y473tFnl9mUT/X+x+V6V4r/8sHGZRopO608nAUja/xPG1 hQ1ENcRUL26HE1VtqfRBcfIwmqHjOJLE1AhqtmWvgMpLwAJTpSPca9zfXSumIfN0PM EYvSY6F81uaKDZJaFuqvl0LjFkIusfJZuCYXzT1k= Received: from mail.harfang.homelinux.org (ip-213-49-250-97.dsl.scarlet.be [213.49.250.97]) by hel.is.scarlet.be (8.14.5/8.14.5) with ESMTP id p82H7nNX026870 for ; Fri, 2 Sep 2011 19:07:50 +0200 X-Scarlet: d=1314983270 c=213.49.250.97 Received: from localhost (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 6B90461CE9 for ; Fri, 2 Sep 2011 19:07:49 +0200 (CEST) Received: from mail.harfang.homelinux.org ([192.168.20.11]) by localhost (mail.harfang.homelinux.org [192.168.20.11]) (amavisd-new, port 10024) with ESMTP id K6NWYn0LFk9D for ; Fri, 2 Sep 2011 19:07:47 +0200 (CEST) Received: from dusk.harfang.homelinux.org (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 8D07D6179D for ; Fri, 2 Sep 2011 19:07:47 +0200 (CEST) Received: from eran by dusk.harfang.homelinux.org with local (Exim 4.76) (envelope-from ) id 1QzXDX-0003Dm-Dz for dev@commons.apache.org; Fri, 02 Sep 2011 19:07:47 +0200 Date: Fri, 2 Sep 2011 19:07:47 +0200 From: Gilles Sadowski To: dev@commons.apache.org Subject: Re: svn commit: r1164615 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java Message-ID: <20110902170747.GH19625@dusk.harfang.homelinux.org> Mail-Followup-To: dev@commons.apache.org References: <20110902163441.68AB523889E3@eris.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20110902163441.68AB523889E3@eris.apache.org> X-Operating-System: Tiny Tux X-PGP-Key-Fingerprint: 53B9 972E C2E6 B93C BEAD 7092 09E6 AF46 51D0 5641 User-Agent: Mutt/1.5.21 (2010-09-15) X-DCC-scarlet.be-Metrics: hel 20001; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: clamav-milter 0.97.1-exp at hel X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org Hi S�bastien. > > /** > * Gauss-Newton least-squares solver. > @@ -146,8 +148,13 @@ public class GaussNewtonOptimizer extend > DecompositionSolver solver = useLU ? > new LUDecompositionImpl(mA).getSolver() : > new QRDecompositionImpl(mA).getSolver(); > - final double[] dX = solver.solve(b); > - > + final RealVector dummy = solver.solve(new ArrayRealVector(b, false)); > + final double[] dX; > + if (dummy instanceof ArrayRealVector){ > + dX = ((ArrayRealVector) dummy).getDataRef(); > + }else{ > + dX = dummy.getData(); > + } In my opinion, the hypothetical efficiency gain is not worth the convoluted code so: --- final double[] dX = solver.solve(new ArrayRealVector(b, false)).toArray(); --- Also, next time, when you'll really need a curly bracket ;-), please insert a space character before it, and around keywords too: --- if (ok) { // ... } else { // ... } --- Sorry to be picky and thank you, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org