comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Can you do 'unions' with pv-wave?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Can you do 'unions' with pv-wave? [message #3189] Fri, 18 November 1994 17:23
jgavin is currently offline  jgavin
Messages: 1
Registered: November 1994
Junior Member
Is there a way to have a single variable viewed as multiple types, similar
to the way unions work in C. For example:

union x {
char a[2];
int b;
};

union x m;

m.a[0] = '\0';
m.a[1] = 'A';

printf ("%d", m.b);

produces the output => 65

In other words, the characters '\0','A' were interpreted as a single integer.
I'm trying to reference a single variable (i.e. 'm') as different types, without
having to make a copy.

The real problem involves a HUGE binary matrix with multiple types intermixed.
We would like to read a single copy of the matrix, and then view it differently
(to avoid multiple copies). Some variables are 8-bit integers, 16-bit int,
float, doubles, so-on-and-so-on.

Our brute-force approach is to read the 50MB file in once as an array of bytes, then again as an array of int, float, then double. This takes time and space
when actually, we simply want to view the same exact data in different ways.
Again, the 'C' union structure is the best way I can describe the problem.

Thanks for any help.

Regards,

Jeff


--
Jeff Gavin Jeff.Gavin@dseg.ti.com
Texas Instruments MSG: JGAV / (214) 462-5496
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Gaussian Convolution
Next Topic: IDL's CONTOUR, /FILL produces a spike

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 02:03:40 PDT 2025

Total time taken to generate the page: 1.59959 seconds