Repository: pyccel/pyccel
Pull request #569 (2020-11-30 07:30:23)

Use stdint.h for integer types in arrays
As discussed in PR #548, we are now using stdint.h for integer types in C. This PR makes those changes for arrays in C.

cc: @saniQQ 

EmilyBourne: @saniQQ @rakati All your questions are about precision so I will answer them together here. As mentioned in the PR description, after PR #548 we will be using precise types in all the code generated by pyccel. While technically shapes don't need to have precise types, if they don't there may be casts generated when generating the code that creates the shape. The same is also true for indexes. (I don't know on what, if any, system this might be the case as all systems I know of have int==int32_t, but there is no guarantee of this so it is better to be consistent)

Patch:
diff --git a/pyccel/codegen/printing/ccode.py b/pyccel/codegen/printing/ccode.py
index aadbcf04..32b10564 100644
--- a/pyccel/codegen/printing/ccode.py
+++ b/pyccel/codegen/printing/ccode.py
@@ -205,10 +205,10 @@ ndarray_type_registry = {('real',8)    : 'nd_double',
                   ('real',4)    : 'nd_float',
                   ('complex',8) : 'nd_cdouble',
                   ('complex',4) : 'nd_cfloat',
-                  ('int',4)     : 'nd_int',
-                  ('int',8)     : 'nd_long',
-                  ('int',2)     : 'nd_sint',
-                  ('int',1)     : 'nd_char',
+                  ('int',8)     : 'nd_int64',
+                  ('int',4)     : 'nd_int32',
+                  ('int',2)     : 'nd_int16',
+                  ('int',1)     : 'nd_int8',
                   ('bool',4)    : 'nd_bool'}
 
 import_dict = {'omp_lib' : 'omp' }
diff --git a/pyccel/stdlib/ndarrays/ndarrays.c b/pyccel/stdlib/ndarrays/ndarrays.c
index e2d61a99..ed2e7a69 100644
--- a/pyccel/stdlib/ndarrays/ndarrays.c
+++ b/pyccel/stdlib/ndarrays/ndarrays.c
@@ -4,7 +4,7 @@
 ** allocation
 */
 
-t_ndarray   array_create(int nd, int *shape, enum e_types type)
+t_ndarray   array_create(int32_t nd, int32_t *shape, enum e_types type)
 {
     t_ndarray arr;
 
@@ -12,17 +12,17 @@ t_ndarray   array_create(int nd, int *shape, enum e_types type)
     arr.type = type;
     switch (type)
     {
-        case nd_bool:
-            arr.type_size = sizeof(bool);
+        case nd_int8:
+            arr.type_size = sizeof(int8_t);
             break;
-        case nd_sint:
-            arr.type_size = sizeof(short int);
+        case nd_int16:
+            arr.type_size = sizeof(int16_t);
             break;
-        case nd_int:
-            arr.type_size = sizeof(int);
+        case nd_int32:
+            arr.type_size = sizeof(int32_t);
             break;
-        case nd_long:
-            arr.type_size = sizeof(long);
+        case nd_int64:
+            arr.type_size = sizeof(int64_t);
             break;
         case nd_float:
             arr.type_size = sizeof(float);
@@ -30,6 +30,9 @@ t_ndarray   array_create(int nd, int *shape, enum e_types type)
         case nd_double:
             arr.type_size = sizeof(double);
             break;
+        case nd_bool:
+            arr.type_size = sizeof(bool);
+            break;
         case nd_cfloat:
             arr.type_size = sizeof(float complex);
             break;
@@ -39,63 +42,76 @@ t_ndarray   array_create(int nd, int *shape, enum e_types type)
     }
     arr.is_slice = false;
     arr.length = 1;
-    arr.shape = malloc(arr.nd * sizeof(int));
-    for (int i = 0; i < arr.nd; i++)
+    arr.shape = malloc(arr.nd * sizeof(int32_t));
+    for (int32_t i = 0; i < arr.nd; i++)
     {
         arr.length *= shape[i];
         arr.shape[i] = shape[i];
     }
     arr.buffer_size = arr.length * arr.type_size;
-    arr.strides = malloc(nd * sizeof(int));
-    for (int i = 0; i < arr.nd; i++)
+    arr.strides = malloc(nd * sizeof(int32_t));
+    for (int32_t i = 0; i < arr.nd; i++)
     {
         arr.strides[i] = 1;
-        for (int j = i + 1; j < arr.nd; j++)
+        for (int32_t j = i + 1; j < arr.nd; j++)
             arr.strides[i] *= arr.shape[j];
     }
     arr.raw_data = malloc(arr.buffer_size);
     return (arr);
 }
 
-void   _array_fill_int(int c, t_ndarray arr)
+void   _array_fill_int8(int8_t c, t_ndarray arr)
+{
+    if (c == 0)
+        memset(arr.raw_data, 0, arr.buffer_size);
+    else
+        for (int32_t i = 0; i < arr.length; i++)
+            arr.nd_int8[i] = c;
+}
+
+void   _array_fill_int16(int16_t c, t_ndarray arr)
 {
     if (c == 0)
         memset(arr.raw_data, 0, arr.buffer_size);
     else
-        for (int i = 0; i < arr.length; i++)
-            arr.nd_int[i] = c;
+        for (int32_t i = 0; i < arr.length; i++)
+            arr.nd_int16[i] = c;
 }
-void   _array_fill_long(long c, t_ndarray arr)
+
+void   _array_fill_int32(int32_t c, t_ndarray arr)
 {
     if (c == 0)
         memset(arr.raw_data, 0, arr.buffer_size);
     else
-        for (int i = 0; i < arr.length; i++)
-            arr.nd_long[i] = c;
+        for (int32_t i = 0; i < arr.length; i++)
+            arr.nd_int32[i] = c;
 }
-void   _array_fill_sint(short int c, t_ndarray arr)
+
+void   _array_fill_int64(int64_t c, t_ndarray arr)
 {
     if (c == 0)
         memset(arr.raw_data, 0, arr.buffer_size);
     else
-        for (int i = 0; i < arr.length; i++)
-            arr.nd_sint[i] = c;
+        for (int32_t i = 0; i < arr.length; i++)
+            arr.nd_int64[i] = c;
 }
+
 void   _array_fill_bool(bool c, t_ndarray arr)
 {
     if (c == 0)
         memset(arr.raw_data, 0, arr.buffer_size);
     else
-        for (int i = 0; i < arr.length; i++)
+        for (int32_t i = 0; i < arr.length; i++)
             arr.nd_bool[i] = c;
 }
-void   _array_fill_cfloat(float complex c, t_ndarray arr)
+
+void   _array_fill_float(float c, t_ndarray arr)
 {
     if (c == 0)
         memset(arr.raw_data, 0, arr.buffer_size);
     else
-        for (int i = 0; i < arr.length; i++)
-            arr.nd_cfloat[i] = c;
+        for (int32_t i = 0; i < arr.length; i++)
+            arr.nd_float[i] = c;
 }
 
 void   _array_fill_double(double c, t_ndarray arr)
@@ -103,16 +119,26 @@ void   _array_fill_double(double c, t_ndarray arr)
     if (c == 0)
         memset(arr.raw_data, 0, arr.buffer_size);
     else
-        for (int i = 0; i < arr.length; i++)
+        for (int32_t i = 0; i < arr.length; i++)
             arr.nd_double[i] = c;
 }
 
+void   _array_fill_cfloat(float complex c, t_ndarray arr)
+{
+    if (c == 0)
+        memset(arr.raw_data, 0, arr.buffer_size);
+    else
+        for (int32_t i = 0; i < arr.length; i++)
+            arr.nd_cfloat[i] = c;
+}
+
+
 void   _array_fill_cdouble(double complex c, t_ndarray arr)
 {
     if (c == 0)
         memset(arr.raw_data, 0, arr.buffer_size);
     else
-        for (int i = 0; i < arr.length; i++)
+        for (int32_t i = 0; i < arr.length; i++)
             arr.nd_cdouble[i] = c;
 }
 
@@ -120,7 +146,7 @@ void   _array_fill_cdouble(double complex c, t_ndarray arr)
 ** deallocation
 */
 
-int free_array(t_ndarray dump)
+int32_t free_array(t_ndarray dump)
 {
     if (!dump.is_slice)
     {
@@ -138,7 +164,7 @@ int free_array(t_ndarray dump)
 ** slices
 */
 
-t_slice new_slice(int start, int end, int step)
+t_slice new_slice(int32_t start, int32_t end, int32_t step)
 {
     t_slice slice_d;
 
@@ -153,17 +179,17 @@ t_ndarray array_slicing(t_ndarray p, ...)
     t_ndarray slice;
     va_list  va;
     t_slice slice_data;
-    int start = 0;
+    int32_t start = 0;
 
     slice.nd = p.nd;
     slice.type = p.type;
     slice.type_size = p.type_size;
-    slice.shape = malloc(sizeof(int) * p.nd);
-    slice.strides = malloc(sizeof(int) * p.nd);
-    memcpy(slice.strides, p.strides, sizeof(int) * p.nd);
+    slice.shape = malloc(sizeof(int32_t) * p.nd);
+    slice.strides = malloc(sizeof(int32_t) * p.nd);
+    memcpy(slice.strides, p.strides, sizeof(int32_t) * p.nd);
     slice.is_slice = true;
     va_start(va, p);
-    for (int i = 0; i < p.nd ; i++)
+    for (int32_t i = 0; i < p.nd ; i++)
     {
         slice_data = va_arg(va, t_slice);
         slice.shape[i] = (slice_data.end - slice_data.start + (slice_data.step - 1)) / slice_data.step; // we need to round up the shape
@@ -173,7 +199,7 @@ t_ndarray array_slicing(t_ndarray p, ...)
     va_end(va);
     slice.raw_data = p.raw_data + start * p.type_size;
     slice.length = 1;
-    for (int i = 0; i < slice.nd; i++)
+    for (int32_t i = 0; i < slice.nd; i++)
             slice.length *= slice.shape[i];
     return (slice);
 }
@@ -182,18 +208,17 @@ t_ndarray array_slicing(t_ndarray p, ...)
 ** indexing
 */
 
-int get_index(t_ndarray arr, ...)
+int32_t get_index(t_ndarray arr, ...)
 {
     va_list va;
-    int index;
+    int32_t index;
 
     va_start(va, arr);
     index = 0;
-    for (int i = 0; i < arr.nd; i++)
+    for (int32_t i = 0; i < arr.nd; i++)
     {
-        index += va_arg(va, int) * arr.strides[i];
+        index += va_arg(va, int32_t) * arr.strides[i];
     }
     va_end(va);
     return (index);
 }
-
diff --git a/pyccel/stdlib/ndarrays/ndarrays.h b/pyccel/stdlib/ndarrays/ndarrays.h
index 523bfaea..daf3bd43 100644
--- a/pyccel/stdlib/ndarrays/ndarrays.h
+++ b/pyccel/stdlib/ndarrays/ndarrays.h
@@ -7,24 +7,32 @@
 # include <stdio.h>
 # include <stdarg.h>
 # include <stdbool.h>
+# include <stdint.h>
 
-# define array_fill(c, arr) _Generic((c), int : _array_fill_int,\
+/* mapping the function array_fill to the correct type */
+# define array_fill(c, arr) _Generic((c), int64_t : _array_fill_int64,\
+                                        int32_t : _array_fill_int32,\
+                                        int16_t : _array_fill_int16,\
+                                        int8_t : _array_fill_int8,\
                                         float : _array_fill_float,\
                                         double : _array_fill_double,\
+                                        bool : _array_fill_bool,\
+                                        float complex : _array_fill_cfloat,\
                                         double complex : _array_fill_cdouble)(c, arr)
 typedef struct  s_slice
 {
-    int start;
-    int end;
-    int step;
+    int32_t start;
+    int32_t end;
+    int32_t step;
 }               t_slice;
 
 enum e_types
 {
         nd_bool,
-        nd_int,
-        nd_sint,
-        nd_long,
+        nd_int8,
+        nd_int16,
+        nd_int32,
+        nd_int64,
         nd_float,
         nd_double,
         nd_cfloat,
@@ -36,47 +44,57 @@ typedef struct  s_ndarray
     /* raw data buffer*/
     union {
             char            *raw_data;
-            int             *nd_int;
+            int8_t          *nd_int8;
+            int16_t         *nd_int16;
+            int32_t         *nd_int32;
+            int64_t         *nd_int64;
             float           *nd_float;
             double          *nd_double;
+            bool            *nd_bool;
             double complex  *nd_cdouble;
             float  complex  *nd_cfloat;
-            long            *nd_long;
-            short int       *nd_sint;
-            char            *nd_char;
-            bool            *nd_bool;
             };
     /* number of dimensions */
-    int             nd;
+    int32_t                 nd;
     /* shape 'size of each dimension' */
-    int             *shape;
+    int32_t                 *shape;
     /* strides 'number of bytes to skip to get the next element' */
-    int             *strides;
+    int32_t                 *strides;
     /* type of the array elements */
-    enum e_types    type;
-    int             type_size;
-    int             length;
-    int             buffer_size;
-    bool            is_slice;
+    enum e_types        type;
+    /* type size of the array elements */
+    int32_t                 type_size;
+    /* number of element in the array */
+    int32_t                 length;
+    /* size of the array */
+    int32_t                 buffer_size;
+    bool                is_slice;
 }               t_ndarray;
 
 /* functions prototypes */
 
 /* allocations */
-t_ndarray   array_create(int nd, int *shape, enum e_types type);
-void        _array_fill_int(int c, t_ndarray arr);
+t_ndarray   array_create(int32_t nd, int32_t *shape, enum e_types type);
+void        _array_fill_int8(int8_t c, t_ndarray arr);
+void        _array_fill_int16(int16_t c, t_ndarray arr);
+void        _array_fill_int32(int32_t c, t_ndarray arr);
+void        _array_fill_int64(int64_t c, t_ndarray arr);
 void        _array_fill_float(float c, t_ndarray arr);
 void        _array_fill_double(double c, t_ndarray arr);
-void        _array_fill_cdouble(complex double c, t_ndarray arr);
+void        _array_fill_bool(bool c, t_ndarray arr);
+void        _array_fill_cfloat(float complex c, t_ndarray arr);
+void        _array_fill_cdouble(double complex c, t_ndarray arr);
 
 /* slicing */
-t_slice     new_slice(int start, int end, int step);
+                /* creating a Slice object */
+t_slice     new_slice(int32_t start, int32_t end, int32_t step);
+                /* creating an array view */
 t_ndarray   array_slicing(t_ndarray p, ...);
 
 /* free */
-int         free_array(t_ndarray dump);
+int32_t         free_array(t_ndarray dump);
 
 /* indexing */
-int         get_index(t_ndarray arr, ...);
+int32_t         get_index(t_ndarray arr, ...);
 
 #endif


Test patch:
diff --git a/tests/ndarrays/test_ndarrays.c b/tests/ndarrays/test_ndarrays.c
index f1aba096..02f2fa46 100644
--- a/tests/ndarrays/test_ndarrays.c
+++ b/tests/ndarrays/test_ndarrays.c
@@ -1,459 +1,841 @@
-#include "ndarrays.h"
-#include <unistd.h>
-
-
-#define getname(X) #X
-#define my_assert(X , Y, dscr) _Generic((X), double: assert_double,\
-                            float: assert_float,\
-                            int: assert_int,\
-                            double complex : assert_cdouble,\
-                            default: assert_ns)(X , Y, getname(X), getname(Y), dscr, __func__, __FILE__, __LINE__)
-
-void assert_double(double v1 , double v2,
-        const char *v1_name, const char *v2_name,const char *dscr,
-        const char * func, const char *file, int line)
-{
-    if (v1 != v2)
-    {
-        printf("[FAIL] %s:%d:%s\n", file, line, func);
-        printf("[INFO] %s:%f != %s:%f\n", v1_name, v1, v2_name,v2);
-        printf("[DSCR] %s\n", dscr);
-        return ;
-    }
-    printf("[PASS] %s:%d:%s\n", file, line, func);
-    printf("[DSCR] %s\n", dscr);
-}
-
-void assert_float(float v1 , float v2,
-        const char *v1_name, const char *v2_name,const char *dscr,
-        const char * func, const char *file, int line)
-{
-    if (v1 != v2)
-    {
-        printf("[FAIL] %s:%d:%s\n", file, line, func);
-        printf("[INFO] %s:%f != %s:%f\n", v1_name, v1, v2_name,v2);
-        printf("[DSCR] %s\n", dscr);
-        return ;
-    }
-    printf("[PASS] %s:%d:%s\n", file, line, func);
-    printf("[DSCR] %s\n", dscr);
-}
-
-void assert_int(int v1 , int v2,
-        const char *v1_name, const char *v2_name,const char *dscr,
-        const char * func, const char *file, int line)
-{
-    if (v1 != v2)
-    {
-        printf("[FAIL] %s:%d:%s\n", file, line, func);
-        printf("[INFO] %s:%d != %s:%d\n", v1_name, v1, v2_name,v2);
-        printf("[DSCR] %s\n", dscr);
-        return ;
-    }
-    printf("[PASS] %s:%d:%s\n", file, line, func);
-    printf("[DSCR] %s\n", dscr);
-}
-
-void assert_cdouble(double complex v1 , double complex v2,
-        const char *v1_name, const char *v2_name,const char *dscr,
-        const char * func, const char *file, int line)
-{
-    if (v1 != v2)
-    {
-        printf("[FAIL] %s:%d:%s\n", file, line, func);
-        printf("[INFO] %s:%f+%f*I != %s:%f+%f*I\n", v1_name, creal(v1), cimag(v1), v2_name,creal(v2), cimag(v2));
-        printf("[DSCR] %s\n", dscr);
-        return ;
-    }
-    printf("[PASS] %s:%d:%s\n", file, line, func);
-    printf("[DSCR] %s\n", dscr);
-}
-
-void assert_ns(float v1 , float v2,
-        const char *v1_name, const char *v2_name, const char *dscr,
-        const char * func, const char *file, int line)
-{
-    printf("[FAIL] %s:%d:%s\n", file, line, func);
-    printf("[INFO] not supported type\n");
-    printf("[DSCR] %s\n", dscr);
-}
-
-int test_indexing_int(void)
-{
-    int m_1[] = {2, 3, 5, 5, 6, 7, 10, 11,
-                12, 260, 6, 8, 8, 0, 45, 0,
-                1, 0, 0, 1, 200, 33, 5, 57,
-                62, 70, 103, 141, 122, 26, 36, 82,
-                8, 10, 4115, 22, 1, 11, 1, 19};
-    int m_1_shape[] = {5, 8};
-    t_ndarray x;
-    int index;
-    int c_index;
-    int value;
-    int c_value;
-
-    x = array_create(2, m_1_shape, nd_int);
-    memcpy(x.raw_data, m_1, x.buffer_size);
-    // testing the index [3, 2]
-    index = 3 * x.strides[0] + 2 * x.strides[1];
-    c_index = 26;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 2) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 2]
-    value = x.nd_int[index];
-    c_value = 103;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-int test_indexing_double(void)
-{
-    double m_1[] = {2, 3, 5, 5, 6, 7, 10, 11,
-                    12, 260, 6.34, 8, 8.002, 0.056, 45, 0.1,
-                    1.02, 0.25, 0.00005, 1, 200, 33, 5, 57,
-                    62, 70, 103.009, 141, 122, 26.50, 36.334, 82,
-                    8.44002, 10.056, 4115, 22.1, 1.1102, 011.25, 1.01110005, 19};
-    int m_1_shape[] = {5, 8};
-    t_ndarray x;
-    int index;
-    int c_index;
-    double value;
-    double c_value;
-
-    x = array_create(2, m_1_shape, nd_double);
-    memcpy(x.raw_data, m_1, x.buffer_size);
-    // testing the index [3, 2]
-    index = 3 * x.strides[0] + 2 * x.strides[1];
-    c_index = 26;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 2) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 2]
-    value = x.nd_double[index];
-    c_value = 103.009;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-int test_indexing_cdouble(void)
-{
-    double complex m_1[] = {0.37 + 0.588*I,  0.92689451+0.57106791*I,
-                            0.93598206+0.30289964*I,  0.54404246+0.09516331*I,
-                            0.02827254+0.00432899*I,  0.06873651+0.24810741*I,
-                            0.94040543+0.43508215*I,  0.58532094+0.67890618*I,
-                            0.68742283+0.64951155*I,  0.15372315+0.89699101*I};
-    int m_1_shape[] = {5, 2};
-    t_ndarray x;
-    int index;
-    int c_index;
-    double complex value;
-    double complex c_value;
-
-    x = array_create(2, m_1_shape, nd_cdouble);
-    memcpy(x.raw_data, m_1, x.buffer_size);
-    // testing the index [3, 1]
-    index = 3 * x.strides[0] + 1 * x.strides[1];
-    c_index = 7;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 1]
-    value = x.nd_cdouble[index];
-    c_value = 0.58532094+0.67890618*I;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-
-/* 
-**  slicing tests
-*/
-
-int test_slicing_int(void)
-{
-    int m_1[] = {2, 3, 5, 5, 6,
-                7, 10, 11, 12, 260,
-                6, 8, 8, 0, 45,
-                0, 1, 0, 0, 1,
-                200, 33, 5, 57, 62,
-                70, 103, 141, 122, 26,
-                36, 82, 8, 10, 4115,
-                22, 1, 11, 1, 19};
-    int m_1_shape[] = {8, 5};
-    t_ndarray x;
-    t_ndarray xview;
-    int c_index;
-    int value;
-    int c_value;
-
-    x = array_create(2, m_1_shape, nd_int);
-    memcpy(x.raw_data, m_1, x.buffer_size);
-    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
-    c_index = 5;
-    for (int i = 0; i < xview.shape[0]; i++)
-    {
-        for (int j = 0; j < xview.shape[1]; j++)
-        {
-            value = xview.nd_int[get_index(xview, i, j)];
-            c_value = m_1[c_index];
-            c_index+=2;
-            if (value != c_value)
-                my_assert(value , c_value, "testing xview values");
-        }
-    }
-    c_value = 1337;
-    xview.nd_int[get_index(xview, 0, 1)] = c_value;
-    value = x.nd_int[get_index(x, 1, 2)];
-    my_assert(value , c_value, "testing xview assignment");
-    free_array(x);
-    free_array(xview);
-    return (0);
-}
-
-int test_slicing_double(void)
-{
-    double m_1[] = {2, 3, 5, 5, 6,
-                    7, 10, 11, 12, 260,
-                    6.34, 8, 8.002, 0.056, 45,
-                    0.1, 1.02, 0.25, 0.00005, 1,
-                    200, 33, 5, 57, 62,
-                    103.009, 141, 122, 26.50, 36.334,
-                    82, 8.44002, 10.056, 4115, 22.1,
-                    1.1102, 011.25, 1.01110005, 19, 70};
-    int m_1_shape[] = {8, 5};
-    t_ndarray x;
-    t_ndarray xview;
-    int c_index;
-    double value;
-    double c_value;
-
-    x = array_create(2, m_1_shape, nd_double);
-    memcpy(x.raw_data, m_1, x.buffer_size);
-    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
-    c_index = 5;
-    for (int i = 0; i < xview.shape[0]; i++)
-    {
-        for (int j = 0; j < xview.shape[1]; j++)
-        {
-            value = xview.nd_double[get_index(xview, i, j)];
-            c_value = m_1[c_index];
-            c_index+=2;
-            if (value != c_value) // to not spam the test because of the loop
-                my_assert(value , c_value, "testing xview values");
-        }
-    }
-    c_value = 0.1337;
-    xview.nd_double[get_index(xview, 0, 1)] = c_value;
-    value = x.nd_double[get_index(x, 1, 2)];
-    my_assert(value, c_value, "testing xview assignment");
-    free_array(x);
-    free_array(xview);
-    return (0);
-}
-
-int test_slicing_cdouble(void)
-{
-    double complex m_1[] = {
-                    0.37 + 0.588*I,  0.92+0.57*I, 0.93+0.30*I,  0.54+0.09*I, 0.02+0.01*I,
-                    0.03+0.24*I, 0.94+0.43*I,  0.58+0.67*I, 0.68+0.64*I,  0.15+0.89*I
-                    };
-    int m_1_shape[] = {2, 5};
-    t_ndarray x;
-    t_ndarray xview;
-    int c_index;
-    double complex value;
-    double complex c_value;
-
-    x = array_create(2, m_1_shape, nd_cdouble);
-    memcpy(x.raw_data, m_1, x.buffer_size);
-    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
-    c_index = 5;
-    for (int i = 0; i < xview.shape[0]; i++)
-    {
-        for (int j = 0; j < xview.shape[1]; j++)
-        {
-            value = xview.nd_cdouble[get_index(xview, i, j)];
-            c_value = m_1[c_index];
-            c_index+=2;
-            if (value != c_value) // to not spam the test because of the loop
-                my_assert(value , c_value, "testing xview values");
-        }
-    }
-    c_value = 0.13 + 0.37*I;
-    xview.nd_cdouble[get_index(xview, 0, 1)] = c_value;
-    value = x.nd_cdouble[get_index(x, 1, 2)];
-    my_assert(value, c_value, "testing xview assignment");
-    free_array(x);
-    free_array(xview);
-    return (0);
-}
-
-/* array_fill tests */
-
-int test_array_fill_int(void)
-{
-    int m_1_shape[] = {5, 2};
-    t_ndarray x;
-    int index;
-    int c_index;
-    int value;
-    int c_value;
-
-    x = array_create(2, m_1_shape, nd_int);
-    array_fill(32, x);
-    // testing the index [3, 1]
-    index = 3 * x.strides[0] + 1 * x.strides[1];
-    c_index = 7;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 1]
-    value = x.nd_int[index];
-    c_value = 32;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-int test_array_fill_double(void)
-{
-    int m_1_shape[] = {5, 2};
-    t_ndarray x;
-    int index;
-    int c_index;
-    double value;
-    double c_value;
-
-    x = array_create(2, m_1_shape, nd_double);
-    array_fill(2., x);
-    // testing the index [3, 1]
-    index = 3 * x.strides[0] + 1 * x.strides[1];
-    c_index = 7;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 1]
-    value = x.nd_double[index];
-    c_value = 2.;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-int test_array_fill_cdouble(void)
-{
-    int m_1_shape[] = {5, 2};
-    t_ndarray x;
-    int index;
-    int c_index;
-    double complex value;
-    double complex c_value;
-
-    x = array_create(2, m_1_shape, nd_cdouble);
-    array_fill(0.3+0.54*I, x);
-    // testing the index [3, 1]
-    index = 3 * x.strides[0] + 1 * x.strides[1];
-    c_index = 7;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 1]
-    value = x.nd_cdouble[index];
-    c_value = 0.3+0.54*I;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-/* array_zeros tests */
-
-int test_array_zeros_double(void)
-{
-    int m_1_shape[] = {5, 2};
-    t_ndarray x;
-    int index;
-    int c_index;
-    double value;
-    double c_value;
-
-    x = array_create(2, m_1_shape, nd_double);
-    array_fill(0, x);
-    // testing the index [3, 1]
-    index = 3 * x.strides[0] + 1 * x.strides[1];
-    c_index = 7;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 1]
-    value = x.nd_double[index];
-    c_value = 0.;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-int test_array_zeros_int(void)
-{
-    int m_1_shape[] = {5, 2};
-    t_ndarray x;
-    int index;
-    int c_index;
-    int value;
-    int c_value;
-
-    x = array_create(2, m_1_shape, nd_int);
-    array_fill(0, x);
-    // testing the index [3, 1]
-    index = 3 * x.strides[0] + 1 * x.strides[1];
-    c_index = 7;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 1]
-    value = x.nd_int[index];
-    c_value = 0;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-int test_array_zeros_cdouble(void)
-{
-    int m_1_shape[] = {5, 2};
-    t_ndarray x;
-    int index;
-    int c_index;
-    double complex value;
-    double complex c_value;
-
-    x = array_create(2, m_1_shape, nd_cdouble);
-    array_fill(0, x);
-    // testing the index [3, 1]
-    index = 3 * x.strides[0] + 1 * x.strides[1];
-    c_index = 7;
-    my_assert(index , c_index, "testing the strides");
-    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
-    // testing the value with the index [3, 1]
-    value = x.nd_cdouble[index];
-    c_value = 0+0*I;
-    my_assert(value , c_value, "testing the value");
-    free_array(x);
-    return (0);
-}
-
-int main(void)
-{
-    /* indexing tests */
-    test_indexing_double();
-    test_indexing_int();
-    test_indexing_cdouble();
-    /* slicing tests */
-    test_slicing_double();
-    test_slicing_int();
-    test_slicing_cdouble();
-    /* array_fill tests */
-    test_array_fill_int();
-    test_array_fill_double();
-    test_array_fill_cdouble();
-    /* array_zeros tests */
-    test_array_zeros_int();
-    test_array_zeros_double();
-    test_array_zeros_cdouble();
-    return (0);
-}
+#include "ndarrays.h"
+#include <unistd.h>
+
+
+#define getname(X) #X
+#define my_assert(X , Y, dscr) _Generic((X), double: assert_double,\
+                            float: assert_float,\
+                            int64_t: assert_int64,\
+                            int32_t: assert_int32,\
+                            int16_t: assert_int16,\
+                            int8_t: assert_int8,\
+                            float complex : assert_cfloat,\
+                            double complex : assert_cdouble,\
+                            default: assert_ns)(X , Y, getname(X), getname(Y), dscr, __func__, __FILE__, __LINE__)
+
+void assert_double(double v1 , double v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%f != %s:%f\n", v1_name, v1, v2_name,v2);
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_float(float v1 , float v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%f != %s:%f\n", v1_name, v1, v2_name,v2);
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_int64(int64_t v1 , int64_t v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%ld != %s:%ld\n", v1_name, v1, v2_name,v2);
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_int32(int32_t v1 , int32_t v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%d != %s:%d\n", v1_name, v1, v2_name,v2);
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_int16(int16_t v1 , int16_t v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%d != %s:%d\n", v1_name, v1, v2_name,v2);
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_int8(int8_t v1 , int8_t v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%d != %s:%d\n", v1_name, v1, v2_name,v2);
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_cfloat(float complex v1 , float complex v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%f+%f*I != %s:%f+%f*I\n", v1_name, creal(v1), cimag(v1), v2_name,creal(v2), cimag(v2));
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_cdouble(double complex v1 , double complex v2,
+        const char *v1_name, const char *v2_name,const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    if (v1 != v2)
+    {
+        printf("[FAIL] %s:%d:%s\n", file, line, func);
+        printf("[INFO] %s:%f+%f*I != %s:%f+%f*I\n", v1_name, creal(v1), cimag(v1), v2_name,creal(v2), cimag(v2));
+        printf("[DSCR] %s\n", dscr);
+        return ;
+    }
+    printf("[PASS] %s:%d:%s\n", file, line, func);
+    printf("[DSCR] %s\n", dscr);
+}
+
+void assert_ns(float v1 , float v2,
+        const char *v1_name, const char *v2_name, const char *dscr,
+        const char * func, const char *file, int32_t line)
+{
+    printf("[FAIL] %s:%d:%s\n", file, line, func);
+    printf("[INFO] not supported type\n");
+    printf("[DSCR] %s\n", dscr);
+}
+
+int32_t test_indexing_int64(void)
+{
+    int64_t m_1[] = {2, 3, 5, 5, 6, 7, 10, 11,
+                12, 260, 6, 8, 8, 0, 45, 0,
+                1, 0, 0, 1, 200, 33, 5, 57,
+                62, 70, 103, 141, 122, 26, 36, 82,
+                8, 10, 4115, 22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {5, 8};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int64_t value;
+    int64_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int64);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    // testing the index [3, 2]
+    index = 3 * x.strides[0] + 2 * x.strides[1];
+    c_index = 26;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 2) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 2]
+    value = x.nd_int64[index];
+    c_value = 103;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_indexing_int32(void)
+{
+    int32_t m_1[] = {2, 3, 5, 5, 6, 7, 10, 11,
+                12, 260, 6, 8, 8, 0, 45, 0,
+                1, 0, 0, 1, 200, 33, 5, 57,
+                62, 70, 103, 141, 122, 26, 36, 82,
+                8, 10, 4115, 22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {5, 8};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int32_t value;
+    int32_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int32);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    // testing the index [3, 2]
+    index = 3 * x.strides[0] + 2 * x.strides[1];
+    c_index = 26;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 2) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 2]
+    value = x.nd_int32[index];
+    c_value = 103;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_indexing_int16(void)
+{
+    int16_t m_1[] = {2, 3, 5, 5, 6, 7, 10, 11,
+                12, 260, 6, 8, 8, 0, 45, 0,
+                1, 0, 0, 1, 200, 33, 5, 57,
+                62, 70, 103, 141, 122, 26, 36, 82,
+                8, 10, 4115, 22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {5, 8};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int16_t value;
+    int16_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int16);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    // testing the index [3, 2]
+    index = 3 * x.strides[0] + 2 * x.strides[1];
+    c_index = 26;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 2) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 2]
+    value = x.nd_int16[index];
+    c_value = 103;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_indexing_int8(void)
+{
+    int8_t m_1[] = {2, 3, 5, 5, 6, 7, 10, 11,
+                12, 250, 6, 8, 8, 0, 45, 0,
+                1, 0, 0, 1, 200, 33, 5, 57,
+                62, 70, 103, 141, 122, 26, 36, 82,
+                8, 10, 251, 22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {5, 8};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int8_t value;
+    int8_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int8);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    // testing the index [3, 2]
+    index = 3 * x.strides[0] + 2 * x.strides[1];
+    c_index = 26;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 2) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 2]
+    value = x.nd_int8[index];
+    c_value = 103;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_indexing_double(void)
+{
+    double m_1[] = {2, 3, 5, 5, 6, 7, 10, 11,
+                    12, 260, 6.34, 8, 8.002, 0.056, 45, 0.1,
+                    1.02, 0.25, 0.00005, 1, 200, 33, 5, 57,
+                    62, 70, 103.009, 141, 122, 26.50, 36.334, 82,
+                    8.44002, 10.056, 4115, 22.1, 1.1102, 011.25, 1.01110005, 19};
+    int32_t m_1_shape[] = {5, 8};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    double value;
+    double c_value;
+
+    x = array_create(2, m_1_shape, nd_double);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    // testing the index [3, 2]
+    index = 3 * x.strides[0] + 2 * x.strides[1];
+    c_index = 26;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 2) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 2]
+    value = x.nd_double[index];
+    c_value = 103.009;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_indexing_cdouble(void)
+{
+    double complex m_1[] = {0.37 + 0.588*I,  0.92689451+0.57106791*I,
+                            0.93598206+0.30289964*I,  0.54404246+0.09516331*I,
+                            0.02827254+0.00432899*I,  0.06873651+0.24810741*I,
+                            0.94040543+0.43508215*I,  0.58532094+0.67890618*I,
+                            0.68742283+0.64951155*I,  0.15372315+0.89699101*I};
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    double complex value;
+    double complex c_value;
+
+    x = array_create(2, m_1_shape, nd_cdouble);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_cdouble[index];
+    c_value = 0.58532094+0.67890618*I;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_indexing_cfloat(void)
+{
+    float complex m_1[] = {0.37 + 0.588*I,  0.92689451+0.57106791*I,
+                            0.93598206+0.30289964*I,  0.54404246+0.09516331*I,
+                            0.02827254+0.00432899*I,  0.06873651+0.24810741*I,
+                            0.94040543+0.43508215*I,  0.58532094+0.67890618*I,
+                            0.68742283+0.64951155*I,  0.15372315+0.89699101*I};
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    float complex value;
+    float complex c_value;
+
+    x = array_create(2, m_1_shape, nd_cfloat);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_cfloat[index];
+    c_value = 0.58532094+0.67890618*I;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+/* 
+**  slicing tests
+*/
+
+int32_t test_slicing_int64(void)
+{
+    int64_t m_1[] = {2, 3, 5, 5, 6,
+                7, 10, 11, 12, 260,
+                6, 8, 8, 0, 45,
+                0, 1, 0, 0, 1,
+                200, 33, 5, 57, 62,
+                70, 103, 141, 122, 26,
+                36, 82, 8, 10, 4115,
+                22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {8, 5};
+    t_ndarray x;
+    t_ndarray xview;
+    int32_t c_index;
+    int64_t value;
+    int64_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int64);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
+    c_index = 5;
+    for (int32_t i = 0; i < xview.shape[0]; i++)
+    {
+        for (int32_t j = 0; j < xview.shape[1]; j++)
+        {
+            value = xview.nd_int64[get_index(xview, i, j)];
+            c_value = m_1[c_index];
+            c_index+=2;
+            if (value != c_value)
+                my_assert(value , c_value, "testing xview values");
+        }
+    }
+    c_value = 1337;
+    xview.nd_int64[get_index(xview, 0, 1)] = c_value;
+    value = x.nd_int64[get_index(x, 1, 2)];
+    my_assert(value , c_value, "testing xview assignment");
+    free_array(x);
+    free_array(xview);
+    return (0);
+}
+
+int32_t test_slicing_int32(void)
+{
+    int32_t m_1[] = {2, 3, 5, 5, 6,
+                7, 10, 11, 12, 260,
+                6, 8, 8, 0, 45,
+                0, 1, 0, 0, 1,
+                200, 33, 5, 57, 62,
+                70, 103, 141, 122, 26,
+                36, 82, 8, 10, 4115,
+                22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {8, 5};
+    t_ndarray x;
+    t_ndarray xview;
+    int32_t c_index;
+    int32_t value;
+    int32_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int32);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
+    c_index = 5;
+    for (int32_t i = 0; i < xview.shape[0]; i++)
+    {
+        for (int32_t j = 0; j < xview.shape[1]; j++)
+        {
+            value = xview.nd_int32[get_index(xview, i, j)];
+            c_value = m_1[c_index];
+            c_index+=2;
+            if (value != c_value)
+                my_assert(value , c_value, "testing xview values");
+        }
+    }
+    c_value = 1337;
+    xview.nd_int32[get_index(xview, 0, 1)] = c_value;
+    value = x.nd_int32[get_index(x, 1, 2)];
+    my_assert(value , c_value, "testing xview assignment");
+    free_array(x);
+    free_array(xview);
+    return (0);
+}
+int32_t test_slicing_int16(void)
+{
+    int16_t m_1[] = {2, 3, 5, 5, 6,
+                7, 10, 11, 12, 260,
+                6, 8, 8, 0, 45,
+                0, 1, 0, 0, 1,
+                200, 33, 5, 57, 62,
+                70, 103, 141, 122, 26,
+                36, 82, 8, 10, 4115,
+                22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {8, 5};
+    t_ndarray x;
+    t_ndarray xview;
+    int32_t c_index;
+    int16_t value;
+    int16_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int16);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
+    c_index = 5;
+    for (int32_t i = 0; i < xview.shape[0]; i++)
+    {
+        for (int32_t j = 0; j < xview.shape[1]; j++)
+        {
+            value = xview.nd_int16[get_index(xview, i, j)];
+            c_value = m_1[c_index];
+            c_index+=2;
+            if (value != c_value)
+                my_assert(value , c_value, "testing xview values");
+        }
+    }
+    c_value = 1337;
+    xview.nd_int16[get_index(xview, 0, 1)] = c_value;
+    value = x.nd_int16[get_index(x, 1, 2)];
+    my_assert(value , c_value, "testing xview assignment");
+    free_array(x);
+    free_array(xview);
+    return (0);
+}
+
+int32_t test_slicing_int8(void)
+{
+    int8_t m_1[] = {2, 3, 5, 5, 6,
+                7, 10, 11, 12, 250,
+                6, 8, 8, 0, 45,
+                0, 1, 0, 0, 1,
+                200, 33, 5, 57, 62,
+                70, 103, 141, 122, 26,
+                36, 82, 8, 10, 251,
+                22, 1, 11, 1, 19};
+    int32_t m_1_shape[] = {8, 5};
+    t_ndarray x;
+    t_ndarray xview;
+    int32_t c_index;
+    int8_t value;
+    int8_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int8);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
+    c_index = 5;
+    for (int32_t i = 0; i < xview.shape[0]; i++)
+    {
+        for (int32_t j = 0; j < xview.shape[1]; j++)
+        {
+            value = xview.nd_int8[get_index(xview, i, j)];
+            c_value = m_1[c_index];
+            c_index+=2;
+            if (value != c_value)
+                my_assert(value , c_value, "testing xview values");
+        }
+    }
+    c_value = 133;
+    xview.nd_int8[get_index(xview, 0, 1)] = c_value;
+    value = x.nd_int8[get_index(x, 1, 2)];
+    my_assert(value , c_value, "testing xview assignment");
+    free_array(x);
+    free_array(xview);
+    return (0);
+}
+
+int32_t test_slicing_double(void)
+{
+    double m_1[] = {2, 3, 5, 5, 6,
+                    7, 10, 11, 12, 260,
+                    6.34, 8, 8.002, 0.056, 45,
+                    0.1, 1.02, 0.25, 0.00005, 1,
+                    200, 33, 5, 57, 62,
+                    103.009, 141, 122, 26.50, 36.334,
+                    82, 8.44002, 10.056, 4115, 22.1,
+                    1.1102, 011.25, 1.01110005, 19, 70};
+    int32_t m_1_shape[] = {8, 5};
+    t_ndarray x;
+    t_ndarray xview;
+    int32_t c_index;
+    double value;
+    double c_value;
+
+    x = array_create(2, m_1_shape, nd_double);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
+    c_index = 5;
+    for (int32_t i = 0; i < xview.shape[0]; i++)
+    {
+        for (int32_t j = 0; j < xview.shape[1]; j++)
+        {
+            value = xview.nd_double[get_index(xview, i, j)];
+            c_value = m_1[c_index];
+            c_index+=2;
+            if (value != c_value) // to not spam the test because of the loop
+                my_assert(value , c_value, "testing xview values");
+        }
+    }
+    c_value = 0.1337;
+    xview.nd_double[get_index(xview, 0, 1)] = c_value;
+    value = x.nd_double[get_index(x, 1, 2)];
+    my_assert(value, c_value, "testing xview assignment");
+    free_array(x);
+    free_array(xview);
+    return (0);
+}
+
+int32_t test_slicing_cdouble(void)
+{
+    double complex m_1[] = {
+                    0.37 + 0.588*I,  0.92+0.57*I, 0.93+0.30*I,  0.54+0.09*I, 0.02+0.01*I,
+                    0.03+0.24*I, 0.94+0.43*I,  0.58+0.67*I, 0.68+0.64*I,  0.15+0.89*I
+                    };
+    int32_t m_1_shape[] = {2, 5};
+    t_ndarray x;
+    t_ndarray xview;
+    int32_t c_index;
+    double complex value;
+    double complex c_value;
+
+    x = array_create(2, m_1_shape, nd_cdouble);
+    memcpy(x.raw_data, m_1, x.buffer_size);
+    xview = array_slicing(x, new_slice(1, 2, 1), new_slice(0, 5, 2));
+    c_index = 5;
+    for (int32_t i = 0; i < xview.shape[0]; i++)
+    {
+        for (int32_t j = 0; j < xview.shape[1]; j++)
+        {
+            value = xview.nd_cdouble[get_index(xview, i, j)];
+            c_value = m_1[c_index];
+            c_index+=2;
+            if (value != c_value) // to not spam the test because of the loop
+                my_assert(value , c_value, "testing xview values");
+        }
+    }
+    c_value = 0.13 + 0.37*I;
+    xview.nd_cdouble[get_index(xview, 0, 1)] = c_value;
+    value = x.nd_cdouble[get_index(x, 1, 2)];
+    my_assert(value, c_value, "testing xview assignment");
+    free_array(x);
+    free_array(xview);
+    return (0);
+}
+
+/* array_fill tests */
+
+int32_t test_array_fill_int64(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int64_t value;
+    int64_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int64);
+    array_fill((int64_t)32, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_int64[index];
+    c_value = 32;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_array_fill_int32(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int32_t value;
+    int32_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int32);
+    array_fill((int32_t)32, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_int32[index];
+    c_value = 32;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_array_fill_int16(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int16_t value;
+    int16_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int16);
+    array_fill((int16_t)32, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_int16[index];
+    c_value = 32;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_array_fill_int8(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int8_t value;
+    int8_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int8);
+    array_fill((int8_t)32, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_int8[index];
+    c_value = 32;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_array_fill_double(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    double value;
+    double c_value;
+
+    x = array_create(2, m_1_shape, nd_double);
+    array_fill(2., x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_double[index];
+    c_value = 2.;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_array_fill_cdouble(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    double complex value;
+    double complex c_value;
+
+    x = array_create(2, m_1_shape, nd_cdouble);
+    array_fill(0.3+0.54*I, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_cdouble[index];
+    c_value = 0.3+0.54*I;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+/* array_zeros tests */
+
+int32_t test_array_zeros_double(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    double value;
+    double c_value;
+
+    x = array_create(2, m_1_shape, nd_double);
+    array_fill(0, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_double[index];
+    c_value = 0.;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_array_zeros_int32(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    int32_t value;
+    int32_t c_value;
+
+    x = array_create(2, m_1_shape, nd_int32);
+    array_fill(0, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_int32[index];
+    c_value = 0;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t test_array_zeros_cdouble(void)
+{
+    int32_t m_1_shape[] = {5, 2};
+    t_ndarray x;
+    int32_t index;
+    int32_t c_index;
+    double complex value;
+    double complex c_value;
+
+    x = array_create(2, m_1_shape, nd_cdouble);
+    array_fill(0, x);
+    // testing the index [3, 1]
+    index = 3 * x.strides[0] + 1 * x.strides[1];
+    c_index = 7;
+    my_assert(index , c_index, "testing the strides");
+    my_assert(get_index(x, 3, 1) , c_index, "testing the indexing function");
+    // testing the value with the index [3, 1]
+    value = x.nd_cdouble[index];
+    c_value = 0+0*I;
+    my_assert(value , c_value, "testing the value");
+    free_array(x);
+    return (0);
+}
+
+int32_t main(void)
+{
+    /* indexing tests */
+    test_indexing_double();
+    test_indexing_int64();
+    test_indexing_int32();
+    test_indexing_int16();
+    test_indexing_int8();
+    test_indexing_cdouble();
+    /* slicing tests */
+    test_slicing_double();
+    test_slicing_int64();
+    test_slicing_int32();
+    test_slicing_int16();
+    test_slicing_int8();
+    test_slicing_cdouble();
+    /* array_fill tests */
+    test_array_fill_int64();
+    test_array_fill_int32();
+    test_array_fill_int16();
+    test_array_fill_int8();
+    test_array_fill_double();
+    test_array_fill_cdouble();
+    /* array_zeros tests */
+    test_array_zeros_int32();
+    test_array_zeros_double();
+    test_array_zeros_cdouble();
+    return (0);
+}