Note that scalars and arrays are quite different in numpy. np.complex64
(this is 32-bit float, just to note, not double precision). You will not be able to change the array like that, you will need to subclass the array instead and then override its __add__
and __sub__
.
If that is all you want to do, it should just work otherwise look at http://docs.scipy.org/doc/numpy/user/basics.subclassing.html since subclassing an array is not that simple.
However if you want to use this type also as a scalar. For example you want to index scalars out, it gets more difficult at least currently. You can get a little further by defining __array_wrap__
to convert to scalars to your own scalar type for some reduce functions, for indexing to work in all cases it appears to me that you may have define your own __getitem__
currently.
In all cases with this approach, you still use the complex datatype, and all functions that are not explicitly overridden will still behave the same. @ecatmur mentioned that you can create new datatypes from the C side, if that is really what you want.