octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [CHANGESET]: First attempt at a single precision type.


From: David Bateman
Subject: Re: [CHANGESET]: First attempt at a single precision type.
Date: Mon, 28 Apr 2008 09:57:42 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080306)

David Bateman wrote:
>
>> | I've assumed that the correct mixed double/single behavior is to promote
>> | the single type to double,
>>
>> Yeah, you would think that would be the way it should work, but of
>> course Matlab converts to single.
>>     
>
> You're kidding.... That is just incorrect in terms of ensuring a
> consistent precision. I assume the reason they did this is to allow
> something like
>
> single_arg + function_that_returns_double_for_single_arg(single_arg)
>
> to return single. This allows some functions not to be converted to
> handle singles and the majority of the calculation remaining in single
> precision. If this is the case there might be a difference between the
> treatment of operators and functions. For example, what about a mix of
> single/double arguments to a function like  filter or betainc for
> example, does it promote or demote the returned argument?
>   

I thought about this further and it seems that matlab's behavior for
mixed operators is

double OP int -> int
single OP int   -> error
double OP single -> single

We can easily get this behavior but removing the numeric conversion
methods from the single classes and putting them in the double classes.
However I see no reason why "single OP int" should be an error, but if
the numeric conversion methods are removed from the single classes then
to ensure that it isn't an error we'd have to implement all of the mixed
single/int operators.. So perhaps complete matlab compatibility is teh
way to go here  :-)

I also tried the mixed types to some functions, such as

>> a = filter (single(1),[1,1], 1:5)

a =

     1     1     2     2     3

>> whos a
  Name      Size            Bytes  Class     Attributes

  a         1x5                20  single             

and it appears that matlab prefers to demote the types if possible. So
the behavior I currently implemented will need to be up dated.

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

[Prev in Thread] Current Thread [Next in Thread]