The "iarray" Package

These routines provide a simple interface to the recursive, heirarchical data structure supported in Karma, when only n-dimensional data is to be represented.

Library: karma
Link With: -lkarma

Functions

iarray_num_dimGet number of dimensions in an Intelligent Array
iarray_typeGet type of data in an Intelligent Array
iarray_value_nameGet name of data in an Intelligent Array
iarray_register_destroy_funcRegister destroy function for an Intelligent Array
iarray_get_image_from_multiGet an image from a Karma data structure.
iarray_get_movie_from_multiGet a movie from a Karma data structure.
iarray_read_nDRead in a Karma arrayfile and yield an "Intelligent Array".
iarray_writeWrite an "Intelligent Array" in the Karma data format.
iarray_createCreate an Intelligent Array.
iarray_get_from_multi_arrayCreate an Intelligent Array from a Karma data structure.
iarray_deallocDeallocate an Intelligent Array.
iarray_put_named_valueAttach a data value to an Intelligent Array.
iarray_put_named_stringAttach a string to an Intelligent Array.
iarray_get_named_valueGet attached data from an Intelligent Array.
iarray_get_named_stringGet attached string from an Intelligent Array.
iarray_copy_dataCopy data between Intelligent Arrays.
iarray_get_sub_array_2DCreate a 2-dimensional alias Intelligent Array.
iarray_get_2D_slice_from_3DCreate a 2-dimensional Intelligent Array alias from a slice.
iarray_dim_lengthGet length of a dimension in an Intelligent Array.
iarray_get_restrictionsGet restriction information.
iarray_fillFill an Intelligent Array with a single value.
iarray_min_maxDetermine the minimum and maximum value of an Intelligent Array.
iarray_scale_and_offsetScale and offset an Intelligent Array.
iarray_add_and_scaleAdd Intelligent Arrays and scale.
iarray_sub_and_scaleSubtract Intelligent Arrays and scale.
iarray_dim_nameGet dimension name in an Intelligent Array.
iarray_remap_torusRemap Intelligent Array into a torus.
iarray_set_world_coordsSet the world co-ordinates of an Intelligent Array dimension.
iarray_get_world_coordsGet the world co-ordinates of an Intelligent Array dimension.
iarray_get_dim_descGet a dimension descriptor from an Intelligent Array.
iarray_compute_histogramCompute a histogram of an "Intelligent Array".
iarray_dim_indexThis routine will find the index of a named dimension.
iarray_get_data_scalingGet the scale and offset for data in an Intelligent Array.
iarray_set_data_scalingSet the scale and offset for data in an Intelligent Array.
iarray_write_mono_psWrite an Intelligent Array as monochrome PostScript.
iarray_write_pseudocolour_psWrite an Intelligent Array as PseudoColour PostScript.
iarray_write_rgb_psWrite an Intelligent Array as TrueColour PostScript.
iarray_create_1DCreate a 1-dimensional Intelligent Array.
iarray_create_2DCreate a 2-dimensional Intelligent Array.
iarray_create_3DCreate a 3-dimensional Intelligent Array.
iarray_create_4DCreate a 4-dimensional Intelligent Array.
iarray_put_floatAttach a float data value to an Intelligent Array.
iarray_put_intAttach an integer data value to an Intelligent Array.
iarray_get_floatGet attached float from an Intelligent Array.
iarray_get_intGet attached integer from an Intelligent Array.
iarray_fill_floatFill an Intelligent Array with a single float value.
iarray_fill_intFill an Intelligent Array with a single integer value.
iarray_min_max_floatDetermine the minimum and maximum value of an Intelligent Array.
iarray_min_max_intDetermine the minimum and maximum value of an Intelligent Array.
iarray_scale_and_offset_floatScale and offset an Intelligent Array.
iarray_scale_and_offset_intScale and offset an Intelligent Array.

Prototype Functions

IARRAY_PROTO_destroy_funcRegister destruction of an Intelligent Array.


Functions


unsigned int iarray_num_dim (iarray array)

Get number of dimensions in an Intelligent Array

Parameters:

Returns: The number of dimensions.
Multithreading Level: Unsafe


unsigned int iarray_type (iarray array)

Get type of data in an Intelligent Array

Parameters:

Returns: The type of the data in the array.
Multithreading Level: Unsafe


CONST char * iarray_value_name (iarray array)

Get name of data in an Intelligent Array

Parameters:

Returns: The name of the data in the array.
Multithreading Level: Unsafe


KCallbackFunc iarray_register_destroy_func (iarray array, void (*destroy_func) (iarray array, void *info), void *info)

Register destroy function for an Intelligent Array.

Parameters:

Returns: The name of the data in the array.
Multithreading Level: Unsafe


flag iarray_get_image_from_multi (multi_array *multi_desc, iarray *pseudo, iarray *red, iarray *green, iarray *blue, unsigned int *cmap_index)

This routine will find an image embedded in a Karma data structure. The image may be single-channel (PseudoColour) or it may be a TrueColour image (red, green and blue components).

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


flag iarray_get_movie_from_multi (multi_array *multi_desc, iarray *pseudo, iarray *red, iarray *green, iarray *blue, unsigned int *cmap_index)

This routine will find a movie embedded in a Karma data structure. The movie may be single-channel (PseudoColour) or it may be a TrueColour movie (red, green and blue components).

Parameters:

Returns: TRUE on succes, else FALSE.
Multithreading Level: Unsafe


iarray iarray_read_nD (CONST char *object, flag cache, CONST char *arrayname, unsigned int num_dim, CONST char **dim_names, CONST char *elem_name, unsigned int mmap_option)

Read in a Karma arrayfile and yield an "Intelligent Array".

Parameters:

Returns: A dynamically allocated intelligent array on success, else an error message is printed to the standard output and NULL is returned.
Multithreading Level: Unsafe


flag iarray_write (iarray array, CONST char *arrayfile)

Write an "Intelligent Array" in the Karma data format.

Parameters:

Returns: TRUE on success, else an error message is printed to the standard output and FALSE is returned.
Multithreading Level: Unsafe


iarray iarray_create (unsigned int type, unsigned int num_dim, CONST char **dim_names, CONST unsigned long *dim_lengths, CONST char *elem_name, iarray old_array)

This routine will create an "Intelligent Array", using the Karma general data structure format as the underlying data format. If the environment variable "IARRAY_ALLOC_DEBUG" is set to "TRUE" then the routine will print allocation debugging information.

Parameters:

Returns: A dynamically allocated intelligent array on success, else an error message is printed to the standard output and NULL is returned.
Multithreading Level: Unsafe


iarray iarray_get_from_multi_array (multi_array *multi_desc, CONST char *arrayname, unsigned int num_dim, CONST char **dim_names, CONST char *elem_name)

This routine will yield an "Intelligent Array" from a multi array Karma general data structure. The routine searches for a n-dimensional array with a single atomic element at each point in multi-dimensional space

Parameters:

Returns: A dynamically allocated intelligent array on success, else an error message is printed to the standard output and NULL is returned.
Multithreading Level: Unsafe


void iarray_dealloc (iarray array)

This routine will deallocate an "Intelligent Array". If the environment variable "IARRAY_ALLOC_DEBUG" is set to "TRUE" then the routine will print deallocation debugging information.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


flag iarray_put_named_value (iarray array, CONST char *name, unsigned int type, double value[2])

This routine will add a unique named value to the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag iarray_put_named_string (iarray array, CONST char *name, char *string)

This routine will add a unique named string to the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag iarray_get_named_value (iarray array, CONST char *name, unsigned int *type, double value[2])

This routine will get a unique named value from the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


char * iarray_get_named_string (iarray array, CONST char *name)

This routine will get a unique named string from the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: A pointer to a dynamically allocated copy of the string on success, else NULL.
Multithreading Level: Unsafe


flag iarray_copy_data (iarray output, iarray input, flag magnitude)

This routine will copy data from one "Intelligent Array" to another. The sizes of the two arrays must be identical. The routine can deal with the types of the two arrays being different

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


iarray iarray_get_sub_array_2D (iarray array, int starty, int startx, unsigned int ylen, unsigned int xlen)

This routine will create an "Intelligent Array" which is an alias or a sub-array of another "Intelligent Array". Subsequent modification of the alias array will modify the data of the original array. Sub-arrays may be created from other sub-arrays. The attachment count of the underlying multi_array data structure is incremented on successful completion.

Parameters:

Returns: A dynamically allocated intelligent array on success, else NULL.
Multithreading Level: Unsafe
Note:


iarray iarray_get_2D_slice_from_3D (iarray cube, unsigned int ydim, unsigned int xdim, unsigned int slice_pos)

This routine will create a 2-D "Intelligent Array" which is an alias of an arbitrary slice of a 3-D array.

Parameters:

Returns: A dynamically allocated intelligent array on success, else NULL.
Multithreading Level: Unsafe
Note:


unsigned long iarray_dim_length (iarray array, unsigned int index)

Get length of a dimension in an Intelligent Array.

Parameters:

Returns: The length of the specified dimension.
Multithreading Level: Unsafe


unsigned int iarray_get_restrictions (iarray array, char ***restr_names, double **restr_values)

This routine will get any associated restrictions for an Intelligent Array. The routine will dynamically allocate space for the restriction data, which must be externally freed.

Parameters:

Returns: The number of restrictions. This may be 0.
Multithreading Level: Unsafe


flag iarray_fill (iarray array, double value[2])

Fill an Intelligent Array with a single value.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag iarray_min_max (iarray array, unsigned int conv_type, double *min, double *max)

Determine the minimum and maximum value of an Intelligent Array.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe.


flag iarray_scale_and_offset (iarray out, iarray inp, double scale[2], double offset[2], flag magnitude)

This routine will perform a scale and offset on every element in an "Intelligent Array" (output = input * scale + offset).

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


flag iarray_add_and_scale (iarray out, iarray inp1, iarray inp2, double scale[2], flag magnitude)

This routine will add two "Intelligent Array" to each other and scales the result. The sizes of the two input arrays and the output must be identical. The routine performs the following computation: OUT = INP1 + INP2 * scale The routine will automatically perform type conversions if necessary.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


flag iarray_sub_and_scale (iarray out, iarray inp1, iarray inp2, double scale[2], flag magnitude)

This routine will subtract two "Intelligent Array" from each other and scales the result. The sizes of the two input arrays and the output must be identical. The routine performs the following computation: OUT = INP1 - INP2 * scale The routine will automatically perform type conversions if necessary.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


CONST char * iarray_dim_name (iarray array, unsigned int index)

This routine will get the name of a specified dimension in a simple, n-dimensional array.

Parameters:

Returns: A pointer to the name of the specified dimension.
Multithreading Level: Unsafe


void iarray_remap_torus (iarray array, unsigned int boundary_width)

This routine will remap an N-dimensional "Intelligent Array" to a pseudo-toroidal array.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void iarray_set_world_coords (iarray array, unsigned int index, double first, double last)

Set the world co-ordinates of an Intelligent Array dimension.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void iarray_get_world_coords (iarray array, unsigned int index, double *first, double *last)

Get the world co-ordinates of an Intelligent Array dimension.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


dim_desc * iarray_get_dim_desc (iarray array, unsigned int index)

Get a dimension descriptor from an Intelligent Array.

Parameters:

Returns: A pointer to the dimension descriptor.
Multithreading Level: Unsafe


flag iarray_compute_histogram (iarray array, unsigned int conv_type, double min, double max, unsigned long num_bins, unsigned long *histogram_array, unsigned long *histogram_peak, unsigned long *histogram_mode)

Compute a histogram of an "Intelligent Array".

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe.


unsigned int iarray_dim_index (iarray array, CONST char *name)

This routine will find the index of a named dimension.

Parameters:

Returns: The dimension index if found, else the number of dimension in the array is returned.
Multithreading Level: Unsafe


flag iarray_get_data_scaling (iarray array, double *scale, double *offset)

This routine will determine the scale and offset for data in an Intelligent Array. This may be important when a floating-point array has been converted to an integer array to save space. Scaling information should be attached to the array so that the original data values may be reconstructed (aside from quantisation effects). The following expression may be used to convert scaled values to real values: (output = input * scale + offset). The scaling and offset values should previously have been attached to the Intelligent Array using the iarray_set_data_scaling routine.

Parameters:

Returns: TRUE if either the scaling or offset value were found, else FALSE
Multithreading Level: Unsafe


flag iarray_set_data_scaling (iarray array, double scale, double offset)

This routine will set the scale and offset for data in an Intelligent Array. This may be important when a floating-point array has been converted to an integer array to save space. The scaling information will be attached to the array so that the original data values may be reconstructed (aside from quantisation effects). The following expression may be used to convert scaled values to real values: (output = input * scale + offset).

Parameters:

Returns: TRUE if the scaling information is different from what was already attached to the array, else FALSE.
Multithreading Level: Unsafe


flag iarray_write_mono_ps (iarray image, PostScriptPage pspage, double xstart, double ystart, double xend, double yend, flag iscale)

This routine will convert a 2-dimensional Intelligent Array to monochrome PostScript. The routine does NOT write PostScript headers or tails.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag iarray_write_pseudocolour_ps (iarray image, PostScriptPage pspage, double xstart, double ystart, double xend, double yend, unsigned short *cmap,unsigned int cmap_size)

This routine will convert a 2-dimensional Intelligent Array to colour PostScript. The routine does NOT write PostScript headers or tails.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag iarray_write_rgb_ps (iarray image_red, iarray image_green, iarray image_blue, PostScriptPage pspage, double xstart, double ystart, double xend, double yend)

This routine will convert three 2-dimensional Intelligent Arrays to colour PostScript. The routine does NOT write PostScript headers or tails.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


iarray iarray_create_1D (unsigned long xlen, unsigned int type)

This routine will create a 1-dimensional "Intelligent Array", using the Karma general data structure format as the underlying data format

Parameters:

Returns: A dynamically allocated intelligent array on success, else NULL.
Multithreading Level: Unsafe
Note:


iarray iarray_create_2D (unsigned long ylen, unsigned long xlen, unsigned int type)

This routine will create a 2-dimensional "Intelligent Array", using the Karma general data structure format as the underlying data format

Parameters:

Returns: A dynamically allocated intelligent array on success, else NULL.
Multithreading Level: Unsafe
Note:


iarray iarray_create_3D (unsigned long zlen, unsigned long ylen, unsigned long xlen, unsigned int type)

This routine will create a 3-dimensional "Intelligent Array", using the Karma general data structure format as the underlying data format

Parameters:

Returns: A dynamically allocated intelligent array on success, else NULL.
Multithreading Level: Unsafe
Note:


iarray iarray_create_4D (unsigned long zlen, unsigned long ylen, unsigned long xlen, unsigned int wlen, unsigned int type)

This routine will create a 4-dimensional "Intelligent Array", using the Karma general data structure format as the underlying data format

Parameters:

Returns: A dynamically allocated intelligent array on success, else NULL.
Multithreading Level: Unsafe
Note:


flag iarray_put_float (iarray array, CONST char *name, float value)

This routine will put a unique named float value into the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag iarray_put_int (iarray array, CONST char *name, int value)

This routine will put a unique named integer value into the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


float iarray_get_float (iarray array, CONST char *name)

This routine will get a unique named float value from the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: The value on success, else the process is aborted on error.
Multithreading Level: Unsafe


int iarray_get_int (iarray array, CONST char *name)

This routine will get a unique named integer value from the underlying Karma general data structure of an "Intelligent Array".

Parameters:

Returns: The value on success, else the process is aborted on error.
Multithreading Level: Unsafe


flag iarray_fill_float (iarray array, float value)

Fill an Intelligent Array with a single float value.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


flag iarray_fill_int (iarray array, int value)

Fill an Intelligent Array with a single integer value.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


flag iarray_min_max_float (iarray array, float *min, float *max)

Determine the minimum and maximum value of an Intelligent Array.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe.
Note:


flag iarray_min_max_int (iarray array, int *min, int *max)

Determine the minimum and maximum value of an Intelligent Array.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe.
Note:


flag iarray_scale_and_offset_float (iarray out, iarray inp, float scale, float offset)

This routine will perform a scale and offset on every element in an "Intelligent Array" (output = input * scale + offset).

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


flag iarray_scale_and_offset_int (iarray out, iarray inp, int scale,int offset)

This routine will perform a scale and offset on every element in an "Intelligent Array" (output = input * scale + offset).

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note:


Prototype Functions


void IARRAY_PROTO_destroy_func (iarray array, void *info)

Register destruction of an Intelligent Array.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Contact: Richard Gooch
Web Development: Ariel Internet Services