Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 96980 invoked from network); 2 Jan 2009 15:53:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jan 2009 15:53:58 -0000 Received: (qmail 97601 invoked by uid 500); 2 Jan 2009 15:53:57 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 97532 invoked by uid 500); 2 Jan 2009 15:53:57 -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 97521 invoked by uid 99); 2 Jan 2009 15:53:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2009 07:53:57 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [194.206.126.239] (HELO smtp.nordnet.fr) (194.206.126.239) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2009 15:53:48 +0000 Received: from lehrin (58.205.141.79.dynamic.adsl.abo.nordnet.fr [79.141.205.58]) by smtp.nordnet.fr (Postfix) with ESMTP id 41387342C5 for ; Fri, 2 Jan 2009 16:53:24 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) by lehrin (Postfix) with ESMTP id 5C1BD408E for ; Fri, 2 Jan 2009 16:53:25 +0100 (CET) Message-ID: <495E3875.8040608@free.fr> Date: Fri, 02 Jan 2009 16:53:25 +0100 From: Luc Maisonobe User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Commons Developers List Subject: Re: [math] Shoud OpenIntToDoubleHashMap get return NaN instead of 0 for key not found? References: <495E2834.9060409@gmail.com> In-Reply-To: <495E2834.9060409@gmail.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Phil Steitz a �crit : > I am still working through this class and the sparse matrix class that > it was extracted from (thanks, Ismael and Sugit!), so I am not sure if > changing this would cause problems, but the current setup (returning 0 > for missing keys) limits usefulness of this class. I see how this is > convenient for sparse matrices; but I would see NaN as a more natural > return value for non-existent keys in the general case. Alternatively, > I guess we could add another method get(int key, double missingReturn). > > Thoughts? I had exactly the same thought while extracting the class. I also prefer to use Double.NaN for numbers that have never been initialized explicitly, but I also understand 0 is more logical in the special case of sparse matrices. What about having a configurable value for missing entries ? It should probably be configured at construction time (with a default value to Double.NaN if not specified) and never changed afterwards. In the case of sparse matrices, we should configure this value to 0.0. Luc > > Phil > > --------------------------------------------------------------------- > 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