diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2014-03-12 11:19:40 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2014-03-12 11:26:48 -0600 |
commit | a38888c18cd2a20de0eb0578b3fa8660cda79582 (patch) | |
tree | 4f0590684328a013544de84b1577f9322db4cbac /doc/swig/test/Tensor.cxx | |
parent | 4fd4850d6b8bb9a8837e19b7ef2b38d0cd67fdd1 (diff) | |
download | numpy-a38888c18cd2a20de0eb0578b3fa8660cda79582.tar.gz |
MAINT: Move doc/swig to tools/swig.
Also update MANIFEST.in and documentation to reflect the move. The
discussion of this change is at #2384.
Closes #2384. Closes #4374.
Diffstat (limited to 'doc/swig/test/Tensor.cxx')
-rw-r--r-- | doc/swig/test/Tensor.cxx | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/doc/swig/test/Tensor.cxx b/doc/swig/test/Tensor.cxx deleted file mode 100644 index 4ccefa144..000000000 --- a/doc/swig/test/Tensor.cxx +++ /dev/null @@ -1,131 +0,0 @@ -#include <stdlib.h> -#include <math.h> -#include <iostream> -#include "Tensor.h" - -// The following macro defines a family of functions that work with 3D -// arrays with the forms -// -// TYPE SNAMENorm( TYPE tensor[2][2][2]); -// TYPE SNAMEMax( TYPE * tensor, int slices, int rows, int cols); -// TYPE SNAMEMin( int slices, int rows, int cols TYPE * tensor); -// void SNAMEScale( TYPE tensor[3][3][3]); -// void SNAMEFloor( TYPE * array, int slices, int rows, int cols, TYPE floor); -// void SNAMECeil( int slices, int rows, int cols, TYPE * array, TYPE ceil); -// void SNAMELUSplit(TYPE in[2][2][2], TYPE lower[2][2][2], TYPE upper[2][2][2]); -// -// for any specified type TYPE (for example: short, unsigned int, long -// long, etc.) with given short name SNAME (for example: short, uint, -// longLong, etc.). The macro is then expanded for the given -// TYPE/SNAME pairs. The resulting functions are for testing numpy -// interfaces, respectively, for: -// -// * 3D input arrays, hard-coded length -// * 3D input arrays -// * 3D input arrays, data last -// * 3D in-place arrays, hard-coded lengths -// * 3D in-place arrays -// * 3D in-place arrays, data last -// * 3D argout arrays, hard-coded length -// -#define TEST_FUNCS(TYPE, SNAME) \ -\ -TYPE SNAME ## Norm(TYPE tensor[2][2][2]) { \ - double result = 0; \ - for (int k=0; k<2; ++k) \ - for (int j=0; j<2; ++j) \ - for (int i=0; i<2; ++i) \ - result += tensor[k][j][i] * tensor[k][j][i]; \ - return (TYPE)sqrt(result/8); \ -} \ -\ -TYPE SNAME ## Max(TYPE * tensor, int slices, int rows, int cols) { \ - int i, j, k, index; \ - TYPE result = tensor[0]; \ - for (k=0; k<slices; ++k) { \ - for (j=0; j<rows; ++j) { \ - for (i=0; i<cols; ++i) { \ - index = k*rows*cols + j*cols + i; \ - if (tensor[index] > result) result = tensor[index]; \ - } \ - } \ - } \ - return result; \ -} \ -\ -TYPE SNAME ## Min(int slices, int rows, int cols, TYPE * tensor) { \ - int i, j, k, index; \ - TYPE result = tensor[0]; \ - for (k=0; k<slices; ++k) { \ - for (j=0; j<rows; ++j) { \ - for (i=0; i<cols; ++i) { \ - index = k*rows*cols + j*cols + i; \ - if (tensor[index] < result) result = tensor[index]; \ - } \ - } \ - } \ - return result; \ -} \ -\ -void SNAME ## Scale(TYPE array[3][3][3], TYPE val) { \ - for (int k=0; k<3; ++k) \ - for (int j=0; j<3; ++j) \ - for (int i=0; i<3; ++i) \ - array[k][j][i] *= val; \ -} \ -\ -void SNAME ## Floor(TYPE * array, int slices, int rows, int cols, TYPE floor) { \ - int i, j, k, index; \ - for (k=0; k<slices; ++k) { \ - for (j=0; j<rows; ++j) { \ - for (i=0; i<cols; ++i) { \ - index = k*rows*cols + j*cols + i; \ - if (array[index] < floor) array[index] = floor; \ - } \ - } \ - } \ -} \ -\ -void SNAME ## Ceil(int slices, int rows, int cols, TYPE * array, TYPE ceil) { \ - int i, j, k, index; \ - for (k=0; k<slices; ++k) { \ - for (j=0; j<rows; ++j) { \ - for (i=0; i<cols; ++i) { \ - index = k*rows*cols + j*cols + i; \ - if (array[index] > ceil) array[index] = ceil; \ - } \ - } \ - } \ -} \ -\ -void SNAME ## LUSplit(TYPE tensor[2][2][2], TYPE lower[2][2][2], \ - TYPE upper[2][2][2]) { \ - int sum; \ - for (int k=0; k<2; ++k) { \ - for (int j=0; j<2; ++j) { \ - for (int i=0; i<2; ++i) { \ - sum = i + j + k; \ - if (sum < 2) { \ - lower[k][j][i] = tensor[k][j][i]; \ - upper[k][j][i] = 0; \ - } else { \ - upper[k][j][i] = tensor[k][j][i]; \ - lower[k][j][i] = 0; \ - } \ - } \ - } \ - } \ -} - -TEST_FUNCS(signed char , schar ) -TEST_FUNCS(unsigned char , uchar ) -TEST_FUNCS(short , short ) -TEST_FUNCS(unsigned short , ushort ) -TEST_FUNCS(int , int ) -TEST_FUNCS(unsigned int , uint ) -TEST_FUNCS(long , long ) -TEST_FUNCS(unsigned long , ulong ) -TEST_FUNCS(long long , longLong ) -TEST_FUNCS(unsigned long long, ulongLong) -TEST_FUNCS(float , float ) -TEST_FUNCS(double , double ) |