Commits

Takafumi Arakaki  committed 12c8427

add 4-dim

  • Participants
  • Parent commits 4b8ac83

Comments (0)

Files changed (2)

File accesscarray/accesscarraymodule.c

       }
     }
     break;
+  case 4:
+    {
+      int n0 = PyArray_DIM(obj,0);
+      int n1 = PyArray_DIM(obj,1);
+      int n2 = PyArray_DIM(obj,2);
+      int n3 = PyArray_DIM(obj,3);
+      int i,j,k,l;
+
+      for (i = 0; i < n0; ++i){
+	for (j = 0; j < n1; ++j){
+	  for (k = 0; k < n2; ++k){
+	    for (l = 0; l < n3; ++l){
+	      
+	      index = i*n0*n1*n2 + j*n1*n2 + k*n2 + l;
+
+	      if (PyArray_ISFLOAT(obj)){
+		elem = (void *)&((double *)data)[index];
+	      }else if (PyArray_ISINTEGER(obj)){
+		elem = (void *)&((int *)data)[index];
+	      }else{
+		PySys_WriteStdout("Unknown data type\n");
+		break;
+	      }
+
+	      if (PyArray_GETPTR4(obj,i,j,k,l) == elem){
+		PySys_WriteStdout(".");
+	      }else{
+		num_missmatch++;
+		PySys_WriteStdout("!");
+	      }
+	      num_elem++;
+	    }
+	  }
+	}
+      }
+    }
+    break;
   }
   
   PySys_WriteStdout("\n");

File accesscarray/check_pointer.py

 faf2d = numpy.array([[1,2,3],[1,2,3],[1,2,3]], dtype=numpy.float, order='F')
 fac3d = numpy.array([[[1,2],[1,2]],[[1,2],[1,2]]], dtype=numpy.float)
 
+fa_4d = numpy.arange(2**4).reshape([2]*4)
+fac4d = fa_4d.copy('C')
+faf4d = fa_4d.copy('F')
+
 print
 print 'print_a1'
 print_a1(fac1d)
 check_pointer(fac2d)
 check_pointer(faf2d)
 check_pointer(fac3d)
+check_pointer(fac4d)
+check_pointer(faf4d)