Hello,
I am about to finish writing a sorting (actually ranking) library (I will
post it on the web soon), and am about to write Radix sort based on
extracting bytes from integers and using these as Radices for a bucket sort.
Fortran's bit manipulation functions allow me to write this with absolutely
no machine dependency. However, I am wondering about efficiency. For
example, it is recommeded that the radix be 8 bits (a byte) because this can
be extracted faster on most machines and manipulated faster (usually as
KIND=1 in Fortran). In C, due to casting, it's trivial to extract bytes
(unsigned char) and manipulate them. In Fortran, extracting say the 2nd byte
of an integer would be done with:
INTEGER(KIND=four_bytes) :: integer_number
INTEGER(KIND=one_byte) :: byte_2
byte_2=IBITS( integer_number, 8, 8)
For REAL's this is even more complicated with two function calls:
REAL(KIND=four_bytes) :: real_number
byte_2=IBITS( TRANSFER(real_number, MOLD=integer_number), 8, 8)
Does anybody have experience and can share it with me on how efficiently
this would be done on today's F90 compilers. What is the variability between
compilers/machines? Should I switch to C for this one?
Thanks,
Aleksandar
_____________________________________________
Aleksandar Donev
http://www.pa.msu.edu/~donev/
[log in to unmask]
(517) 432-6770
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824-1116
_____________________________________________
|