wish of those help Your typemaps and your declaration of the array_add function are not valid. NumPy arrays always have a size and this has to be communicated to C++. There is quite extensive documentation for the usage of

.

code :

```
int add(int x, int y) { return x + y; }
int sub(int x, int y) { return x - y; }
```

```
#include <algorithm>
#include <iostream>
class Example {
public:
void array_add(int *a, int len_a, int *b, int len_b, int *c, int len_c) {
int const max = std::max(len_a, std::max(len_b, len_c));
for (int i = 0; i < max; ++i) {
c[i] = a[i] + b[i];
}
}
};
```

```
%module example
%{
#define SWIG_FILE_WITH_INIT
#include "example.h"
%}
%include "numpy.i"
%init %{
import_array();
%}
%apply (int *IN_ARRAY1, int DIM1) { (int *a, int len_a), (int *b, int len_b) };
%apply (int *INPLACE_ARRAY1, int DIM1) { (int *c, int len_c) };
%include "example.h"
```

```
import example
import numpy as np
E = example.Example()
a = np.array([1,1], dtype=np.int32)
b = np.array([1,1], dtype=np.int32)
c = np.array([1,1], dtype=np.int32)
E.array_add(a,b,c)
print(c)
```

```
$ swig -python -c++ example.i
$ clang++ -Wall -Wextra -Wpedantic -I/usr/include/python2.7 -fPIC -shared example_wrap.cxx -o _example.so -lpython2.7
$ python test.py
[2 2]
```