------ dynamic-2d-arrays.h ------ /* Dynamic 2D Array Library; version 1.0 */ /* (c) copyright Ian Hickson 2000, distributed under the GNU GPL */ /* MANUAL: defining your array: array2d* array; defining a variable of the relevant type: type value; ...where type is "int", "float", "array2d", or whatever. allocate the array: array = allocArray2D(width, height, sizeof(type)); set a place in the array to a particular value: value = (something); setArray2D(array, x, y, &value); get a particular value: value = *(type*)getArray2D(array, x, y); make a copy of an array: array2d* newarray; newarray = cloneArray2D(array) swap rows 2 and 3: permuteRowsArray2D(array, 2, 3); free the array: freeArray2D(array); freeArray2D(newarray); that's it. */ /* WARNING! In the interests of speed, this library does no serious error checking! (Note: You can disable error checking altogether by disabling asserts when compiling.) */ typedef char byte; /* SizeOf(byte) MUST equal 1! */ /* internal representation of the array */ typedef struct ARRAY2D { int elementSize; int width, height; byte* array; } array2d; /* interface functions */ extern array2d* allocArray2D(int width, int height, int elementSize); extern array2d* cloneArray2D(array2d* source); extern void* getPointerArray2D(array2d* array, int x, int y); extern void freeArray2D(array2d* array); extern void setArray2D(array2d* array, int x, int y, void* value); extern void* getArray2D(array2d* array, int x, int y); extern void permuteRowsArray2D(array2d* array, int y1, int y2); /* end */ --------------------------------- ------ gauss-elimination.h ------ /* Dynamic 2D Array Library; version 1.0 */ /* (c) copyright Ian Hickson 2000, distributed under the GNU GPL */ /* Implements a float dynamic square array with gauss elimination */ typedef float geNumber; extern array2d* geAllocArray(int equations); extern geNumber geGet(array2d*, int x, int y); extern void geSet(array2d*, int x, int y, geNumber value); extern array2d* geGaussElimination(array2d* originalArray); /* returns a new 1xN array with the answers, doesn't modify originalArray */ extern void gePrint(array2d*, int dp); /* dumps array to stdout */ /* end */ --------------------------------- ------ lists.h ------------------ /* Dynamic Lists of Numbers; version 1.0 */ /* (c) copyright Ian Hickson 2000, distributed under the GNU GPL */ /* a dynamic list of doubles */ typedef double nlNumber; typedef array2d numberList; /* interface */ numberList* nlAllocList(int entries); void nlFreeList(numberList* array); void nlSet(numberList* array, int x, nlNumber value); nlNumber nlGet(numberList* array, int x); void nlPrint(numberList* array, int dp); /* end */ --------------------------------- ------ runge-kutta.h ------------ /* Generic Runge Kutta ODE Solver; version 1.0 */ /* (c) copyright Ian Hickson 2000, distributed under the GNU GPL */ typedef nlNumber pStep(nlNumber x, numberList* LastValues); extern void rungekutta(nlNumber Start, nlNumber End, nlNumber StepSize, numberList* InitialValues, pStep* FunctionReturningHighestOrderDifferentialOfIntegrand, pStep* CallBack); /* end */ ---------------------------------