For some applications, like image processing, you handle files containing data of unsigned type. For many applications, you do not want to convert these arrays to floating point values, but you want to keep them in their original form, especially if memory requirements become critical.
This is why a new set of types was added to yorick-mb. Since the burden to add other types, like long long
was not much higher, these were added too. So the full list of new types is:
Type name | C equivalent | Constant example | format in linux-i386 |
---|---|---|---|
uchar | unsigned char | 23ur | 8 bit unsigned |
ushort | unsigned short | 12us | 16 bit unsigned |
uint | unsigned int | 11un | 32 bit unsigned |
ulong | unsigned long | 1000ul | 32 bit unsigned |
llong | long long | -154ll | 64 bit signed |
ullong | unsigned long long | 322ull | 64 bit unsigned |
ldouble | long double | 1.0l | 80 bit IEEE floating point |
lcomplex | long double[2] | 1.2il, -3il | 80 bit IEEE complex |
Is it important to note that the same functionalities are provided for these as for the original yorick types. You can build arrays of such numbers, store them in PDB files (see the openb and createb yorick functions), interface C functions defined with such types, use all existing operators on them, do fast Fourier transforms on long doubles, etc.
Even better: PDB files containing such numbers can be read with older yorick releases, as the PDB file contains a description of the binary structure of numbers stored that can be decoded correctly with, say, yorick-1.4. This works of course as long as the older yorick can represent the number in one of of its native formats without truncation.
Unsigned types are useful for reading raw encoded images. Suppose you have a file image.raw
containing a raw 8 bit encoded image of size 640x400. This is how you get the image in an array im
in yorick scripting language:
> im=array(uchar,640,400) > f=open("image.dat","rb") > _read,f,0,im |
and you are done.
Now suppose the image is stored in 16 bits per pixel, little-endian. You then read the file with:
> im=array(ushort,640,400) > f=open("image.dat","rb") > pc_primitives,f > _read,f,0,im |
or if the image is stored in big-endian format:
> im=array(ushort,640,400) > f=open("image.dat","rb") > sun_primitives,f > _read,f,0,im |
or if the image is stored in an endianness conforming to your computer's architecture, simply:
> im=array(ushort,640,400) > f=open("image.dat","rb") > _read,f,0,im |