summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Zindy <ezindy@gmail.com>2013-06-08 22:59:48 +0100
committerEgor Zindy <ezindy@gmail.com>2013-06-08 22:59:48 +0100
commita21d8257e823d364f96dc2a6f57c42cac75dd826 (patch)
tree4d30965c95add2de4d8ca839b2035eb102b5d000
parent938f586d6f61654dec8e9e3f14084e98d86f60e9 (diff)
downloadnumpy-a21d8257e823d364f96dc2a6f57c42cac75dd826.tar.gz
cleaned-up loop indexes in Tensor.cxx
-rw-r--r--doc/swig/test/Tensor.cxx80
-rw-r--r--doc/swig/test/Tensor.h16
-rw-r--r--doc/swig/test/Tensor.i8
3 files changed, 52 insertions, 52 deletions
diff --git a/doc/swig/test/Tensor.cxx b/doc/swig/test/Tensor.cxx
index dce595291..4ccefa144 100644
--- a/doc/swig/test/Tensor.cxx
+++ b/doc/swig/test/Tensor.cxx
@@ -7,11 +7,11 @@
// arrays with the forms
//
// TYPE SNAMENorm( TYPE tensor[2][2][2]);
-// TYPE SNAMEMax( TYPE * tensor, int rows, int cols, int num);
-// TYPE SNAMEMin( int rows, int cols, int num, TYPE * tensor);
+// 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 rows, int cols, int num, TYPE floor);
-// void SNAMECeil( int rows, int cols, int num, TYPE * array, TYPE ceil);
+// 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
@@ -35,32 +35,32 @@ TYPE SNAME ## Norm(TYPE tensor[2][2][2]) { \
for (int k=0; k<2; ++k) \
for (int j=0; j<2; ++j) \
for (int i=0; i<2; ++i) \
- result += tensor[i][j][k] * tensor[i][j][k]; \
+ result += tensor[k][j][i] * tensor[k][j][i]; \
return (TYPE)sqrt(result/8); \
} \
\
-TYPE SNAME ## Max(TYPE * tensor, int rows, int cols, int num) { \
+TYPE SNAME ## Max(TYPE * tensor, int slices, int rows, int cols) { \
int i, j, k, index; \
TYPE result = tensor[0]; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = k*rows*cols + j*rows + i; \
- if (tensor[index] > result) result = tensor[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 (tensor[index] > result) result = tensor[index]; \
} \
} \
} \
return result; \
} \
\
-TYPE SNAME ## Min(int rows, int cols, int num, TYPE * tensor) { \
+TYPE SNAME ## Min(int slices, int rows, int cols, TYPE * tensor) { \
int i, j, k, index; \
TYPE result = tensor[0]; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = k*rows*cols + j*rows + i; \
- if (tensor[index] < result) result = tensor[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 (tensor[index] < result) result = tensor[index]; \
} \
} \
} \
@@ -68,31 +68,31 @@ TYPE SNAME ## Min(int rows, int cols, int num, TYPE * tensor) { \
} \
\
void SNAME ## Scale(TYPE array[3][3][3], TYPE val) { \
- for (int i=0; i<3; ++i) \
+ for (int k=0; k<3; ++k) \
for (int j=0; j<3; ++j) \
- for (int k=0; k<3; ++k) \
- array[i][j][k] *= val; \
+ for (int i=0; i<3; ++i) \
+ array[k][j][i] *= val; \
} \
\
-void SNAME ## Floor(TYPE * array, int rows, int cols, int num, TYPE floor) { \
+void SNAME ## Floor(TYPE * array, int slices, int rows, int cols, TYPE floor) { \
int i, j, k, index; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = k*cols*rows + j*rows + i; \
- if (array[index] < floor) array[index] = floor; \
+ 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 rows, int cols, int num, TYPE * array, TYPE ceil) { \
+void SNAME ## Ceil(int slices, int rows, int cols, TYPE * array, TYPE ceil) { \
int i, j, k, index; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (array[index] > ceil) array[index] = ceil; \
+ 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; \
} \
} \
} \
@@ -104,14 +104,14 @@ void SNAME ## LUSplit(TYPE tensor[2][2][2], TYPE lower[2][2][2], \
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[i][j][k] = tensor[i][j][k]; \
- upper[i][j][k] = 0; \
- } else { \
- upper[i][j][k] = tensor[i][j][k]; \
- lower[i][j][k] = 0; \
- } \
+ 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; \
+ } \
} \
} \
} \
diff --git a/doc/swig/test/Tensor.h b/doc/swig/test/Tensor.h
index d60eb2d2e..1f483b328 100644
--- a/doc/swig/test/Tensor.h
+++ b/doc/swig/test/Tensor.h
@@ -5,11 +5,11 @@
// functions that work with 3D arrays with the forms
//
// TYPE SNAMENorm( TYPE tensor[2][2][2]);
-// TYPE SNAMEMax( TYPE * tensor, int rows, int cols, int num);
-// TYPE SNAMEMin( int rows, int cols, int num, TYPE * tensor);
+// TYPE SNAMEMax( TYPE * tensor, int slices, int rows, int cols);
+// TYPE SNAMEMin( int slices, int rows, int cols, TYPE * tensor);
// void SNAMEScale( TYPE array[3][3][3]);
-// void SNAMEFloor( TYPE * array, int rows, int cols, int num, TYPE floor);
-// void SNAMECeil( int rows, int cols, int num, TYPE * array, TYPE ceil );
+// 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[3][3][3], TYPE lower[3][3][3], TYPE upper[3][3][3]);
//
// for any specified type TYPE (for example: short, unsigned int, long
@@ -29,11 +29,11 @@
#define TEST_FUNC_PROTOS(TYPE, SNAME) \
\
TYPE SNAME ## Norm( TYPE tensor[2][2][2]); \
-TYPE SNAME ## Max( TYPE * tensor, int rows, int cols, int num); \
-TYPE SNAME ## Min( int rows, int cols, int num, TYPE * tensor); \
+TYPE SNAME ## Max( TYPE * tensor, int slices, int rows, int cols); \
+TYPE SNAME ## Min( int slices, int rows, int cols, TYPE * tensor); \
void SNAME ## Scale( TYPE array[3][3][3], TYPE val); \
-void SNAME ## Floor( TYPE * array, int rows, int cols, int num, TYPE floor); \
-void SNAME ## Ceil( int rows, int cols, int num, TYPE * array, TYPE ceil ); \
+void SNAME ## Floor( TYPE * array, int slices, int rows, int cols, TYPE floor); \
+void SNAME ## Ceil( int slices, int rows, int cols, TYPE * array, TYPE ceil ); \
void SNAME ## LUSplit(TYPE tensor[2][2][2], TYPE lower[2][2][2], TYPE upper[2][2][2]);
TEST_FUNC_PROTOS(signed char , schar )
diff --git a/doc/swig/test/Tensor.i b/doc/swig/test/Tensor.i
index a1198dc9e..5bf9da7e2 100644
--- a/doc/swig/test/Tensor.i
+++ b/doc/swig/test/Tensor.i
@@ -17,15 +17,15 @@
%apply (TYPE IN_ARRAY3[ANY][ANY][ANY]) {(TYPE tensor[ANY][ANY][ANY])};
%apply (TYPE* IN_ARRAY3, int DIM1, int DIM2, int DIM3)
- {(TYPE* tensor, int rows, int cols, int num)};
+ {(TYPE* tensor, int slices, int rows, int cols)};
%apply (int DIM1, int DIM2, int DIM3, TYPE* IN_ARRAY3)
- {(int rows, int cols, int num, TYPE* tensor)};
+ {(int slices, int rows, int cols, TYPE* tensor)};
%apply (TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) {(TYPE array[3][3][3])};
%apply (TYPE* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3)
- {(TYPE* array, int rows, int cols, int num)};
+ {(TYPE* array, int slices, int rows, int cols)};
%apply (int DIM1, int DIM2, int DIM3, TYPE* INPLACE_ARRAY3)
- {(int rows, int cols, int num, TYPE* array)};
+ {(int slices, int rows, int cols, TYPE* array)};
%apply (TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) {(TYPE lower[2][2][2])};
%apply (TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) {(TYPE upper[2][2][2])};