help converting multi-dim arrays

Russ Smith smith at nrl-aic.ARPA
Fri Apr 12 05:00:01 AEST 1985


I ran into a similar problem a number of years ago when I was
writing an "array relaxation" software package which had to handle
varying sized three dimensional arrays (and had to fit on a PDP-11/45).
I got around the problem by writing a command file which created an
"include" file on-the-fly and then recompiled the C program(s) (hack, hack!).
It worked, though...

The technique was similar (but not identical) to:

	setup 5 7 3 256 256 peleg	# Create and compile a package
					# of C programs to do "peleg"
					# relaxation using a 5x7
					# neighborhood on 3-labeled
					# probabilistic images of maximum
					# size 256x256...

which would create an include file with lines of the form:

	#define MAXNCOLS	256
	#define MAXNROWS	256
	#define NLABELS		3
	#define NBRHT		7
	#define NBRWDTH		5
	
which could then be included into the source file with, e.g.:

	#include "peleg.h"

and used as in:

	double neighborhood[NBRHT][NBRWDTH];
	double onerow[MAXNCOLS];

and so on. Kludgey, but it did allow many folks at the good old Computer
Vision Laboratory to test out various forms of algorithms on varying
sized three dimensional arrays most efficiently. (Note that a different
package of programs was created (and named appropriately) for each
importantly different set of parameters.)

Unless there are better ways now (for example, using a makefile with the
same functionality (which I, alas, either didn't know exist or didn't
have available at the time and mini-reinvented)) this method can be
used.

Russ <Smith at nrl-aic>
Navy Center for Applied Research in Artificial Intelligence



More information about the Comp.lang.c mailing list