Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 1098 invoked from network); 2 Jan 2009 16:07:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jan 2009 16:07:10 -0000 Received: (qmail 4778 invoked by uid 500); 2 Jan 2009 16:07:09 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 4688 invoked by uid 500); 2 Jan 2009 16:07:09 -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 4676 invoked by uid 99); 2 Jan 2009 16:07:09 -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 08:07:09 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sebbaz@gmail.com designates 74.125.44.156 as permitted sender) Received: from [74.125.44.156] (HELO yx-out-1718.google.com) (74.125.44.156) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2009 16:07:01 +0000 Received: by yx-out-1718.google.com with SMTP id 3so2018469yxi.60 for ; Fri, 02 Jan 2009 08:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=5mE8Tc74UKvkhiyrXkyGYUJC5tsUKIx/oypDnWglANA=; b=QZqiLDW4o3Nt68NofodEq6gkrqOH9F7eO5wIxhBtMCyPNkaGg8kD7XHLUymTFujR/A hhQWNgfyJDLVGcju2AscBWT3Rnk9Xl6aA3q+RzR3mTwoW42mRupXYJYGlry0H19YQmd1 ptx3KCiL9h9D6YoFy8mBV8gfbAUeqJpW7QO1A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=j4P0vOgNShHiOCTMm2cbSkZy/3moOyRJXILsvtMr8doCVQQemUfEc6wYqQ0htxeTjE uWh1dE+lg687EpBAWqOEPuhy6sppJqdLeA7AyB+VKj0k6/D0dEqHlMLZiaDuGy9tVpku 03BvYGKUuGAvKSxThARcG0JNy1de9p5PsbxYU= Received: by 10.150.149.19 with SMTP id w19mr34757282ybd.114.1230912400825; Fri, 02 Jan 2009 08:06:40 -0800 (PST) Received: by 10.151.68.13 with HTTP; Fri, 2 Jan 2009 08:06:40 -0800 (PST) Message-ID: <25aac9fc0901020806j5c0b6fdy3e8cea14b8f9b9fd@mail.gmail.com> Date: Fri, 2 Jan 2009 16:06:40 +0000 From: sebb To: "Commons Developers List" Subject: Re: [math] Shoud OpenIntToDoubleHashMap get return NaN instead of 0 for key not found? In-Reply-To: <495E3875.8040608@free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <495E2834.9060409@gmail.com> <495E3875.8040608@free.fr> X-Virus-Checked: Checked by ClamAV on apache.org On 02/01/2009, Luc Maisonobe wrote: > Phil Steitz a =E9crit : > > > 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. +0 (I never used Math, but seems sensible) > 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. +1 to never changing the value - making it final would be best for thread safety. > > 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 > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org