PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/li_std_vectora.i

#
Swig | 65 lines | 44 code | 21 blank | 0 comment | 0 complexity | bbbad666f882bed82e39ddaf8044faa5 MD5 | raw file
 1%module li_std_vectora
 2
 3%include std_vectora.i
 4
 5
 6%{
 7#include <algorithm>
 8#include <functional>
 9#include <numeric>
10%}
11
12
13%template(vector_i) std::vector<int, std::allocator<int> >;
14
15%template(matrix_i) std::vector<std::vector<int,std::allocator<int> >,std::allocator<std::vector<int,std::allocator<int> > > >;
16
17%inline 
18{
19  typedef 
20    std::vector<std::vector<int,std::allocator<int> >,
21                std::allocator<std::vector<int,std::allocator<int> > > >
22    imatrix;
23
24  std::vector<int> vident(const std::vector<int,std::allocator<int> >& v)
25  {
26    return v;
27  }
28
29  imatrix mident(const imatrix& v)
30  {
31    return v;
32  }
33}
34
35
36%template(DoubleVector) std::vector<double, std::allocator<double> >;
37
38%inline %{
39typedef float Real;
40%}
41
42namespace std {
43  %template(RealVector) vector<Real, std::allocator<Real> >;
44}
45
46%inline %{
47
48double average(std::vector<int, std::allocator<int> > v) {
49    return std::accumulate(v.begin(),v.end(),0.0)/v.size();
50}
51
52std::vector<Real,std::allocator<Real> >
53half(const std::vector<Real,std::allocator<Real> >& v) {
54    std::vector<Real> w(v);
55    for (unsigned int i=0; i<w.size(); i++)
56        w[i] /= 2.0;
57    return w;
58}
59
60%}
61
62%template(IntPtrVector) std::vector<int *,std::allocator<int *> >;
63
64
65