commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <Luc.Maison...@free.fr>
Subject Re: [math] Shoud OpenIntToDoubleHashMap get return NaN instead of 0 for key not found?
Date Fri, 02 Jan 2009 17:54:52 GMT
Phil Steitz a écrit :
> sebb wrote:
>> On 02/01/2009, Luc Maisonobe <Luc.Maisonobe@free.fr> wrote:
>>  
>>> 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.
>>>     
>>
>> +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.
>>
>>   
> +1

OK. I've committed the change in trunk (r730801).

thanks for the advice.
Luc

> 
> Phil
>>>  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
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message