array_util.c File Reference


Detailed Description

Some utility functions for the test suite.

This module must be compiled with instantiated default types.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "array_util.h"
#include "abort_prog.h"
#include "util/rand_util.h"

Data Structures

struct  indvalpair_t

Functions

oski_value_t * array_Duplicate (const oski_value_t *x0, oski_index_t len)
 Returns a pointer to a newly allocated copy of the given array, or NULL on error.
void array_Destroy (oski_value_t *x)
 Release previously allocated array.
int array_CompareElems_NoAbort (const char *test_func, const oski_value_t *x, const oski_value_t *y, oski_index_t len)
 Compare elements of two arrays, and exit the program with an error code of 1 if the element-wise difference greater than len*(machine epsilon) detected.
void array_CompareElems (const char *test_func, const oski_value_t *x, const oski_value_t *y, oski_index_t len)
 Compare elements of two arrays, and exit the program with an error code of 1 if the element-wise difference greater than len*(machine epsilon) is detected.
void array_FillRandom (oski_value_t *x, oski_index_t n)
 Initialize an array with random values between -1 and 1.
oski_value_t * array_CreateRandom (oski_index_t n)
 Allocate an array of random values between -1 and 1.
oski_value_t * array_Create (oski_index_t n, oski_value_t val)
 Allocate an array with elements initialized to a particular value.
static int compare_indvalpair (const void *pa, const void *pb)
void array_SortIndValPairs (oski_index_t *ind, oski_value_t *val, oski_index_t n)
 Sorts an (index, value) pair of arrays.


Function Documentation

void array_CompareElems const char *  test_func,
const oski_value_t *  x,
const oski_value_t *  y,
oski_index_t  len
 

Compare elements of two arrays, and exit the program with an error code of 1 if the element-wise difference greater than len*(machine epsilon) is detected.

Parameters:
[in] test_func Name of the calling test function.
[in] x Expected results.
[in] y Observed/computed results.
[in] len Length of the x and y arrays.

int array_CompareElems_NoAbort const char *  test_func,
const oski_value_t *  x,
const oski_value_t *  y,
oski_index_t  len
 

Compare elements of two arrays, and exit the program with an error code of 1 if the element-wise difference greater than len*(machine epsilon) detected.

Parameters:
[in] test_func Name of the calling test function.
[in] x Expected results.
[in] y Observed/computed results.
[in] len Length of the x and y arrays.

void array_Destroy oski_value_t *  x  ) 
 

Release previously allocated array.

Parameters:
[in,out] x Array to destroy.
Postcondition:
x no longer usable.

oski_value_t* array_Duplicate const oski_value_t *  x0,
oski_index_t  len
 

Returns a pointer to a newly allocated copy of the given array, or NULL on error.

Parameters:
[in] x0 Array to copy.
[in] len Number of elements to copy from x0.
Returns:
A newly allocated copy of x0, or NULL on error.


Generated on Wed Sep 19 16:41:21 2007 for BeBOP Optimized Sparse Kernel Interface Library by  doxygen 1.4.6