| 1 |
#ifndef MATRIX_H |
| 2 |
#define MATRIX_H |
| 3 |
|
| 4 |
// The following macro defines the prototypes for a family of |
| 5 |
// functions that work with 2D arrays with the forms |
| 6 |
// |
| 7 |
// TYPE SNAMEDet( TYPE matrix[2][2]); |
| 8 |
// TYPE SNAMEMax( TYPE * matrix, int rows, int cols); |
| 9 |
// TYPE SNAMEMin( int rows, int cols, TYPE * matrix); |
| 10 |
// void SNAMEScale( TYPE array[3][3]); |
| 11 |
// void SNAMEFloor( TYPE * array, int rows, int cols, TYPE floor); |
| 12 |
// void SNAMECeil( int rows, int cols, TYPE * array, TYPE ceil ); |
| 13 |
// void SNAMELUSplit(TYPE in[3][3], TYPE lower[3][3], TYPE upper[3][3]); |
| 14 |
// |
| 15 |
// for any specified type TYPE (for example: short, unsigned int, long |
| 16 |
// long, etc.) with given short name SNAME (for example: short, uint, |
| 17 |
// longLong, etc.). The macro is then expanded for the given |
| 18 |
// TYPE/SNAME pairs. The resulting functions are for testing numpy |
| 19 |
// interfaces, respectively, for: |
| 20 |
// |
| 21 |
// * 2D input arrays, hard-coded lengths |
| 22 |
// * 2D input arrays |
| 23 |
// * 2D input arrays, data last |
| 24 |
// * 2D in-place arrays, hard-coded lengths |
| 25 |
// * 2D in-place arrays |
| 26 |
// * 2D in-place arrays, data last |
| 27 |
// * 2D argout arrays, hard-coded length |
| 28 |
// |
| 29 |
#define TEST_FUNC_PROTOS(TYPE, SNAME) \ |
| 30 |
\ |
| 31 |
TYPE SNAME ## Det( TYPE matrix[2][2]); \ |
| 32 |
TYPE SNAME ## Max( TYPE * matrix, int rows, int cols); \ |
| 33 |
TYPE SNAME ## Min( int rows, int cols, TYPE * matrix); \ |
| 34 |
void SNAME ## Scale( TYPE array[3][3], TYPE val); \ |
| 35 |
void SNAME ## Floor( TYPE * array, int rows, int cols, TYPE floor); \ |
| 36 |
void SNAME ## Ceil( int rows, int cols, TYPE * array, TYPE ceil ); \ |
| 37 |
void SNAME ## LUSplit(TYPE matrix[3][3], TYPE lower[3][3], TYPE upper[3][3]); |
| 38 |
|
| 39 |
TEST_FUNC_PROTOS(signed char , schar ) |
| 40 |
TEST_FUNC_PROTOS(unsigned char , uchar ) |
| 41 |
TEST_FUNC_PROTOS(short , short ) |
| 42 |
TEST_FUNC_PROTOS(unsigned short , ushort ) |
| 43 |
TEST_FUNC_PROTOS(int , int ) |
| 44 |
TEST_FUNC_PROTOS(unsigned int , uint ) |
| 45 |
TEST_FUNC_PROTOS(long , long ) |
| 46 |
TEST_FUNC_PROTOS(unsigned long , ulong ) |
| 47 |
TEST_FUNC_PROTOS(long long , longLong ) |
| 48 |
TEST_FUNC_PROTOS(unsigned long long, ulongLong) |
| 49 |
TEST_FUNC_PROTOS(float , float ) |
| 50 |
TEST_FUNC_PROTOS(double , double ) |
| 51 |
|
| 52 |
#endif |