swig
swig copied to clipboard
Output typemap of int should be double
The MATLAB int64 type is quite rarely used in practise. If you call numel(zeros(3))
or shape(zeros(3))
you'll get a double and a vector of doubles respectively. Therefore, it makes sense to have a int in C/C++ map to double in MATLAB by default.
Since the IEEE floating point standard guarantees that integers up to a certain number are represented exactly, I see no problem with this.
@KrisThielemans @ibell @tesch1 - any objections?
it's one of those things that I hate in MATLAB. Nevertheless, I think your suggestion makes sense. how would this work when then call a function expecting an int as argument? I guess this already works now, but I wouldn't want to break something like
functionExpectingInt(functionReturningInt())
This won't influence that. There would still be a "MATLAB double"-to-"C++ int" input typemap. We are talking about how to define the output typemap.