[Numpy-discussion] SWIGed function does not like my boolean array
Matthieu Brucher
matthieu.brucher@gmail....
Wed Nov 7 09:45:14 CST 2007
Unfortunately, operations on boolean are not the same as operations on
integers, so you can't replace one with another.
Matthieu
2007/11/7, Sebastian Haase <haase@msg.ucsf.edu>:
>
> O.K., so sizeof(bool) is 1.
> But I already have a function instantiation for uint8.
>
> The problem is that without doing "some magic" the compiler (?, or
> numpy ?) would never allow to use anything but a "dedicated"
> bool-typed function for bool.
> Even though the CPU treats bool exactly like an integer of same
> byte-width.
>
> How can I have numpy (or is SWIG the problem ??) use my existing
> integer function for a bool-type array ?
> (Without making a differently-typed copy of course ...)
>
> Thanks,
> Sebastian
>
> PS: I'm not using the C++ std library.
>
>
> On Nov 7, 2007 2:54 PM, Matthieu Brucher <matthieu.brucher@gmail.com>
> wrote:
> > Hi,
> >
> > No, a bool is not an int32. Try just sizeof(bool) to be sure (on my box,
> > it's one).
> > Besides, if you use a std::vector of bool, be aware of the fact that it
> is
> > not like the other vectors.
> >
> > Matthieu
> >
> > 2007/11/7, Sebastian Haase <haase@msg.ucsf.edu>:
> > >
> > >
> > >
> > > Hi,
> > > I have a templated function written in C++.
> > > My SWIG typemap instantiates this for many argument array types (such
> > > as unit8, int16, uint16, int32, float32,float64,...)
> > > All works well, except when feeding in a boolean array as in
> > > seb.mmms(a>6)
> > > I get this error:
> > > NotImplementedError: No matching function for overloaded 'mmms'
> > >
> > > What should I do ?
> > > Preferably I would avoid having to add another type-instantiation into
> > > the library (it looks already quite bloated having 6+ versions of
> > > every function). Isn't bool just a synonym for int32 ?
> > >
> > > Thanks
> > > Sebastian Haase
> > > _______________________________________________
> > > Numpy-discussion mailing list
> > > Numpy-discussion@scipy.org
> > > http://projects.scipy.org/mailman/listinfo/numpy-discussion
> > >
> >
> >
> >
> > --
> > French PhD student
> > Website : http://miles.developpez.com/
> > Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
> > LinkedIn : http://www.linkedin.com/in/matthieubrucher
> > _______________________________________________
> > Numpy-discussion mailing list
> > Numpy-discussion@scipy.org
> > http://projects.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
French PhD student
Website : http://miles.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071107/b73dc4a5/attachment-0001.html
More information about the Numpy-discussion
mailing list