
Using values of one array as pointer counters to access data in another ( long )
Quote:
> I wish to compute slopes for every x,y,z pair stored in array in memory
> by using the values of another node array as the index value access key.
> I want to group the slope values that touch each node. This means
> keeping track of all pairs which contain a "0", then each that contain
> a "1", etc. etc.
> NODES:
> 0 9 ( edge 1 or NODES[0]: from Node = XYZ[0] to_Node = XYZ[9] )
> 0 8
> 0 1
> 1 5
> 2 1
> 2 5
> 3 3
> 3 1
> 3 6
> 4 2
> 4 7 ( edge 11 or NODES[10]: from Node = XYZ[4] to_Node = XYZ[7] )
From your numbering, an element of the array NODES must be able
to store two indices into XYZ. Later you declare NODES as an
array of longs; so is edge 11 actually stored in NODES[20] and
NODES[21]?
Quote:
> I have a program that uses pointers to structures and then reads the
> arrays above ( these arrays are written to memory by a previous function
> call)
> My program seeks to do the following:
> 1) read the first number from the NODES array ( in this case "0" )
> 2) use this value as a counter (pointer incrementation) for how many
> rows down the XYZ array to go to reteive the first x,y,z value pair. (
> for loop )
> 3) reset the XYZ pointer to the beginning of that array.
> 4) read the second number from the NODES array ( in this case "9")
> 5) use this value in the same manner as in step 2. ( for loop )
> 6) compute slopes for every coordinate pair who's index #'sinclude "0".
> 7) repeat steps 1-6 for every coordinate pair who's index#'s include
> "1".
> 8) " " " " " " " " "
> "2".
> etc....etc...etc...
> 9) continue until all values of NODES array have been read and all XYZ
> pairs are fetched.
A top down description of what you need to do would be more
helpful: e.g., at the top level, indicate how you decide which node
to concentrate on, and then at the next refinement, indicate
what processing on the selected node is performed.
Quote:
> The problem is that I need to process only a subset at a time. I only
> want to consider those NODES values which contain a 0, do calculations
> on those, then fetch those pairs who's NODES values contain a 1, etc.
Have you written a program that works correctly for all nodes?
Quote:
> I have a variable passed to my function called n_Edges which makes sure
> I don't read past the last member of the NODES array. The number of
> elements in the XYZ array is equal to the maximum value in the NODES
> array ( in this case 9 ).
Is that 9 or 10?
Quote:
> right now I have the following implementation ( pseudo-code ).
> It compiles, but it doesn't behave the way I want it to....
I'm surprised you haven't gotten any responses pointing out that
pseudo-code is not intended to compile, and the code you give
is obviously not the code that's compiling.
Quote:
> calc_Slopes(double* XYZ, long* NODES, long n_Points,long n_Edges)
[snip]
> x1 = XYZ.X
> y1 = XYZ.Y
> Z1 = XYZ.Z
If XYZ is an array of doubles, how can it have X, Y and Z
components, even if you meant XYZ[i].X, XYZ[i].Y, etc? There
seems to be a similar problem with NODES, but your pseudo-code
is too vague to be sure.
You are either handling your arrays in too loose a manner, or else
just describing the handling in too loose a manner.
--
MJSR
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.