File: numeric.html

package info (click to toggle)
boost 1.33.1-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 100,948 kB
  • ctags: 145,103
  • sloc: cpp: 573,492; xml: 49,055; python: 15,626; ansic: 13,588; sh: 2,099; yacc: 858; makefile: 660; perl: 427; lex: 111; csh: 6
file content (267 lines) | stat: -rw-r--r-- 9,297 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 1st August 2002), see www.w3.org">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="../boost.css">

    <title>Boost.Python - &lt;boost/python/numeric.hpp&gt;</title>
  </head>

  <body>
    <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
    "header">
      <tr>
        <td valign="top" width="300">
          <h3><a href="../../../../index.htm"><img height="86" width="277"
          alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3>
        </td>

        <td valign="top">
          <h1 align="center"><a href="../index.html">Boost.Python</a></h1>

          <h2 align="center">Header &lt;boost/python/numeric.hpp&gt;</h2>
        </td>
      </tr>
    </table>
    <hr>

    <h2>Contents</h2>

    <dl class="page-index">
      <dt><a href="#introduction">Introduction</a></dt>

      <dt><a href="#classes">Classes</a></dt>

      <dd>
        <dl class="page-index">
          <dt><a href="#array-spec">Class <code>array</code></a></dt>

          <dd>
            <dl class="page-index">
              <dt><a href="#array-spec-synopsis">Class <code>array</code>
              synopsis</a></dt>

              <dt><a href="#array-spec-observers">Class <code>array</code>
              observer functions</a></dt>

              <dt><a href="#array-spec-statics">Class <code>array</code>
              static functions</a></dt>
            </dl>
          </dd>
        </dl>
      </dd>

      <dt><a href="#examples">Example(s)</a></dt>
    </dl>
    <hr>

    <h2><a name="introduction"></a>Introduction</h2>

    <p>Exposes a <a href=
    "ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> for the Python
    <a href=
    "http://www.python.org/dev/doc/devel/lib/typesmapping.html">array</a>
    type.</p>

    <h2><a name="classes"></a>Classes</h2>

    <h3><a name="array-spec"></a>Class <code>array</code></h3>

    <p>Provides access to the array types of <a href=
    "http://www.pfdubois.com/numpy/">Numerical Python</a>'s <a href=
    "http://www.pfdubois.com/numpy/#Numeric">Numeric</a> and <a href=
    "http://stsdas.stsci.edu/numarray/index.html">NumArray</a> modules. With
    the exception of the functions documented <a href=
    "#array-spec-observers">below</a>, the semantics of the constructors and
    member functions defined below can be fully understood by reading the <a
    href="ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> concept
    definition. Since <code>array</code> is publicly derived from <code><a
    href="object.html#object-spec">object</a></code>, the public object
    interface applies to <code>array</code> instances as well.</p>

    <p><a name="default_search"></a>The default behavior is to use
    <code>numarray.NDArray</code> as the associated Python type if the
    <code>numarray</code> module is installed in the default location.
    Otherwise it falls back to use <code>Numeric.ArrayType</code>. If neither
    extension module is installed, conversions to arguments of type
    <code>numeric::array</code> will cause overload resolution to reject the
    overload, and other attempted uses of <code>numeric::array</code> will <a
    href="definitions.html#raise">raise</a> an appropriate Python exception.
    The associated Python type can be set manually using the <code><a href=
    "#array-spec-statics">set_module_and_type</a>(...)</code> static
    function.</p>

    <h4><a name="array-spec-synopsis"></a>Class <code>array</code>
    synopsis</h4>
<pre>
namespace boost { namespace python { namespace numeric
{
   class array : public object
   {
    public:
      object astype();
      template &lt;class Type&gt;
      object astype(Type const&amp; type_);

      template &lt;class Type&gt;
      object new_(Type const&amp; type_) const;

      template &lt;class Sequence&gt; 
      void resize(Sequence const&amp; x);
      void resize(long x1);
      void resize(long x1, long x2);
      ...
      void resize(long x1, long x2,...long x<i>n</i>);

      template &lt;class Sequence&gt; 
      void setshape(Sequence const&amp; x);
      void setshape(long x1);
      void setshape(long x1, long x2);
      ...
      void setshape(long x1, long x2,...long x<i>n</i>);

      template &lt;class Indices, class Values&gt;
      void put(Indices const&amp; indices, Values const&amp; values);

      template &lt;class Sequence&gt;
      object take(Sequence const&amp; sequence, long axis = 0);

      template &lt;class File&gt;
      void tofile(File const&amp; f) const;

      object factory();
      template &lt;class Buffer&gt;
      object factory(Buffer const&amp;);
      template &lt;class Buffer, class Type&gt;
      object factory(Buffer const&amp;, Type const&amp;);
      template &lt;class Buffer, class Type, class Shape&gt;
      object factory(Buffer const&amp;, Type const&amp;, Shape const&amp;, bool copy = true, bool savespace = false);
      template &lt;class Buffer, class Type, class Shape&gt;
      object factory(Buffer const&amp;, Type const&amp;, Shape const&amp;, bool copy, bool savespace, char typecode);

      template &lt;class T1&gt;
      explicit array(T1 const&amp; x1);
      template &lt;class T1, class T2&gt;
      explicit array(T1 const&amp; x1, T2 const&amp; x2);
      ...
      template &lt;class T1, class T2,...class T<i>n</i>&gt;
      explicit array(T1 const&amp; x1, T2 const&amp; x2,...T<i>n</i> const&amp; xn);

      static void set_module_and_type();
      static void set_module_and_type(char const* package_path = 0, char const* type_name = 0);

      object argmax(long axis=-1);

      object argmin(long axis=-1);

      object argsort(long axis=-1);

      void byteswap();

      object copy() const;

      object diagonal(long offset = 0, long axis1 = 0, long axis2 = 1) const;

      void info() const;

      bool is_c_array() const;
      bool isbyteswapped() const;
      void sort();
      object trace(long offset = 0, long axis1 = 0, long axis2 = 1) const;
      object type() const;
      char typecode() const;
      
      object getflat() const;
      long getrank() const;
      object getshape() const;
      bool isaligned() const;
      bool iscontiguous() const;
      long itemsize() const;
      long nelements() const;
      object nonzero() const;
   
      void ravel();
   
      object repeat(object const&amp; repeats, long axis=0);
   
      void setflat(object const&amp; flat);
   
      void swapaxes(long axis1, long axis2);
   
      str tostring() const;
   
      void transpose(object const&amp; axes = object());
   
      object view() const;
  };
}}}
</pre>

    <h4><a name="array-spec-observers"></a>Class <code>array</code> observer
    functions</h4>
<pre>
object factory();
template &lt;class Buffer&gt;
object factory(Buffer const&amp;);
template &lt;class Buffer, class Type&gt;
object factory(Buffer const&amp;, Type const&amp;);
template &lt;class Buffer, class Type, class Shape&gt;
object factory(Buffer const&amp;, Type const&amp;, Shape const&amp;, bool copy = true, bool savespace = false);
template &lt;class Buffer, class Type, class Shape&gt;
object factory(Buffer const&amp;, Type const&amp;, Shape const&amp;, bool copy, bool savespace, char typecode);
</pre>
    These functions map to the underlying array type's <code>array()</code>
    function family. They are not called "<code>array</code>" because of the
    C++ limitation that you can't define a member function with the same name
    as its enclosing class. 
<pre>
template &lt;class Type&gt;
object new_(Type const&amp;) const;
</pre>
    This function maps to the underlying array type's <code>new()</code>
    function. It is not called "<code>new</code>" because that is a keyword
    in C++. 

    <h4><a name="array-spec-statics"></a>Class <code>array</code> static
    functions</h4>
<pre>
static void set_module_and_type(char const* package_path, char const* type_name);
static void set_module_and_type();
</pre>

    <dl class="function-semantics">
      <dt><b>Requires:</b> <code>package_path</code> and
      <code>type_name</code>, if supplied, is an <a href=
      "definitions.html#ntbs">ntbs</a>.</dt>

      <dt><b>Effects:</b> The first form sets the package path of the module
      which supplies the type named by <code>type_name</code> to
      <code>package_path</code>. The second form restores the <a href=
      "#default_search">default search behavior</a>. The associated Python
      type will be searched for only the first time it is needed, and
      thereafter the first time it is needed after an invocation of
      <code>set_module_and_type</code>.</dt>
    </dl>

    <h2><a name="examples"></a>Example</h2>
<pre>
#include &lt;boost/python/numeric.hpp&gt;
#include &lt;boost/python/tuple.hpp&gt;

// sets the first element in a 2d numeric array
void set_first_element(numeric::array&amp; y, double value)
{
    y[make_tuple(0,0)] = value;
}
</pre>

    <p>Revised 03 October, 2002</p>

    <p><i>&copy; Copyright <a href=
    "../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
  </body>
</html>