From user-return-27310-apmail-commons-user-archive=commons.apache.org@commons.apache.org Wed Apr 18 22:32:35 2012 Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3EE7B9B38 for ; Wed, 18 Apr 2012 22:32:35 +0000 (UTC) Received: (qmail 40374 invoked by uid 500); 18 Apr 2012 22:32:34 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 40275 invoked by uid 500); 18 Apr 2012 22:32:34 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 40266 invoked by uid 99); 18 Apr 2012 22:32:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 22:32:33 +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.27] (HELO eir.is.scarlet.be) (193.74.71.27) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 22:32:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1334788324; bh=z31/Hj19XLCHjMKgAaTX+t6rsBMJpzNXknCFFbfaWPU=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=PaPNWXxlQVxRD9jgaqFZh/5H2CVApQqcXvLBqViMM0poxkcj/y7FJynGKi1DzLdK2 8s649CGD2hT8UyfGs8TlVWEpzmWem2d/rXR5Dsh75Q/KCUxO+Rb/sxl8Ft2frY8QJJ oazyjHsU7kF0go7p1pU2PvRrav4jE9LH0Vq7C3/M= Received: from mail.harfang.homelinux.org (ip-213-49-235-72.dsl.scarlet.be [213.49.235.72]) by eir.is.scarlet.be (8.14.5/8.14.5) with ESMTP id q3IMW3kM016122 for ; Thu, 19 Apr 2012 00:32:03 +0200 X-Scarlet: d=1334788323 c=213.49.235.72 Received: from localhost (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 0444F61CEB for ; Thu, 19 Apr 2012 00:32:03 +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 IonpT2JkHtMd for ; Thu, 19 Apr 2012 00:32:00 +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 5309C61B47 for ; Thu, 19 Apr 2012 00:32:00 +0200 (CEST) Received: from eran by dusk.harfang.homelinux.org with local (Exim 4.77) (envelope-from ) id 1SKdPs-0002Sx-2o for user@commons.apache.org; Thu, 19 Apr 2012 00:32:00 +0200 Date: Thu, 19 Apr 2012 00:31:59 +0200 From: Gilles Sadowski To: user@commons.apache.org Subject: Re: [math] UnivariateRealSolver in math3 Message-ID: <20120418223159.GO14208@dusk.harfang.homelinux.org> Mail-Followup-To: user@commons.apache.org References: <20120417133245.GZ32074@dusk.harfang.homelinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: eir 20002; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: clamav-milter 0.97.1-exp at eir X-Virus-Status: Clean Hi. > > But isn't this a regression compared to version 2.2 of commons math. > > There is a lot of commonalities between the Newton solver and the other solvers. > If I have a class representing a problem for which I have derivative, > lower and upper bounds and initial guess, I can try to solve it with a > Newton solver but also with the other solvers. So I should be able to > pass any of the univariate real solvers. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Please give a short code example of what you mean by this. In Commons Math, you don't pass the solver to the function, you pass the function to the solver's "solve" method(s). And doing so, nothing prevents you from passing an instance of a "DifferentiableUnivariateFunction" to a "solve" method that expects an instance of "UnivariateFunction" (since the former "extends" the latter). > However this is not possible > in math3.0 since there is no common interface anymore bewteen > NewtonSolver and the other solvers [...] That's so because they don't provide interchangeable functionalities (one requires the "derivative" in order to work, while the others do not). The alternative would have been to check, at runtime (with "instanceof") whether the provided function is indeed an instance of "DifferentiableUnivariateFunction" and throw an exception if not. This is indeed what was done before, but it is more bug-prone since this bypasses the strong type-checking provided by the compiler. Regards, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org