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 07B358348 for ; Fri, 9 Sep 2011 02:05:45 +0000 (UTC) Received: (qmail 39236 invoked by uid 500); 9 Sep 2011 02:05:44 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 39109 invoked by uid 500); 9 Sep 2011 02:05:43 -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 39101 invoked by uid 99); 9 Sep 2011 02:05:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Sep 2011 02:05:43 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebastien.brisard@gmail.com designates 209.85.212.49 as permitted sender) Received: from [209.85.212.49] (HELO mail-vw0-f49.google.com) (209.85.212.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Sep 2011 02:05:38 +0000 Received: by vws8 with SMTP id 8so686923vws.8 for ; Thu, 08 Sep 2011 19:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=AGRQyVvm2rzmLpee2L8uKQ9GdHY0eiZkqOZ3xC4c9qg=; b=jWhL/h44c5+/A3d7maEts9D31vF8W3USDoEN8pWMyd97Djr9hDLpBRCtbpuHWIK3Od AZ6bW6yXEmQGp93RgPmjwBqDUrOUUBIa+7r0fYXY+Q3NyZp9BkjW+XtzUbxoA/WfMpSq lMwAu2K9bBPHNcg3sQz7On03OrE/Uw/hpFA24= MIME-Version: 1.0 Received: by 10.52.29.5 with SMTP id f5mr7785vdh.70.1315533918003; Thu, 08 Sep 2011 19:05:18 -0700 (PDT) Sender: sebastien.brisard@gmail.com Received: by 10.220.188.134 with HTTP; Thu, 8 Sep 2011 19:05:17 -0700 (PDT) In-Reply-To: References: <4E6919E1.3010905@free.fr> Date: Fri, 9 Sep 2011 04:05:17 +0200 X-Google-Sender-Auth: ZPbXL2t6Rep66Ww45k1FQ_MCq7k Message-ID: Subject: Re: [math] use the more general super-type RealMatrix in place of Array2DRowRealMatrix in package ode? From: =?ISO-8859-1?Q?S=E9bastien_Brisard?= To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sorry Ted, I was not very clear in my explanations. solve does return a RealMatrix. Internally, it builds BlockRealMatrix, thou= gh. The issue is that Luc needs the underlying double[][] array in this ODE application. This you could easily get if the returned matrix were a Array2DRowRealMatrix, and you could have something along the lines {code} RealMatrix x =3D decomposition.getSolver().solve(new Array2DRowRealMatrix(b, false)); if (x instanceof Array2DRowRealMatrix){ return x.getDataRef(); } else { return new Array2DRowRealMatrix(x.getData(), false); } {code} but this hack is of no use here, since it turns out that the decomposition solver being used here *always* returns a BlockRealMatrix (as an Array2DRealMatrix). So basically, deep copy of x through x.getData() will *always* occur. That's what is worrying me. I hope I do make my point, now. S=E9bastien 2011/9/9 Ted Dunning : > Why doesn't solve just return a RealMatrix? =A0Why does it insist on retu= rning > an Array2DRowRealMatrix? > > Does the user really care? > > 2011/9/8 S=E9bastien Brisard > >> Hi Luc, >> thanks for your detailed explanations attached to the MATH-659. I'm >> worried about the changes I have applied to the code, now. Here is >> what I've done. I've replaced the following line >> {code} >> return new Array2DRowRealMatrix(decomposition.getSolver().solve(b), fals= e); >> {code} >> with >> {code} >> RealMatrix x =3D decomposition.getSolver().solve(new >> Array2DRowRealMatrix(b, false)); >> return new Array2DRowRealMatrix(x.getData(), false); >> {code} >> >> decomposition is in fact an instance of QRDecompositionImpl.Solver, >> whose method solve(RealMatrix) returns a BlockRealMatrix, not an >> Array2DRowRealMatrix, hence the ugly last line. This code seems to be >> correct (unit tests still pass), but I'm worried about the efficiency, >> especially if initializeHighOrderDerivatives is called very often. >> What do you think should be done? >> >> Best regards, >> S=E9bastien >> >> --------------------------------------------------------------------- >> 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