[C++-sig] Initialize SparseVector

Nicodemus nicodemus at esss.com.br
Wed Apr 13 16:27:39 CEST 2005


Hi Achim,

Take a look at make_constructor. I don't have time right now to provide 
an example, but this should get you going.

Regards,
Bruno.

Achim Domma (Procoders) wrote:

> Hi,
>
> I have wrapped a sparse vector class, which currently can be used like 
> this:
>
> v=svm.vector()
> v[3]=7
> v[9]=-3.2
> v[5]=0.3
> ...
>
> Everything works finde so far, but I want to implement a more pythonic 
> way to initialize the vector. Something like this would be nice:
>
> v=svm.vector( (3,7), (9,-3.2), (5,0.3), ... )
>
> What's the easiest way to get something like this with boost.python? I 
> have control over the complete code, so small modifications on the 
> sparse vector class would be no problem.
>
> regards,
> Achim
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
>




More information about the Cplusplus-sig mailing list