Print

Print


Thanks for the prompt answer, Jaap.

So, I guess that if I need the 3-value sign function the way I do it is the
most efficient in Ox (which is actually very quick).

Well, the use is mostly for non-parametric testing.

Best,

Matteo

 

Da: The ox-users list is aimed at all Ox users
[mailto:[log in to unmask]] Per conto di Vries, J.J. de (Jaap)
Inviato: luned́ 22 febbraio 2010 22:28
A: [log in to unmask]
Oggetto: Re: sign function

 

Dear Matteo,

 

Your sign function is richer than the sign bit, because it can take three
values. If you simplify it to

 

return mX .< 0

 

you have the sign bit (implementation dependent). No sums or subtractions
involved, and if the compiler is efficient it just takes the sign bit
(usually supported by the processor).

Low level solutions would require taking every double separately from the
matrix, casting it to a binary format, and selecting an individual bit.
Makes it complicated and heavily platform dependent.

 

The optimal answer of course depends on the question what you want to do
with the signs.

 

Regards,

Jaap

 

  _____  

Van: The ox-users list is aimed at all Ox users namens Matteo Pelagatti
Verzonden: ma 22-2-2010 22:07
Aan: [log in to unmask]
Onderwerp: sign function

Dear Oxers,

when I need the sign function I usually do it this way

 

sign(const mX)

{

                return (mX .> 0) - (mX .< 0);

}

 

But, to me this does not appear to be very efficient, since many comparisons
and sums are carried out by the interpreter.

Is there any low level way to do the same? Something that only returns the
sign bits of every double?

 

Thanks and best regards to all,

Matteo