You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ole Ersoy <ol...@gmail.com> on 2015/12/26 17:21:30 UTC

[math] RealVector.isInfinite() mixes in Nan check?

In RealVector there is an isInfinite() method that checks for isInfinite() and isNan() at the same time.  If any coordinate is infinite, it will return true...unless a value is Nan...then it will return false.  I'm probably missing something...but it seems like isInfinite() should return true if the 'isInfinite' condition matches, without the check for Nan mixed in?  There exists a method that checks for Nan as well.  I pasted both below:

     /**
      * Check whether any coordinate of this vector is {@code NaN}.
      *
      * @return {@code true} if any coordinate of this vector is {@code NaN},
      *         {@code false} otherwise.
      */
     public abstract boolean isNaN();

     /**
      * Check whether any coordinate of this vector is infinite and none are
      * {@code NaN}.
      *
      * @return {@code true} if any coordinate of this vector is infinite and
      *         none are {@code NaN}, {@code false} otherwise.
      */
     public abstract boolean isInfinite();

Thoughts?

Cheers,
Ole

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [math] RealVector.isInfinite() mixes in Nan check?

Posted by Ole Ersoy <ol...@gmail.com>.

On 12/26/2015 12:12 PM, Gilles wrote:
> On Sat, 26 Dec 2015 10:21:30 -0600, Ole Ersoy wrote:
>> In RealVector there is an isInfinite() method that checks for
>> isInfinite() and isNan() at the same time.  If any coordinate is
>> infinite, it will return true...unless a value is Nan...then it will
>> return false.  I'm probably missing something...but it seems like
>> isInfinite() should return true if the 'isInfinite' condition matches,
>> without the check for Nan mixed in?
>
> I'd think that if any component is NaN then "isInfinite" should indeed
> be false.
> But in that case, it does not mean that all components are finite...
>
> Perhaps it would be less surprising to have a method "isFinite" (no
> infinities and no NaNs).
I think it would be good to add that and only check for elements that are infinite in isInfinite().

Cheers,
Ole

>
> Regards,
> Gilles
>
>> There exists a method that checks
>> for Nan as well.  I pasted both below:
>>
>>     /**
>>      * Check whether any coordinate of this vector is {@code NaN}.
>>      *
>>      * @return {@code true} if any coordinate of this vector is {@code NaN},
>>      *         {@code false} otherwise.
>>      */
>>     public abstract boolean isNaN();
>>
>>     /**
>>      * Check whether any coordinate of this vector is infinite and none are
>>      * {@code NaN}.
>>      *
>>      * @return {@code true} if any coordinate of this vector is infinite and
>>      *         none are {@code NaN}, {@code false} otherwise.
>>      */
>>     public abstract boolean isInfinite();
>>
>> Thoughts?
>>
>> Cheers,
>> Ole
>>
>> ---------------------------------------------------------------------
>> 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


Re: [math] RealVector.isInfinite() mixes in Nan check?

Posted by Ole Ersoy <ol...@gmail.com>.

On 12/26/2015 02:41 PM, Phil Steitz wrote:
> On 12/26/15 11:12 AM, Gilles wrote:
>> On Sat, 26 Dec 2015 10:21:30 -0600, Ole Ersoy wrote:
>>> In RealVector there is an isInfinite() method that checks for
>>> isInfinite() and isNan() at the same time.  If any coordinate is
>>> infinite, it will return true...unless a value is Nan...then it will
>>> return false.  I'm probably missing something...but it seems like
>>> isInfinite() should return true if the 'isInfinite' condition
>>> matches,
>>> without the check for Nan mixed in?
>> I'd think that if any component is NaN then "isInfinite" should
>> indeed
>> be false.
> Right.  That is what we advertise and do now. Looking at the
> implementation, it is a bit lazy, though, as it calls isNaN instead
> of just interleaving the NaN check in one pass through the array.
> We should fix that.
>
>> But in that case, it does not mean that all components are finite...
>>
>> Perhaps it would be less surprising to have a method "isFinite" (no
>> infinities and no NaNs).
> Do you have a use case for such a method?  In fact, neither isNaN
> nor isInifinite is used anywhere in [math].  Could be deprecation
> candidates.
Thumbs up for deprecating.

Cheers,
Ole


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [math] RealVector.isInfinite() mixes in Nan check?

Posted by Phil Steitz <ph...@gmail.com>.
On 12/26/15 11:12 AM, Gilles wrote:
> On Sat, 26 Dec 2015 10:21:30 -0600, Ole Ersoy wrote:
>> In RealVector there is an isInfinite() method that checks for
>> isInfinite() and isNan() at the same time.  If any coordinate is
>> infinite, it will return true...unless a value is Nan...then it will
>> return false.  I'm probably missing something...but it seems like
>> isInfinite() should return true if the 'isInfinite' condition
>> matches,
>> without the check for Nan mixed in?
>
> I'd think that if any component is NaN then "isInfinite" should
> indeed
> be false.

Right.  That is what we advertise and do now. Looking at the
implementation, it is a bit lazy, though, as it calls isNaN instead
of just interleaving the NaN check in one pass through the array. 
We should fix that.

> But in that case, it does not mean that all components are finite...
>
> Perhaps it would be less surprising to have a method "isFinite" (no
> infinities and no NaNs).
Do you have a use case for such a method?  In fact, neither isNaN
nor isInifinite is used anywhere in [math].  Could be deprecation
candidates.

 
Phil

>
> Regards,
> Gilles
>
>> There exists a method that checks
>> for Nan as well.  I pasted both below:
>>
>>     /**
>>      * Check whether any coordinate of this vector is {@code NaN}.
>>      *
>>      * @return {@code true} if any coordinate of this vector is
>> {@code NaN},
>>      *         {@code false} otherwise.
>>      */
>>     public abstract boolean isNaN();
>>
>>     /**
>>      * Check whether any coordinate of this vector is infinite
>> and none are
>>      * {@code NaN}.
>>      *
>>      * @return {@code true} if any coordinate of this vector is
>> infinite and
>>      *         none are {@code NaN}, {@code false} otherwise.
>>      */
>>     public abstract boolean isInfinite();
>>
>> Thoughts?
>>
>> Cheers,
>> Ole
>>
>> ---------------------------------------------------------------------
>>
>> 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


Re: [math] RealVector.isInfinite() mixes in Nancheck?

Posted by Gilles <gi...@harfang.homelinux.org>.
On Sat, 26 Dec 2015 10:21:30 -0600, Ole Ersoy wrote:
> In RealVector there is an isInfinite() method that checks for
> isInfinite() and isNan() at the same time.  If any coordinate is
> infinite, it will return true...unless a value is Nan...then it will
> return false.  I'm probably missing something...but it seems like
> isInfinite() should return true if the 'isInfinite' condition 
> matches,
> without the check for Nan mixed in?

I'd think that if any component is NaN then "isInfinite" should indeed
be false.
But in that case, it does not mean that all components are finite...

Perhaps it would be less surprising to have a method "isFinite" (no
infinities and no NaNs).

Regards,
Gilles

> There exists a method that checks
> for Nan as well.  I pasted both below:
>
>     /**
>      * Check whether any coordinate of this vector is {@code NaN}.
>      *
>      * @return {@code true} if any coordinate of this vector is 
> {@code NaN},
>      *         {@code false} otherwise.
>      */
>     public abstract boolean isNaN();
>
>     /**
>      * Check whether any coordinate of this vector is infinite and 
> none are
>      * {@code NaN}.
>      *
>      * @return {@code true} if any coordinate of this vector is 
> infinite and
>      *         none are {@code NaN}, {@code false} otherwise.
>      */
>     public abstract boolean isInfinite();
>
> Thoughts?
>
> Cheers,
> Ole
>
> ---------------------------------------------------------------------
> 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