PageRenderTime 37ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/test-suite/python/li_std_vectora.i

#
Swig | 65 lines | 44 code | 21 blank | 0 comment | 0 complexity | bbbad666f882bed82e39ddaf8044faa5 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module li_std_vectora
  2. %include std_vectora.i
  3. %{
  4. #include <algorithm>
  5. #include <functional>
  6. #include <numeric>
  7. %}
  8. %template(vector_i) std::vector<int, std::allocator<int> >;
  9. %template(matrix_i) std::vector<std::vector<int,std::allocator<int> >,std::allocator<std::vector<int,std::allocator<int> > > >;
  10. %inline
  11. {
  12. typedef
  13. std::vector<std::vector<int,std::allocator<int> >,
  14. std::allocator<std::vector<int,std::allocator<int> > > >
  15. imatrix;
  16. std::vector<int> vident(const std::vector<int,std::allocator<int> >& v)
  17. {
  18. return v;
  19. }
  20. imatrix mident(const imatrix& v)
  21. {
  22. return v;
  23. }
  24. }
  25. %template(DoubleVector) std::vector<double, std::allocator<double> >;
  26. %inline %{
  27. typedef float Real;
  28. %}
  29. namespace std {
  30. %template(RealVector) vector<Real, std::allocator<Real> >;
  31. }
  32. %inline %{
  33. double average(std::vector<int, std::allocator<int> > v) {
  34. return std::accumulate(v.begin(),v.end(),0.0)/v.size();
  35. }
  36. std::vector<Real,std::allocator<Real> >
  37. half(const std::vector<Real,std::allocator<Real> >& v) {
  38. std::vector<Real> w(v);
  39. for (unsigned int i=0; i<w.size(); i++)
  40. w[i] /= 2.0;
  41. return w;
  42. }
  43. %}
  44. %template(IntPtrVector) std::vector<int *,std::allocator<int *> >;