mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 17:32:55 +00:00
deploy: 68fa9dccde
This commit is contained in:
@@ -3,166 +3,14 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.11: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils 0.16: http://docutils.sourceforge.net/" />
|
||||
<title>Building Hybrid Systems with Boost.Python</title>
|
||||
<meta name="author" content="David Abrahams" />
|
||||
<meta name="organization" content="Boost Consulting" />
|
||||
<meta name="date" content="2003-05-14" />
|
||||
<meta name="author" content="Ralf W. Grosse-Kunstleve" />
|
||||
<meta name="copyright" content="Copyright David Abrahams and Ralf W. Grosse-Kunstleve 2003. All rights reserved" />
|
||||
<style type="text/css">
|
||||
|
||||
@import url("doc/src/boostbook.css");
|
||||
@import url("doc/src/docutils.css");
|
||||
/* Copyright David Abrahams 2006. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
|
||||
img.boost-logo {
|
||||
border: none;
|
||||
vertical-align: middle
|
||||
}
|
||||
|
||||
pre.literal-block span.concept {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: inline;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.prevpage {
|
||||
padding-top: -5px;
|
||||
text-align: left;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.nextpage {
|
||||
padding-top: -20px;
|
||||
text-align: right;
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.small {
|
||||
font-size: smaller }
|
||||
|
||||
h2 a {
|
||||
font-size: 90%;
|
||||
}
|
||||
h3 a {
|
||||
font-size: 80%;
|
||||
}
|
||||
h4 a {
|
||||
font-size: 70%;
|
||||
}
|
||||
h5 a {
|
||||
font-size: 60%;
|
||||
}
|
||||
|
||||
dl,table
|
||||
{
|
||||
text-align: left;
|
||||
font-size: 10pt;
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
|
||||
/*=============================================================================
|
||||
Tables
|
||||
=============================================================================*/
|
||||
|
||||
/* The only clue docutils gives us that tables are logically tables,
|
||||
and not, e.g., footnotes, is that they have border="1". Therefore
|
||||
we're keying off of that. We used to manually patch docutils to
|
||||
add a "table" class to all logical tables, but that proved much too
|
||||
fragile.
|
||||
*/
|
||||
|
||||
table[border="1"]
|
||||
{
|
||||
width: 92%;
|
||||
margin-left: 4%;
|
||||
margin-right: 4%;
|
||||
}
|
||||
|
||||
table[border="1"]
|
||||
{
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
/* Table Cells */
|
||||
table[border="1"] tr td
|
||||
{
|
||||
padding: 0.5em;
|
||||
text-align: left;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
table[border="1"] tr th
|
||||
{
|
||||
padding: 0.5em 0.5em 0.5em 0.5em;
|
||||
border: 1pt solid white;
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
@media screen
|
||||
{
|
||||
|
||||
/* Tables */
|
||||
table[border="1"] tr td
|
||||
{
|
||||
border: 1px solid #DCDCDC;
|
||||
}
|
||||
|
||||
table[border="1"] tr th
|
||||
{
|
||||
background-color: #F0F0F0;
|
||||
border: 1px solid #DCDCDC;
|
||||
}
|
||||
|
||||
pre,
|
||||
.screen
|
||||
{
|
||||
border: 1px solid #DCDCDC;
|
||||
}
|
||||
|
||||
td pre
|
||||
td .screen
|
||||
{
|
||||
border: 0px
|
||||
}
|
||||
|
||||
.sidebar pre
|
||||
{
|
||||
border: 0px
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pre,
|
||||
.screen
|
||||
{
|
||||
font-size: 9pt;
|
||||
display: block;
|
||||
margin: 1pc 4% 0pc 4%;
|
||||
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
||||
}
|
||||
|
||||
/* Program listings in tables don't get borders */
|
||||
td pre,
|
||||
td .screen
|
||||
{
|
||||
margin: 0pc 0pc 0pc 0pc;
|
||||
padding: 0pc 0pc 0pc 0pc;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
<--- Cannot embed stylesheet '/rst.css': No such file or directory. --->
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="building-hybrid-systems-with-boost-python">
|
||||
@@ -186,7 +34,7 @@ dl,table
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first">Table of Contents</p>
|
||||
<p class="topic-title">Table of Contents</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#abstract" id="id5">Abstract</a></li>
|
||||
<li><a class="reference internal" href="#introduction" id="id6">Introduction</a></li>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 2. Building and Testing</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="rn.html" title="Chapter 1. Release Notes">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Background</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Choosing a Boost.Python Library Binary</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="configuring_boost_build.html" title="Configuring Boost.Build">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Configuring Boost.Build</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">
|
||||
@@ -136,29 +136,35 @@
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<p class="simpara">
|
||||
If you have both python 2.5 and python 2.4 installed, <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> might contain
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">Make</span> <span class="identifier">both</span> <span class="identifier">versions</span> <span class="identifier">of</span> <span class="identifier">Python</span> <span class="identifier">available</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">To</span> <span class="identifier">build</span> <span class="identifier">with</span> <span class="identifier">python</span> <span class="number">2.4</span><span class="special">,</span> <span class="identifier">add</span> <span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
|
||||
<span class="preprocessor"># to</span> <span class="identifier">your</span> <span class="identifier">command</span> <span class="identifier">line</span><span class="special">.</span>
|
||||
</pre>
|
||||
<p>
|
||||
The first version configured (2.5) becomes the default. To build
|
||||
against python 2.4, add <code class="computeroutput"><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span></code>
|
||||
to the <code class="computeroutput"><span class="identifier">bjam</span></code> command
|
||||
line.
|
||||
</p>
|
||||
</li>
|
||||
<p class="simpara">
|
||||
The first version configured (2.5) becomes the default. To build against
|
||||
python 2.4, add <code class="computeroutput"><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span></code>
|
||||
to the <code class="computeroutput"><span class="identifier">bjam</span></code> command
|
||||
line.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="simpara">
|
||||
If you have python installed in an unusual location, you might supply
|
||||
the path to the interpreter in the <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>
|
||||
parameter:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="special">/</span><span class="identifier">usr</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">python</span><span class="special">-</span><span class="number">2.6</span><span class="special">-</span><span class="identifier">beta</span><span class="special">/</span><span class="identifier">bin</span><span class="special">/</span><span class="identifier">python</span> <span class="special">;</span>
|
||||
</pre>
|
||||
</li>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="simpara">
|
||||
If you have a separate build of Python for use with a particular toolset,
|
||||
you might supply that toolset in the <code class="computeroutput"><span class="identifier">condition</span></code>
|
||||
parameter:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">use</span> <span class="keyword">for</span> <span class="identifier">most</span> <span class="identifier">toolsets</span>
|
||||
|
||||
<span class="preprocessor"># Use</span> <span class="identifier">with</span> <span class="identifier">Intel</span> <span class="identifier">C</span><span class="special">++</span> <span class="identifier">toolset</span>
|
||||
@@ -170,60 +176,66 @@
|
||||
<span class="special">:</span> <span class="special"><</span><span class="identifier">toolset</span><span class="special">></span><span class="identifier">intel</span> <span class="special">#</span> <span class="identifier">condition</span>
|
||||
<span class="special">;</span>
|
||||
</pre>
|
||||
</li>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="simpara">
|
||||
If you have downloaded the Python sources and built both the normal
|
||||
and the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">"python
|
||||
debugging"</a> builds from source on Windows, you might see:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">;</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python_d</span>
|
||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span>
|
||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">libs</span>
|
||||
<span class="special">:</span> <span class="special"><</span><span class="identifier">python</span><span class="special">-</span><span class="identifier">debugging</span><span class="special">></span><span class="identifier">on</span> <span class="special">;</span>
|
||||
</pre>
|
||||
</li>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="simpara">
|
||||
You can set up your user-config.jam so a bjam built under Windows can
|
||||
build/test both Windows and Cygwin_ python extensions. Just pass <code class="computeroutput"><span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span></code>
|
||||
in the <code class="computeroutput"><span class="identifier">condition</span></code> parameter
|
||||
for the cygwin python installation:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor"># windows</span> <span class="identifier">installation</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>
|
||||
|
||||
<span class="preprocessor"># cygwin</span> <span class="identifier">installation</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">cygwin</span><span class="special">\\</span><span class="identifier">bin</span><span class="special">\\</span><span class="identifier">python2</span><span class="special">.</span><span class="number">5</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
when you put target-os=cygwin in your build request, it should build
|
||||
with the cygwin version of python: <a name="flavor"></a>_
|
||||
</p>
|
||||
<p class="simpara">
|
||||
when you put target-os=cygwin in your build request, it should build
|
||||
with the cygwin version of python: <a name="flavor"></a>_
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span>
|
||||
</pre>
|
||||
<p>
|
||||
This is supposed to work the other way, too (targeting windows python
|
||||
with a <a href="http://cygwin.com" target="_top">Cygwin</a> bjam) but it
|
||||
seems as though the support in Boost.Build's toolsets for building
|
||||
that way is broken at the time of this writing.
|
||||
</p>
|
||||
</li>
|
||||
<p class="simpara">
|
||||
This is supposed to work the other way, too (targeting windows python
|
||||
with a <a href="http://cygwin.com" target="_top">Cygwin</a> bjam) but it seems
|
||||
as though the support in Boost.Build's toolsets for building that way
|
||||
is broken at the time of this writing.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="simpara">
|
||||
Note that because of <a href="http://zigzag.cs.msu.su/boost.build/wiki/AlternativeSelection" target="_top">the
|
||||
way Boost.Build currently selects target alternatives</a>, you
|
||||
might have be very explicit in your build requests. For example, given:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">a</span> <span class="identifier">regular</span> <span class="identifier">windows</span> <span class="identifier">build</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
building with
|
||||
</p>
|
||||
<p class="simpara">
|
||||
building with
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span>
|
||||
</pre>
|
||||
<p>
|
||||
will yield an error. Instead, you'll need to write
|
||||
</p>
|
||||
<p class="simpara">
|
||||
will yield an error. Instead, you'll need to write
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span><span class="special">/</span><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
|
||||
</pre>
|
||||
</li>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<div class="footnotes">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>#include Issues</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Installing Boost.Python on your System</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="no_install_quickstart.html" title="No-Install Quickstart">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>No-Install Quickstart</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="background.html" title="Background">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="testing_boost_python.html" title="Testing Boost.Python">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Python Debugging Builds</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="include_issues.html" title="#include Issues">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Testing Boost.Python</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="python_debugging_builds.html" title="Python Debugging Builds">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 3. Configuration</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="building/notes_for_mingw_and_cygwin_with_.html" title="Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 5. Frequently Asked Questions (FAQs)</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="support.html" title="Chapter 4. Support Resources">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Compilation takes too much time and eats too much memory! What can I do to make it faster?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_wrap_a_function_which0.html" title="How can I wrap a function which needs to take ownership of a raw pointer?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Does Boost.Python work with Mac OS X?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>error C2064: term does not evaluate to a function taking 2 arguments</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_do_i_create_sub_packages_usi.html" title="How do I create sub-packages using Boost.Python?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>fatal error C1204:Compiler limit:internal structure overflow</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_wrap_functions_which_t.html" title="How can I wrap functions which take C++ containers as arguments?">
|
||||
@@ -32,10 +32,12 @@
|
||||
Upgrade your compiler (preferred)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="simpara">
|
||||
Break your source file up into multiple translation units.
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
</p>
|
||||
<p class="simpara">
|
||||
<code class="computeroutput"><span class="identifier">my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">...</span>
|
||||
<span class="keyword">void</span> <span class="identifier">more_of_my_module</span><span class="special">();</span>
|
||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">my_module</span><span class="special">)</span>
|
||||
@@ -46,25 +48,25 @@
|
||||
<span class="identifier">more_of_my_module</span><span class="special">();</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">more_of_my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<p class="simpara">
|
||||
<code class="computeroutput"><span class="identifier">more_of_my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">more_of_my_module</span><span class="special">()</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"baz"</span><span class="special">,</span> <span class="identifier">baz</span><span class="special">);</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
If you find that a <code class="computeroutput"><span class="identifier">class_</span><span class="special"><...></span></code> declaration can't fit in
|
||||
a single source file without triggering the error, you can always pass
|
||||
a reference to the <code class="computeroutput"><span class="identifier">class_</span></code>
|
||||
object to a function in another source file, and call some of its member
|
||||
functions (e.g. <code class="computeroutput"><span class="special">.</span><span class="identifier">def</span><span class="special">(...)</span></code>) in the auxilliary source file:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">more_of_my_class</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<p class="simpara">
|
||||
If you find that a <code class="computeroutput"><span class="identifier">class_</span><span class="special"><...></span></code> declaration can't fit in a
|
||||
single source file without triggering the error, you can always pass
|
||||
a reference to the <code class="computeroutput"><span class="identifier">class_</span></code>
|
||||
object to a function in another source file, and call some of its member
|
||||
functions (e.g. <code class="computeroutput"><span class="special">.</span><span class="identifier">def</span><span class="special">(...)</span></code>) in the auxilliary source file:
|
||||
</p>
|
||||
<p class="simpara">
|
||||
<code class="computeroutput"><span class="identifier">more_of_my_class</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">more_of_my_class</span><span class="special">(</span><span class="keyword">class</span><span class="special">&</span><span class="identifier">lt</span><span class="special">;</span><span class="identifier">my_class</span><span class="special">&</span><span class="identifier">gt</span><span class="special">;&</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">x</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">x</span>
|
||||
@@ -74,7 +76,7 @@
|
||||
<span class="special">...</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
</li>
|
||||
</li>
|
||||
</ol></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I automatically convert my custom string type to and from a Python string?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="error_c2064_term_does_not_evalua.html" title="error C2064: term does not evaluate to a function taking 2 arguments">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I find the existing PyObject that holds a C++ object?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I wrap a function which needs to take ownership of a raw pointer?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I wrap functions which take C++ containers as arguments?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="is_return_internal_reference_eff.html" title="Is return_internal_reference efficient?">
|
||||
@@ -25,36 +25,40 @@
|
||||
</p>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
||||
<li class="listitem">
|
||||
<p>
|
||||
Using the regular <code class="computeroutput"><span class="identifier">class_</span><span class="special"><></span></code> wrapper:
|
||||
</p>
|
||||
<p class="simpara">
|
||||
Using the regular <code class="computeroutput"><span class="identifier">class_</span><span class="special"><></span></code> wrapper:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">class_</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">>(</span><span class="string">"std_vector_double"</span><span class="special">)</span>
|
||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(...)</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">;</span>
|
||||
</pre>
|
||||
<p class="simpara">
|
||||
This can be moved to a template so that several types (<code class="computeroutput"><span class="keyword">double</span></code>, <code class="computeroutput"><span class="keyword">int</span></code>,
|
||||
<code class="computeroutput"><span class="keyword">long</span></code>, etc.) can be wrapped
|
||||
with the same code. This technique is used in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">array_family</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">flex_wrapper</span><span class="special">.</span><span class="identifier">h</span></code> in the "scitbx" package.
|
||||
The file could easily be modified for wrapping <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code> instantiations. This type of
|
||||
C++/Python binding is most suitable for containers that may contain a
|
||||
large number of elements (>10000).
|
||||
</li>
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p>
|
||||
Using custom rvalue converters. Boost.Python "rvalue converters"
|
||||
match function signatures such as:
|
||||
</p>
|
||||
<p class="simpara">
|
||||
Using custom rvalue converters. Boost.Python "rvalue converters"
|
||||
match function signatures such as:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">array</span><span class="special">);</span> <span class="comment">// pass by const-reference</span>
|
||||
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">array</span><span class="special">);</span> <span class="comment">// pass by value</span>
|
||||
</pre>
|
||||
<p class="simpara">
|
||||
Some custom rvalue converters are implemented in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">container_conversions</span><span class="special">.</span><span class="identifier">h</span></code> This code can be used to convert
|
||||
from C++ container types such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code> or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><></span></code> to Python tuples and vice versa.
|
||||
A few simple examples can be found in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">array_family</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">regression_test_module</span><span class="special">.</span><span class="identifier">cpp</span></code>
|
||||
Automatic C++ container <-> Python tuple conversions are most suitable
|
||||
for containers of moderate size. These converters generate significantly
|
||||
less object code compared to alternative 1 above.
|
||||
</li>
|
||||
</p>
|
||||
</li>
|
||||
</ol></div>
|
||||
<p>
|
||||
A disadvantage of using alternative 2 is that operators such as arithmetic
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How do I create sub-packages using Boost.Python?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="compilation_takes_too_much_time_.html" title="Compilation takes too much time and eats too much memory! What can I do to make it faster?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How do I debug my Python extensions?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="fatal_error_c1204_compiler_limit.html" title="fatal error C1204:Compiler limit:internal structure overflow">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>I'm getting the "attempt to return dangling reference" error. What am I doing wrong?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Is Boost.Python thread-aware/compatible with multiple interpreters?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="why_is_my_automatic_to_python_co.html" title="Why is my automatic to-python conversion not being found?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Is return_internal_reference efficient?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="i_m_getting_the_attempt_to_retur.html" title="I'm getting the "attempt to return dangling reference" error. What am I doing wrong?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Why doesn't my *= operator work?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_do_i_debug_my_python_extensi.html" title="How do I debug my Python extensions?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Why is my automatic to-python conversion not being found?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_automatically_convert_.html" title="How can I automatically convert my custom string type to and from a Python string?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 6. Glossary</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="faq/is_boost_python_thread_aware_com.html" title="Is Boost.Python thread-aware/compatible with multiple interpreters?">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Boost.Python</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="next" href="rn.html" title="Chapter 1. Release Notes">
|
||||
</head>
|
||||
@@ -126,7 +126,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: March 29, 2019 at 19:47:44 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: March 04, 2021 at 17:00:22 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Sphinx build info version 1
|
||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||
config: c2f89bf9615bf36af14ecba75ba30ca4
|
||||
config: 374e3c15a89643f46322a816fc37dcdf
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14
doc/html/numpy/_sources/index.rst.txt
Normal file
14
doc/html/numpy/_sources/index.rst.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
.. Boost.Python NumPy extension documentation master file, created by
|
||||
sphinx-quickstart on Thu Oct 27 09:04:58 2011.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to the documentation of the Boost.Python NumPy extension!
|
||||
=================================================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
Tutorial <tutorial/index>
|
||||
Reference <reference/index>
|
||||
|
||||
110
doc/html/numpy/_sources/reference/binary_ufunc.rst.txt
Normal file
110
doc/html/numpy/_sources/reference/binary_ufunc.rst.txt
Normal file
@@ -0,0 +1,110 @@
|
||||
binary_ufunc
|
||||
============
|
||||
|
||||
.. contents :: Table of Contents
|
||||
|
||||
A ``binary_ufunc`` is a struct used as an intermediate step to broadcast two arguments so that a C++ function can be converted to a ufunc like function
|
||||
|
||||
``<boost/python/numpy/ufunc.hpp>`` contains the ``binary_ufunc`` structure definitions
|
||||
|
||||
|
||||
synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace python
|
||||
{
|
||||
namespace numpy
|
||||
{
|
||||
|
||||
template <typename TBinaryFunctor,
|
||||
typename TArgument1=typename TBinaryFunctor::first_argument_type,
|
||||
typename TArgument2=typename TBinaryFunctor::second_argument_type,
|
||||
typename TResult=typename TBinaryFunctor::result_type>
|
||||
|
||||
struct binary_ufunc
|
||||
{
|
||||
|
||||
static object call(TBinaryFunctor & self,
|
||||
object const & input1,
|
||||
object const & input2,
|
||||
object const & output);
|
||||
|
||||
static object make();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
constructors
|
||||
------------
|
||||
|
||||
::
|
||||
|
||||
struct example_binary_ufunc
|
||||
{
|
||||
typedef any_valid first_argument_type;
|
||||
typedef any_valid second_argument_type;
|
||||
typedef any_valid result_type;
|
||||
};
|
||||
|
||||
:Requirements: The ``any_valid`` type must be defined using typedef as a valid C++ type in order to use the struct methods correctly
|
||||
|
||||
:Note: The struct must be exposed as a Python class, and an instance of the class must be created to use the ``call`` method corresponding to the ``__call__`` attribute of the Python object
|
||||
|
||||
accessors
|
||||
---------
|
||||
|
||||
::
|
||||
|
||||
template <typename TBinaryFunctor,
|
||||
typename TArgument1=typename TBinaryFunctor::first_argument_type,
|
||||
typename TArgument2=typename TBinaryFunctor::second_argument_type,
|
||||
typename TResult=typename TBinaryFunctor::result_type>
|
||||
static object call(TBinaryFunctor & self,
|
||||
object const & input,
|
||||
object const & output);
|
||||
|
||||
:Requires: Typenames ``TBinaryFunctor`` and optionally ``TArgument1`` and ``TArgument2`` for argument type and ``TResult`` for result type
|
||||
|
||||
:Effects: Passes a Python object to the underlying C++ functor after broadcasting its arguments
|
||||
|
||||
::
|
||||
|
||||
template <typename TBinaryFunctor,
|
||||
typename TArgument1=typename TBinaryFunctor::first_argument_type,
|
||||
typename TArgument2=typename TBinaryFunctor::second_argument_type,
|
||||
typename TResult=typename TBinaryFunctor::result_type>
|
||||
static object make();
|
||||
|
||||
:Requires: Typenames ``TBinaryFunctor`` and optionally ``TArgument1`` and ``TArgument2`` for argument type and ``TResult`` for result type
|
||||
|
||||
:Returns: A Python function object to call the overloaded () operator in the struct (in typical usage)
|
||||
|
||||
Example(s)
|
||||
----------
|
||||
|
||||
::
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
struct BinarySquare
|
||||
{
|
||||
typedef double first_argument_type;
|
||||
typedef double second_argument_type;
|
||||
typedef double result_type;
|
||||
|
||||
double operator()(double a,double b) const { return (a*a + b*b) ; }
|
||||
};
|
||||
|
||||
p::object ud = p::class_<BinarySquare, boost::shared_ptr<BinarySquare> >("BinarySquare").def("__call__", np::binary_ufunc<BinarySquare>::make());
|
||||
p::object inst = ud();
|
||||
result_array = inst.attr("__call__")(demo_array,demo_array) ;
|
||||
std::cout << "Square of list with binary ufunc is " << p::extract <char const * > (p::str(result_array)) << std::endl ;
|
||||
|
||||
92
doc/html/numpy/_sources/reference/dtype.rst.txt
Normal file
92
doc/html/numpy/_sources/reference/dtype.rst.txt
Normal file
@@ -0,0 +1,92 @@
|
||||
dtype
|
||||
=====
|
||||
|
||||
.. contents :: Table of Contents
|
||||
|
||||
A `dtype`_ is an object describing the type of the elements of an ndarray
|
||||
|
||||
.. _dtype: http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#data-type-objects-dtype
|
||||
|
||||
``<boost/python/numpy/dtype.hpp>`` contains the method calls necessary to generate a python object equivalent to a numpy.dtype from builtin C++ objects, as well as to create custom dtypes from user defined types
|
||||
|
||||
|
||||
synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace python
|
||||
{
|
||||
namespace numpy
|
||||
{
|
||||
|
||||
class dtype : public object
|
||||
{
|
||||
static python::detail::new_reference convert(object::object_cref arg, bool align);
|
||||
public:
|
||||
|
||||
// Convert an arbitrary Python object to a data-type descriptor object.
|
||||
template <typename T>
|
||||
explicit dtype(T arg, bool align=false);
|
||||
|
||||
// Get the built-in numpy dtype associated with the given scalar template type.
|
||||
template <typename T> static dtype get_builtin();
|
||||
|
||||
// Return the size of the data type in bytes.
|
||||
int get_itemsize() const;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructors
|
||||
------------
|
||||
|
||||
::
|
||||
|
||||
template <typename T>
|
||||
explicit dtype(T arg, bool align=false)
|
||||
|
||||
:Requirements: ``T`` must be either :
|
||||
|
||||
* a built-in C++ typename convertible to object
|
||||
* a valid python object or convertible to object
|
||||
|
||||
:Effects: Constructs an object from the supplied python object / convertible
|
||||
to object / builtin C++ data type
|
||||
|
||||
:Throws: Nothing
|
||||
|
||||
::
|
||||
|
||||
template <typename T> static dtype get_builtin();
|
||||
|
||||
:Requirements: The typename supplied, ``T`` must be a builtin C++ type also supported by numpy
|
||||
|
||||
:Returns: Numpy dtype corresponding to builtin C++ type
|
||||
|
||||
accessors
|
||||
---------
|
||||
|
||||
::
|
||||
|
||||
int get_itemsize() const;
|
||||
|
||||
:Returns: the size of the data type in bytes.
|
||||
|
||||
|
||||
Example(s)
|
||||
----------
|
||||
|
||||
::
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
np::dtype dtype = np::dtype::get_builtin<double>();
|
||||
p::tuple for_custom_dtype = p::make_tuple("ha",dtype);
|
||||
np::dtype custom_dtype = np::dtype(list_for_dtype);
|
||||
|
||||
12
doc/html/numpy/_sources/reference/index.rst.txt
Normal file
12
doc/html/numpy/_sources/reference/index.rst.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Boost.Python NumPy extension Reference
|
||||
======================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
dtype
|
||||
ndarray
|
||||
unary_ufunc
|
||||
binary_ufunc
|
||||
multi_iter
|
||||
|
||||
94
doc/html/numpy/_sources/reference/multi_iter.rst.txt
Normal file
94
doc/html/numpy/_sources/reference/multi_iter.rst.txt
Normal file
@@ -0,0 +1,94 @@
|
||||
multi_iter
|
||||
==========
|
||||
|
||||
.. contents :: Table of Contents
|
||||
|
||||
A ``multi_iter`` is a Python object, intended to be used as an iterator It should generally only be used in loops.
|
||||
|
||||
``<boost/python/numpy/ufunc.hpp>`` contains the class definitions for ``multi_iter``
|
||||
|
||||
|
||||
synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace python
|
||||
{
|
||||
namespace numpy
|
||||
{
|
||||
|
||||
class multi_iter : public object
|
||||
{
|
||||
public:
|
||||
void next();
|
||||
bool not_done() const;
|
||||
char * get_data(int n) const;
|
||||
int const get_nd() const;
|
||||
Py_intptr_t const * get_shape() const;
|
||||
Py_intptr_t const shape(int n) const;
|
||||
};
|
||||
|
||||
|
||||
multi_iter make_multi_iter(object const & a1);
|
||||
multi_iter make_multi_iter(object const & a1, object const & a2);
|
||||
multi_iter make_multi_iter(object const & a1, object const & a2, object const & a3);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
constructors
|
||||
------------
|
||||
|
||||
::
|
||||
|
||||
multi_iter make_multi_iter(object const & a1);
|
||||
multi_iter make_multi_iter(object const & a1, object const & a2);
|
||||
multi_iter make_multi_iter(object const & a1, object const & a2, object const & a3);
|
||||
|
||||
:Returns: A Python iterator object broadcasting over one, two or three sequences as supplied
|
||||
|
||||
accessors
|
||||
---------
|
||||
|
||||
::
|
||||
|
||||
void next();
|
||||
|
||||
:Effects: Increments the iterator
|
||||
|
||||
::
|
||||
|
||||
bool not_done() const;
|
||||
|
||||
:Returns: boolean value indicating whether the iterator is at its end
|
||||
|
||||
::
|
||||
|
||||
char * get_data(int n) const;
|
||||
|
||||
:Returns: a pointer to the element of the nth broadcasted array.
|
||||
|
||||
::
|
||||
|
||||
int const get_nd() const;
|
||||
|
||||
:Returns: the number of dimensions of the broadcasted array expression
|
||||
|
||||
::
|
||||
|
||||
Py_intptr_t const * get_shape() const;
|
||||
|
||||
:Returns: the shape of the broadcasted array expression as an array of integers.
|
||||
|
||||
::
|
||||
|
||||
Py_intptr_t const shape(int n) const;
|
||||
|
||||
:Returns: the shape of the broadcasted array expression in the nth dimension.
|
||||
|
||||
|
||||
382
doc/html/numpy/_sources/reference/ndarray.rst.txt
Normal file
382
doc/html/numpy/_sources/reference/ndarray.rst.txt
Normal file
@@ -0,0 +1,382 @@
|
||||
ndarray
|
||||
=======
|
||||
|
||||
.. contents :: Table of Contents
|
||||
|
||||
A `ndarray`_ is an N-dimensional array which contains items of the same type and size, where N is the number of dimensions and is specified in the form of a ``shape`` tuple. Optionally, the numpy ``dtype`` for the objects contained may also be specified.
|
||||
|
||||
.. _ndarray: http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html
|
||||
.. _dtype: http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#data-type-objects-dtype
|
||||
|
||||
``<boost/python/numpy/ndarray.hpp>`` contains the structures and methods necessary to move raw data between C++ and Python and create ndarrays from the data
|
||||
|
||||
|
||||
|
||||
synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace python
|
||||
{
|
||||
namespace numpy
|
||||
{
|
||||
|
||||
class ndarray : public object
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum bitflag
|
||||
{
|
||||
NONE=0x0, C_CONTIGUOUS=0x1, F_CONTIGUOUS=0x2, V_CONTIGUOUS=0x1|0x2,
|
||||
ALIGNED=0x4, WRITEABLE=0x8, BEHAVED=0x4|0x8,
|
||||
CARRAY_RO=0x1|0x4, CARRAY=0x1|0x4|0x8, CARRAY_MIS=0x1|0x8,
|
||||
FARRAY_RO=0x2|0x4, FARRAY=0x2|0x4|0x8, FARRAY_MIS=0x2|0x8,
|
||||
UPDATE_ALL=0x1|0x2|0x4, VARRAY=0x1|0x2|0x8, ALL=0x1|0x2|0x4|0x8
|
||||
};
|
||||
|
||||
ndarray view(dtype const & dt) const;
|
||||
ndarray astype(dtype const & dt) const;
|
||||
ndarray copy() const;
|
||||
int const shape(int n) const;
|
||||
int const strides(int n) const;
|
||||
char * get_data() const;
|
||||
dtype get_dtype() const;
|
||||
python::object get_base() const;
|
||||
void set_base(object const & base);
|
||||
Py_intptr_t const * get_shape() const;
|
||||
Py_intptr_t const * get_strides() const;
|
||||
int const get_nd() const;
|
||||
|
||||
bitflag const get_flags() const;
|
||||
|
||||
ndarray transpose() const;
|
||||
ndarray squeeze() const;
|
||||
ndarray reshape(tuple const & shape) const;
|
||||
object scalarize() const;
|
||||
};
|
||||
|
||||
ndarray zeros(tuple const & shape, dtype const & dt);
|
||||
ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
|
||||
ndarray empty(tuple const & shape, dtype const & dt);
|
||||
ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
|
||||
ndarray array(object const & obj);
|
||||
ndarray array(object const & obj, dtype const & dt);
|
||||
|
||||
template <typename Container>
|
||||
ndarray from_data(void * data,dtype const & dt,Container shape,Container strides,python::object const & owner);
|
||||
template <typename Container>
|
||||
ndarray from_data(void const * data, dtype const & dt, Container shape, Container strides, object const & owner);
|
||||
|
||||
ndarray from_object(object const & obj, dtype const & dt,int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE);
|
||||
ndarray from_object(object const & obj, dtype const & dt,int nd, ndarray::bitflag flags=ndarray::NONE);
|
||||
ndarray from_object(object const & obj, dtype const & dt, ndarray::bitflag flags=ndarray::NONE);
|
||||
ndarray from_object(object const & obj, int nd_min, int nd_max,ndarray::bitflag flags=ndarray::NONE);
|
||||
ndarray from_object(object const & obj, int nd, ndarray::bitflag flags=ndarray::NONE);
|
||||
ndarray from_object(object const & obj, ndarray::bitflag flags=ndarray::NONE)
|
||||
|
||||
ndarray::bitflag operator|(ndarray::bitflag a, ndarray::bitflag b) ;
|
||||
ndarray::bitflag operator&(ndarray::bitflag a, ndarray::bitflag b);
|
||||
|
||||
}
|
||||
|
||||
|
||||
constructors
|
||||
------------
|
||||
|
||||
::
|
||||
|
||||
ndarray view(dtype const & dt) const;
|
||||
|
||||
:Returns: new ndarray with old ndarray data cast as supplied dtype
|
||||
|
||||
::
|
||||
|
||||
ndarray astype(dtype const & dt) const;
|
||||
|
||||
:Returns: new ndarray with old ndarray data converted to supplied dtype
|
||||
|
||||
::
|
||||
|
||||
ndarray copy() const;
|
||||
|
||||
:Returns: Copy of calling ndarray object
|
||||
|
||||
::
|
||||
|
||||
ndarray transpose() const;
|
||||
|
||||
:Returns: An ndarray with the rows and columns interchanged
|
||||
|
||||
::
|
||||
|
||||
ndarray squeeze() const;
|
||||
|
||||
:Returns: An ndarray with all unit-shaped dimensions removed
|
||||
|
||||
::
|
||||
|
||||
ndarray reshape(tuple const & shape) const;
|
||||
|
||||
:Requirements: The new ``shape`` of the ndarray must be supplied as a tuple
|
||||
|
||||
:Returns: An ndarray with the same data but reshaped to the ``shape`` supplied
|
||||
|
||||
|
||||
::
|
||||
|
||||
object scalarize() const;
|
||||
|
||||
:Returns: A scalar if the ndarray has only one element, otherwise it returns the entire array
|
||||
|
||||
::
|
||||
|
||||
ndarray zeros(tuple const & shape, dtype const & dt);
|
||||
ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
|
||||
:Requirements: The following parameters must be supplied as required :
|
||||
|
||||
* the ``shape`` or the size of all dimensions, as a tuple
|
||||
* the ``dtype`` of the data
|
||||
* the ``nd`` size for a square shaped ndarray
|
||||
* the ``shape`` Py_intptr_t
|
||||
|
||||
:Returns: A new ndarray with the given shape and data type, with data initialized to zero.
|
||||
|
||||
::
|
||||
|
||||
ndarray empty(tuple const & shape, dtype const & dt);
|
||||
ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``shape`` or the size of all dimensions, as a tuple
|
||||
* the ``dtype`` of the data
|
||||
* the ``shape`` Py_intptr_t
|
||||
|
||||
:Returns: A new ndarray with the given shape and data type, with data left uninitialized.
|
||||
|
||||
::
|
||||
|
||||
ndarray array(object const & obj);
|
||||
ndarray array(object const & obj, dtype const & dt);
|
||||
|
||||
:Returns: A new ndarray from an arbitrary Python sequence, with dtype of each element specified optionally
|
||||
|
||||
::
|
||||
|
||||
template <typename Container>
|
||||
inline ndarray from_data(void * data,dtype const & dt,Container shape,Container strides,python::object const & owner)
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``data`` which is a generic C++ data container
|
||||
* the dtype ``dt`` of the data
|
||||
* the ``shape`` of the ndarray as Python object
|
||||
* the ``strides`` of each dimension of the array as a Python object
|
||||
* the ``owner`` of the data, in case it is not the ndarray itself
|
||||
|
||||
:Returns: ndarray with attributes and data supplied
|
||||
|
||||
:Note: The ``Container`` typename must be one that is convertible to a std::vector or python object type
|
||||
|
||||
::
|
||||
|
||||
ndarray from_object(object const & obj, dtype const & dt,int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE);
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``obj`` Python object to convert to ndarray
|
||||
* the dtype ``dt`` of the data
|
||||
* minimum number of dimensions ``nd_min`` of the ndarray as Python object
|
||||
* maximum number of dimensions ``nd_max`` of the ndarray as Python object
|
||||
* optional ``flags`` bitflags
|
||||
|
||||
:Returns: ndarray constructed with dimensions and data supplied as parameters
|
||||
|
||||
::
|
||||
|
||||
inline ndarray from_object(object const & obj, dtype const & dt, int nd, ndarray::bitflag flags=ndarray::NONE);
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``obj`` Python object to convert to ndarray
|
||||
* the dtype ``dt`` of the data
|
||||
* number of dimensions ``nd`` of the ndarray as Python object
|
||||
* optional ``flags`` bitflags
|
||||
|
||||
:Returns: ndarray with dimensions ``nd`` x ``nd`` and suplied parameters
|
||||
|
||||
::
|
||||
|
||||
inline ndarray from_object(object const & obj, dtype const & dt, ndarray::bitflag flags=ndarray::NONE)
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``obj`` Python object to convert to ndarray
|
||||
* the dtype ``dt`` of the data
|
||||
* optional ``flags`` bitflags
|
||||
|
||||
:Returns: Supplied Python object as ndarray
|
||||
|
||||
::
|
||||
|
||||
ndarray from_object(object const & obj, int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE);
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``obj`` Python object to convert to ndarray
|
||||
* minimum number of dimensions ``nd_min`` of the ndarray as Python object
|
||||
* maximum number of dimensions ``nd_max`` of the ndarray as Python object
|
||||
* optional ``flags`` bitflags
|
||||
|
||||
:Returns: ndarray with supplied dimension limits and parameters
|
||||
|
||||
:Note: dtype need not be supplied here
|
||||
|
||||
::
|
||||
|
||||
inline ndarray from_object(object const & obj, int nd, ndarray::bitflag flags=ndarray::NONE);
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``obj`` Python object to convert to ndarray
|
||||
* the dtype ``dt`` of the data
|
||||
* number of dimensions ``nd`` of the ndarray as Python object
|
||||
* optional ``flags`` bitflags
|
||||
|
||||
:Returns: ndarray of ``nd`` x ``nd`` dimensions constructed from the supplied object
|
||||
|
||||
::
|
||||
|
||||
inline ndarray from_object(object const & obj, ndarray::bitflag flags=ndarray::NONE)
|
||||
|
||||
:Requirements: The following parameters must be supplied :
|
||||
|
||||
* the ``obj`` Python object to convert to ndarray
|
||||
* optional ``flags`` bitflags
|
||||
|
||||
:Returns: ndarray of same dimensions and dtype as supplied Python object
|
||||
|
||||
|
||||
accessors
|
||||
---------
|
||||
|
||||
::
|
||||
|
||||
int const shape(int n) const;
|
||||
|
||||
:Returns: The size of the n-th dimension of the ndarray
|
||||
|
||||
::
|
||||
|
||||
int const strides(int n) const;
|
||||
|
||||
:Returns: The stride of the nth dimension.
|
||||
|
||||
::
|
||||
|
||||
char * get_data() const;
|
||||
|
||||
:Returns: Array's raw data pointer as a char
|
||||
|
||||
:Note: This returns char so stride math works properly on it.User will have to reinterpret_cast it.
|
||||
|
||||
::
|
||||
|
||||
dtype get_dtype() const;
|
||||
|
||||
:Returns: Array's data-type descriptor object (dtype)
|
||||
|
||||
|
||||
::
|
||||
|
||||
object get_base() const;
|
||||
|
||||
:Returns: Object that owns the array's data, or None if the array owns its own data.
|
||||
|
||||
|
||||
::
|
||||
|
||||
void set_base(object const & base);
|
||||
|
||||
:Returns: Set the object that owns the array's data. Exercise caution while using this
|
||||
|
||||
|
||||
::
|
||||
|
||||
Py_intptr_t const * get_shape() const;
|
||||
|
||||
:Returns: Shape of the array as an array of integers
|
||||
|
||||
|
||||
::
|
||||
|
||||
Py_intptr_t const * get_strides() const;
|
||||
|
||||
:Returns: Stride of the array as an array of integers
|
||||
|
||||
|
||||
::
|
||||
|
||||
int const get_nd() const;
|
||||
|
||||
:Returns: Number of array dimensions
|
||||
|
||||
|
||||
::
|
||||
|
||||
bitflag const get_flags() const;
|
||||
|
||||
:Returns: Array flags
|
||||
|
||||
::
|
||||
|
||||
inline ndarray::bitflag operator|(ndarray::bitflag a, ndarray::bitflag b)
|
||||
|
||||
:Returns: bitflag logically OR-ed as (a | b)
|
||||
|
||||
::
|
||||
|
||||
inline ndarray::bitflag operator&(ndarray::bitflag a, ndarray::bitflag b)
|
||||
|
||||
:Returns: bitflag logically AND-ed as (a & b)
|
||||
|
||||
|
||||
Example(s)
|
||||
----------
|
||||
|
||||
::
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
p::object tu = p::make_tuple('a','b','c') ;
|
||||
np::ndarray example_tuple = np::array (tu) ;
|
||||
|
||||
p::list l ;
|
||||
np::ndarray example_list = np::array (l) ;
|
||||
|
||||
np::dtype dt = np::dtype::get_builtin<int>();
|
||||
np::ndarray example_list1 = np::array (l,dt);
|
||||
|
||||
int data[] = {1,2,3,4} ;
|
||||
p::tuple shape = p::make_tuple(4) ;
|
||||
p::tuple stride = p::make_tuple(4) ;
|
||||
p::object own ;
|
||||
np::ndarray data_ex = np::from_data(data,dt,shape,stride,own);
|
||||
|
||||
uint8_t mul_data[][4] = {{1,2,3,4},{5,6,7,8},{1,3,5,7}};
|
||||
shape = p::make_tuple(3,2) ;
|
||||
stride = p::make_tuple(4,2) ;
|
||||
np::dtype dt1 = np::dtype::get_builtin<uint8_t>();
|
||||
|
||||
np::ndarray mul_data_ex = np::from_data(mul_data,dt1, p::make_tuple(3,4),p::make_tuple(4,1),p::object());
|
||||
mul_data_ex = np::from_data(mul_data,dt1, shape,stride,p::object());
|
||||
|
||||
103
doc/html/numpy/_sources/reference/unary_ufunc.rst.txt
Normal file
103
doc/html/numpy/_sources/reference/unary_ufunc.rst.txt
Normal file
@@ -0,0 +1,103 @@
|
||||
unary_ufunc
|
||||
===========
|
||||
|
||||
.. contents :: Table of Contents
|
||||
|
||||
A ``unary_ufunc`` is a struct used as an intermediate step to broadcast a single argument so that a C++ function can be converted to a ufunc like function
|
||||
|
||||
``<boost/python/numpy/ufunc.hpp>`` contains the ``unary_ufunc`` structure definitions
|
||||
|
||||
|
||||
synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace python
|
||||
{
|
||||
namespace numpy
|
||||
{
|
||||
|
||||
template <typename TUnaryFunctor,
|
||||
typename TArgument=typename TUnaryFunctor::argument_type,
|
||||
typename TResult=typename TUnaryFunctor::result_type>
|
||||
struct unary_ufunc
|
||||
{
|
||||
|
||||
static object call(TUnaryFunctor & self,
|
||||
object const & input,
|
||||
object const & output) ;
|
||||
|
||||
static object make();
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
constructors
|
||||
------------
|
||||
|
||||
::
|
||||
|
||||
struct example_unary_ufunc
|
||||
{
|
||||
typedef any_valid_type argument_type;
|
||||
typedef any_valid_type result_type;
|
||||
};
|
||||
|
||||
:Requirements: The ``any_valid`` type must be defined using typedef as a valid C++ type in order to use the struct methods correctly
|
||||
|
||||
:Note: The struct must be exposed as a Python class, and an instance of the class must be created to use the ``call`` method corresponding to the ``__call__`` attribute of the Python object
|
||||
|
||||
accessors
|
||||
---------
|
||||
|
||||
::
|
||||
|
||||
template <typename TUnaryFunctor,
|
||||
typename TArgument=typename TUnaryFunctor::argument_type,
|
||||
typename TResult=typename TUnaryFunctor::result_type>
|
||||
static object call(TUnaryFunctor & self,
|
||||
object const & input,
|
||||
object const & output);
|
||||
|
||||
:Requires: Typenames ``TUnaryFunctor`` and optionally ``TArgument`` for argument type and ``TResult`` for result type
|
||||
|
||||
:Effects: Passes a Python object to the underlying C++ functor after broadcasting its arguments
|
||||
|
||||
::
|
||||
|
||||
template <typename TUnaryFunctor,
|
||||
typename TArgument=typename TUnaryFunctor::argument_type,
|
||||
typename TResult=typename TUnaryFunctor::result_type>
|
||||
static object make();
|
||||
|
||||
:Requires: Typenames ``TUnaryFunctor`` and optionally ``TArgument`` for argument type and ``TResult`` for result type
|
||||
|
||||
:Returns: A Python function object to call the overloaded () operator in the struct (in typical usage)
|
||||
|
||||
|
||||
|
||||
Example(s)
|
||||
----------
|
||||
|
||||
::
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
struct UnarySquare
|
||||
{
|
||||
typedef double argument_type;
|
||||
typedef double result_type;
|
||||
double operator()(double r) const { return r * r;}
|
||||
};
|
||||
|
||||
p::object ud = p::class_<UnarySquare, boost::shared_ptr<UnarySquare> >("UnarySquare").def("__call__", np::unary_ufunc<UnarySquare>::make());
|
||||
p::object inst = ud();
|
||||
std::cout << "Square of unary scalar 1.0 is " << p::extract <char const * > (p::str(inst.attr("__call__")(1.0))) << std::endl ;
|
||||
|
||||
54
doc/html/numpy/_sources/tutorial/dtype.rst.txt
Normal file
54
doc/html/numpy/_sources/tutorial/dtype.rst.txt
Normal file
@@ -0,0 +1,54 @@
|
||||
How to use dtypes
|
||||
=================
|
||||
|
||||
Here is a brief tutorial to show how to create ndarrays with built-in python data types, and extract the types and values of member variables
|
||||
|
||||
Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module::
|
||||
|
||||
#include <boost/python/numpy.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Py_Initialize();
|
||||
np::initialize();
|
||||
|
||||
Next, we create the shape and dtype. We use the get_builtin method to get the numpy dtype corresponding to the builtin C++ dtype
|
||||
Here, we will create a 3x3 array passing a tuple with (3,3) for the size, and double as the data type ::
|
||||
|
||||
p::tuple shape = p::make_tuple(3, 3);
|
||||
np::dtype dtype = np::dtype::get_builtin<double>();
|
||||
np::ndarray a = np::zeros(shape, dtype);
|
||||
|
||||
Finally, we can print the array using the extract method in the python namespace.
|
||||
Here, we first convert the variable into a string, and then extract it as a C++ character array from the python string using the <char const \* > template ::
|
||||
|
||||
std::cout << "Original array:\n" << p::extract<char const *>(p::str(a)) << std::endl;
|
||||
|
||||
We can also print the dtypes of the data members of the ndarray by using the get_dtype method for the ndarray ::
|
||||
|
||||
std::cout << "Datatype is:\n" << p::extract<char const *>(p::str(a.get_dtype())) << std::endl ;
|
||||
|
||||
We can also create custom dtypes and build ndarrays with the custom dtypes
|
||||
|
||||
We use the dtype constructor to create a custom dtype. This constructor takes a list as an argument.
|
||||
|
||||
The list should contain one or more tuples of the format (variable name, variable type)
|
||||
|
||||
So first create a tuple with a variable name and its dtype, double, to create a custom dtype ::
|
||||
|
||||
p::tuple for_custom_dtype = p::make_tuple("ha",dtype) ;
|
||||
|
||||
Next, create a list, and add this tuple to the list. Then use the list to create the custom dtype ::
|
||||
|
||||
p::list list_for_dtype ;
|
||||
list_for_dtype.append(for_custom_dtype) ;
|
||||
np::dtype custom_dtype = np::dtype(list_for_dtype) ;
|
||||
|
||||
We are now ready to create an ndarray with dimensions specified by \*shape\* and of custom dtpye ::
|
||||
|
||||
np::ndarray new_array = np::zeros(shape,custom_dtype);
|
||||
}
|
||||
56
doc/html/numpy/_sources/tutorial/fromdata.rst.txt
Normal file
56
doc/html/numpy/_sources/tutorial/fromdata.rst.txt
Normal file
@@ -0,0 +1,56 @@
|
||||
How to access data using raw pointers
|
||||
=====================================
|
||||
|
||||
One of the advantages of the ndarray wrapper is that the same data can be used in both Python and C++ and changes can be made to reflect at both ends.
|
||||
The from_data method makes this possible.
|
||||
|
||||
Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module::
|
||||
|
||||
#include <boost/python/numpy.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Py_Initialize();
|
||||
np::initialize();
|
||||
|
||||
Create an array in C++ , and pass the pointer to it to the from_data method to create an ndarray::
|
||||
|
||||
int arr[] = {1,2,3,4,5};
|
||||
np::ndarray py_array = np::from_data(arr, np::dtype::get_builtin<int>(),
|
||||
p::make_tuple(5),
|
||||
p::make_tuple(sizeof(int)),
|
||||
p::object());
|
||||
|
||||
Print the source C++ array, as well as the ndarray, to check if they are the same::
|
||||
|
||||
std::cout << "C++ array :" << std::endl;
|
||||
for (int j=0;j<4;j++)
|
||||
{
|
||||
std::cout << arr[j] << ' ';
|
||||
}
|
||||
std::cout << std::endl
|
||||
<< "Python ndarray :" << p::extract<char const *>(p::str(py_array)) << std::endl;
|
||||
|
||||
Now, change an element in the Python ndarray, and check if the value changed correspondingly in the source C++ array::
|
||||
|
||||
py_array[1] = 5 ;
|
||||
std::cout << "Is the change reflected in the C++ array used to create the ndarray ? " << std::endl;
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
std::cout << arr[j] << ' ';
|
||||
}
|
||||
|
||||
Next, change an element of the source C++ array and see if it is reflected in the Python ndarray::
|
||||
|
||||
arr[2] = 8;
|
||||
std::cout << std::endl
|
||||
<< "Is the change reflected in the Python ndarray ?" << std::endl
|
||||
<< p::extract<char const *>(p::str(py_array)) << std::endl;
|
||||
}
|
||||
|
||||
As we can see, the changes are reflected across the ends. This happens because the from_data method passes the C++ array by reference to create the ndarray, and thus uses the same locations for storing data.
|
||||
|
||||
12
doc/html/numpy/_sources/tutorial/index.rst.txt
Normal file
12
doc/html/numpy/_sources/tutorial/index.rst.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Boost.Python NumPy extension Tutorial
|
||||
=====================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
simple
|
||||
dtype
|
||||
ndarray
|
||||
ufunc
|
||||
fromdata
|
||||
|
||||
99
doc/html/numpy/_sources/tutorial/ndarray.rst.txt
Normal file
99
doc/html/numpy/_sources/tutorial/ndarray.rst.txt
Normal file
@@ -0,0 +1,99 @@
|
||||
Creating ndarrays
|
||||
=================
|
||||
|
||||
The Boost.Numpy library exposes quite a few methods to create ndarrays. ndarrays can be created in a variety of ways, include empty arrays and zero filled arrays.
|
||||
ndarrays can also be created from arbitrary python sequences as well as from data and dtypes.
|
||||
|
||||
This tutorial will introduce you to some of the ways in which you can create ndarrays. The methods covered here include creating ndarrays from arbitrary Python sequences, as well as from C++ containers, using both unit and non-unit strides
|
||||
|
||||
First, as before, initialise the necessary namepaces and runtimes ::
|
||||
|
||||
#include <boost/python/numpy.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Py_Initialize();
|
||||
np::initialize();
|
||||
|
||||
Let's now create an ndarray from a simple tuple. We first create a tuple object, and then pass it to the array method, to generate the necessary tuple ::
|
||||
|
||||
p::object tu = p::make_tuple('a','b','c');
|
||||
np::ndarray example_tuple = np::array(tu);
|
||||
|
||||
Let's now try the same with a list. We create an empty list, add an element using the append method, and as before, call the array method ::
|
||||
|
||||
p::list l;
|
||||
l.append('a');
|
||||
np::ndarray example_list = np::array (l);
|
||||
|
||||
Optionally, we can also specify a dtype for the array ::
|
||||
|
||||
np::dtype dt = np::dtype::get_builtin<int>();
|
||||
np::ndarray example_list1 = np::array (l,dt);
|
||||
|
||||
We can also create an array by supplying data arrays and a few other parameters.
|
||||
|
||||
First,create an integer array ::
|
||||
|
||||
int data[] = {1,2,3,4,5};
|
||||
|
||||
Create a shape, and strides, needed by the function ::
|
||||
|
||||
p::tuple shape = p::make_tuple(5);
|
||||
p::tuple stride = p::make_tuple(sizeof(int));
|
||||
|
||||
Here, shape is (4,) , and the stride is `sizeof(int)``.
|
||||
A stride is the number of bytes that must be traveled to get to the next desired element while constructing the ndarray.
|
||||
|
||||
The function also needs an owner, to keep track of the data array passed. Passing none is dangerous ::
|
||||
|
||||
p::object own;
|
||||
|
||||
The from_data function takes the data array, datatype,shape,stride and owner as arguments and returns an ndarray ::
|
||||
|
||||
np::ndarray data_ex1 = np::from_data(data,dt, shape,stride,own);
|
||||
|
||||
Now let's print the ndarray we created ::
|
||||
|
||||
std::cout << "Single dimensional array ::" << std::endl
|
||||
<< p::extract<char const *>(p::str(data_ex)) << std::endl;
|
||||
|
||||
Let's make it a little more interesting. Lets make an 3x2 ndarray from a multi-dimensional array using non-unit strides
|
||||
|
||||
First lets create a 3x4 array of 8-bit integers ::
|
||||
|
||||
uint8_t mul_data[][4] = {{1,2,3,4},{5,6,7,8},{1,3,5,7}};
|
||||
|
||||
Now let's create an array of 3x2 elements, picking the first and third elements from each row . For that, the shape will be 3x2.
|
||||
The strides will be 4x2 i.e. 4 bytes to go to the next desired row, and 2 bytes to go to the next desired column ::
|
||||
|
||||
shape = p::make_tuple(3,2);
|
||||
stride = p::make_tuple(sizeof(uint8_t)*2,sizeof(uint8_t));
|
||||
|
||||
Get the numpy dtype for the built-in 8-bit integer data type ::
|
||||
|
||||
np::dtype dt1 = np::dtype::get_builtin<uint8_t>();
|
||||
|
||||
Now lets first create and print out the ndarray as is.
|
||||
Notice how we can pass the shape and strides in the function directly, as well as the owner. The last part can be done because we don't have any use to
|
||||
manipulate the "owner" object ::
|
||||
|
||||
np::ndarray mul_data_ex = np::from_data(mul_data, dt1,
|
||||
p::make_tuple(3,4),
|
||||
p::make_tuple(4,1),
|
||||
p::object());
|
||||
std::cout << "Original multi dimensional array :: " << std::endl
|
||||
<< p::extract<char const *>(p::str(mul_data_ex)) << std::endl;
|
||||
|
||||
Now create the new ndarray using the shape and strides and print out the array we created using non-unit strides ::
|
||||
|
||||
mul_data_ex = np::from_data(mul_data, dt1, shape, stride, p::object());
|
||||
std::cout << "Selective multidimensional array :: "<<std::endl
|
||||
<< p::extract<char const *>(p::str(mul_data_ex)) << std::endl ;
|
||||
}
|
||||
|
||||
.. note:: The from_data method will throw ``error_already_set`` if the number of elements dictated by the shape and the corresponding strides don't match.
|
||||
41
doc/html/numpy/_sources/tutorial/simple.rst.txt
Normal file
41
doc/html/numpy/_sources/tutorial/simple.rst.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
A simple tutorial on Arrays
|
||||
===========================
|
||||
|
||||
Let's start with a simple tutorial to create and modify arrays.
|
||||
|
||||
Get the necessary headers for numpy components and set up necessary namespaces::
|
||||
|
||||
#include <boost/python/numpy.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
Initialise the Python runtime, and the numpy module. Failure to call these results in segmentation errors::
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Py_Initialize();
|
||||
np::initialize();
|
||||
|
||||
|
||||
Zero filled n-dimensional arrays can be created using the shape and data-type of the array as a parameter. Here, the shape is 3x3 and the datatype is the built-in float type::
|
||||
|
||||
p::tuple shape = p::make_tuple(3, 3);
|
||||
np::dtype dtype = np::dtype::get_builtin<float>();
|
||||
np::ndarray a = np::zeros(shape, dtype);
|
||||
|
||||
You can also create an empty array like this ::
|
||||
|
||||
np::ndarray b = np::empty(shape,dtype);
|
||||
|
||||
Print the original and reshaped array. The array a which is a list is first converted to a string, and each value in the list is extracted using extract< >::
|
||||
|
||||
std::cout << "Original array:\n" << p::extract<char const *>(p::str(a)) << std::endl;
|
||||
|
||||
// Reshape the array into a 1D array
|
||||
a = a.reshape(p::make_tuple(9));
|
||||
// Print it again.
|
||||
std::cout << "Reshaped array:\n" << p::extract<char const *>(p::str(a)) << std::endl;
|
||||
}
|
||||
|
||||
120
doc/html/numpy/_sources/tutorial/ufunc.rst.txt
Normal file
120
doc/html/numpy/_sources/tutorial/ufunc.rst.txt
Normal file
@@ -0,0 +1,120 @@
|
||||
Ufuncs
|
||||
======
|
||||
|
||||
Ufuncs or universal functions operate on ndarrays element by element, and support array broadcasting, type casting, and other features.
|
||||
|
||||
Lets try and see how we can use the binary and unary ufunc methods
|
||||
|
||||
After the neccessary includes ::
|
||||
|
||||
#include <boost/python/numpy.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace p = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
|
||||
Now we create the structs necessary to implement the ufuncs. The typedefs *must* be made as the ufunc generators take these typedefs as inputs and return an error otherwise ::
|
||||
|
||||
struct UnarySquare
|
||||
{
|
||||
typedef double argument_type;
|
||||
typedef double result_type;
|
||||
|
||||
double operator()(double r) const { return r * r;}
|
||||
};
|
||||
|
||||
struct BinarySquare
|
||||
{
|
||||
typedef double first_argument_type;
|
||||
typedef double second_argument_type;
|
||||
typedef double result_type;
|
||||
|
||||
double operator()(double a,double b) const { return (a*a + b*b) ; }
|
||||
};
|
||||
|
||||
Initialise the Python runtime and the numpy module ::
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Py_Initialize();
|
||||
np::initialize();
|
||||
|
||||
Now expose the struct UnarySquare to Python as a class, and let ud be the class object. ::
|
||||
|
||||
p::object ud = p::class_<UnarySquare, boost::shared_ptr<UnarySquare> >("UnarySquare");
|
||||
ud.def("__call__", np::unary_ufunc<UnarySquare>::make());
|
||||
|
||||
Let inst be an instance of the class ud ::
|
||||
|
||||
p::object inst = ud();
|
||||
|
||||
Use the "__call__" method to call the overloaded () operator and print the value ::
|
||||
|
||||
std::cout << "Square of unary scalar 1.0 is " << p::extract<char const *>(p::str(inst.attr("__call__")(1.0))) << std::endl;
|
||||
|
||||
Create an array in C++ ::
|
||||
|
||||
int arr[] = {1,2,3,4} ;
|
||||
|
||||
|
||||
..and use it to create the ndarray in Python ::
|
||||
|
||||
np::ndarray demo_array = np::from_data(arr, np::dtype::get_builtin<int>(),
|
||||
p::make_tuple(4),
|
||||
p::make_tuple(4),
|
||||
p::object());
|
||||
|
||||
Print out the demo array ::
|
||||
|
||||
std::cout << "Demo array is " << p::extract<char const *>(p::str(demo_array)) << std::endl;
|
||||
|
||||
Call the "__call__" method to perform the operation and assign the value to result_array ::
|
||||
|
||||
p::object result_array = inst.attr("__call__")(demo_array);
|
||||
|
||||
Print the resultant array ::
|
||||
|
||||
std::cout << "Square of demo array is " << p::extract<char const *>(p::str(result_array)) << std::endl;
|
||||
|
||||
Lets try the same with a list ::
|
||||
|
||||
p::list li;
|
||||
li.append(3);
|
||||
li.append(7);
|
||||
|
||||
Print out the demo list ::
|
||||
|
||||
std::cout << "Demo list is " << p::extract<char const *>(p::str(li)) << std::endl;
|
||||
|
||||
Call the ufunc for the list ::
|
||||
|
||||
result_array = inst.attr("__call__")(li);
|
||||
|
||||
And print the list out ::
|
||||
|
||||
std::cout << "Square of demo list is " << p::extract<char const *>(p::str(result_array)) << std::endl;
|
||||
|
||||
Now lets try Binary ufuncs. Again, expose the struct BinarySquare to Python as a class, and let ud be the class object ::
|
||||
|
||||
ud = p::class_<BinarySquare, boost::shared_ptr<BinarySquare> >("BinarySquare");
|
||||
ud.def("__call__", np::binary_ufunc<BinarySquare>::make());
|
||||
|
||||
And initialise ud ::
|
||||
|
||||
inst = ud();
|
||||
|
||||
Print the two input lists ::
|
||||
|
||||
std::cout << "The two input list for binary ufunc are " << std::endl
|
||||
<< p::extract<char const *>(p::str(demo_array)) << std::endl
|
||||
<< p::extract<char const *>(p::str(demo_array)) << std::endl;
|
||||
|
||||
Call the binary ufunc taking demo_array as both inputs ::
|
||||
|
||||
result_array = inst.attr("__call__")(demo_array,demo_array);
|
||||
|
||||
And print the output ::
|
||||
|
||||
std::cout << "Square of list with binary ufunc is " << p::extract<char const *>(p::str(result_array)) << std::endl;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
@@ -52,6 +52,8 @@ div.sphinxsidebar {
|
||||
width: 230px;
|
||||
margin-left: -100%;
|
||||
font-size: 90%;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap : break-word;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
@@ -79,14 +81,26 @@ div.sphinxsidebar input {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox form.search {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
width: 170px;
|
||||
float: left;
|
||||
width: 80%;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="submit"] {
|
||||
width: 30px;
|
||||
float: left;
|
||||
width: 20%;
|
||||
border-left: none;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
max-width: 100%;
|
||||
@@ -124,6 +138,8 @@ ul.keywordmatches li.goodmatch a {
|
||||
|
||||
table.contentstable {
|
||||
width: 90%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.contentstable p.biglink {
|
||||
@@ -151,9 +167,14 @@ table.indextable td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table.indextable dl, table.indextable dd {
|
||||
table.indextable ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
table.indextable > tbody > tr > td > ul {
|
||||
padding-left: 0em;
|
||||
}
|
||||
|
||||
table.indextable tr.pcap {
|
||||
@@ -185,8 +206,27 @@ div.genindex-jumpbox {
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
/* -- domain module index --------------------------------------------------- */
|
||||
|
||||
table.modindextable td {
|
||||
padding: 2px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
/* -- general body styles --------------------------------------------------- */
|
||||
|
||||
div.body {
|
||||
min-width: 450px;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li, div.body blockquote {
|
||||
-moz-hyphens: auto;
|
||||
-ms-hyphens: auto;
|
||||
-webkit-hyphens: auto;
|
||||
hyphens: auto;
|
||||
}
|
||||
|
||||
a.headerlink {
|
||||
visibility: hidden;
|
||||
}
|
||||
@@ -197,7 +237,10 @@ h3:hover > a.headerlink,
|
||||
h4:hover > a.headerlink,
|
||||
h5:hover > a.headerlink,
|
||||
h6:hover > a.headerlink,
|
||||
dt:hover > a.headerlink {
|
||||
dt:hover > a.headerlink,
|
||||
caption:hover > a.headerlink,
|
||||
p.caption:hover > a.headerlink,
|
||||
div.code-block-caption:hover > a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
@@ -209,10 +252,6 @@ div.body td {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.first {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
@@ -314,6 +353,18 @@ table.docutils {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
table caption span.caption-text {
|
||||
}
|
||||
|
||||
table.docutils td, table.docutils th {
|
||||
padding: 1px 8px 1px 5px;
|
||||
border-top: 0;
|
||||
@@ -322,10 +373,6 @@ table.docutils td, table.docutils th {
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
table.field-list td, table.field-list th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
table.footnote td, table.footnote th {
|
||||
border: 0 !important;
|
||||
}
|
||||
@@ -344,6 +391,53 @@ table.citation td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* -- figures --------------------------------------------------------------- */
|
||||
|
||||
div.figure {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.figure p.caption {
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-text {
|
||||
}
|
||||
|
||||
/* -- field list styles ----------------------------------------------------- */
|
||||
|
||||
table.field-list td, table.field-list th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.field-list p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.field-name {
|
||||
-moz-hyphens: manual;
|
||||
-ms-hyphens: manual;
|
||||
-webkit-hyphens: manual;
|
||||
hyphens: manual;
|
||||
}
|
||||
|
||||
/* -- hlist styles ---------------------------------------------------------- */
|
||||
|
||||
table.hlist td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
ol.arabic {
|
||||
@@ -384,28 +478,27 @@ dd {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
dt:target, .highlighted {
|
||||
dt:target, span.highlighted {
|
||||
background-color: #fbe54e;
|
||||
}
|
||||
|
||||
rect.highlighted {
|
||||
fill: #fbe54e;
|
||||
}
|
||||
|
||||
dl.glossary dt {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.field-list p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.sig-paren {
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
.versionmodified {
|
||||
font-style: italic;
|
||||
}
|
||||
@@ -456,6 +549,13 @@ pre {
|
||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
||||
}
|
||||
|
||||
span.pre {
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
-webkit-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
td.linenos pre {
|
||||
padding: 5px 0px;
|
||||
border: 0;
|
||||
@@ -471,22 +571,51 @@ table.highlighttable td {
|
||||
padding: 0 0.5em 0 0.5em;
|
||||
}
|
||||
|
||||
tt.descname {
|
||||
div.code-block-caption {
|
||||
padding: 2px 5px;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
div.code-block-caption code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
div.code-block-caption + div > div.highlight > pre {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-number {
|
||||
padding: 0.1em 0.3em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-text {
|
||||
}
|
||||
|
||||
div.literal-block-wrapper {
|
||||
padding: 1em 1em 0;
|
||||
}
|
||||
|
||||
div.literal-block-wrapper div.highlight {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
tt.descclassname {
|
||||
code.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
tt.xref, a tt {
|
||||
code.xref, a code {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
@@ -518,6 +647,16 @@ span.eqno {
|
||||
float: right;
|
||||
}
|
||||
|
||||
span.eqno a.headerlink {
|
||||
position: relative;
|
||||
left: 0px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
div.math:hover a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* -- printout stylesheet --------------------------------------------------- */
|
||||
|
||||
@media print {
|
||||
|
||||
261
doc/html/numpy/_static/classic.css
Normal file
261
doc/html/numpy/_static/classic.css
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* classic.css_t
|
||||
* ~~~~~~~~~~~~~
|
||||
*
|
||||
* Sphinx stylesheet -- classic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
font-size: 100%;
|
||||
background-color: #11303d;
|
||||
color: #000;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.document {
|
||||
background-color: #1c4e63;
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.bodywrapper {
|
||||
margin: 0 0 0 230px;
|
||||
}
|
||||
|
||||
div.body {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
padding: 0 20px 30px 20px;
|
||||
}
|
||||
|
||||
div.footer {
|
||||
color: #ffffff;
|
||||
width: 100%;
|
||||
padding: 9px 0 9px 0;
|
||||
text-align: center;
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
div.footer a {
|
||||
color: #ffffff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.related {
|
||||
background-color: #133f52;
|
||||
line-height: 30px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.related a {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 {
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
color: #ffffff;
|
||||
font-size: 1.4em;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 a {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h4 {
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
color: #ffffff;
|
||||
font-size: 1.3em;
|
||||
font-weight: normal;
|
||||
margin: 5px 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p.topless {
|
||||
margin: 5px 10px 10px 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
margin: 10px;
|
||||
padding: 0;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar a {
|
||||
color: #98dbcc;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #98dbcc;
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- hyperlink styles ------------------------------------------------------ */
|
||||
|
||||
a {
|
||||
color: #355f7c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #355f7c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
div.body h4,
|
||||
div.body h5,
|
||||
div.body h6 {
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
background-color: #f2f2f2;
|
||||
font-weight: normal;
|
||||
color: #20435c;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin: 20px -20px 10px -20px;
|
||||
padding: 3px 0 3px 10px;
|
||||
}
|
||||
|
||||
div.body h1 { margin-top: 0; font-size: 200%; }
|
||||
div.body h2 { font-size: 160%; }
|
||||
div.body h3 { font-size: 140%; }
|
||||
div.body h4 { font-size: 120%; }
|
||||
div.body h5 { font-size: 110%; }
|
||||
div.body h6 { font-size: 100%; }
|
||||
|
||||
a.headerlink {
|
||||
color: #c60f0f;
|
||||
font-size: 0.8em;
|
||||
padding: 0 4px 0 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.headerlink:hover {
|
||||
background-color: #c60f0f;
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li, div.body blockquote {
|
||||
text-align: justify;
|
||||
line-height: 130%;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title + p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.admonition p {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div.admonition pre {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div.admonition ul, div.admonition ol {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div.note {
|
||||
background-color: #eee;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
div.seealso {
|
||||
background-color: #ffc;
|
||||
border: 1px solid #ff6;
|
||||
}
|
||||
|
||||
div.topic {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
div.warning {
|
||||
background-color: #ffe4e4;
|
||||
border: 1px solid #f66;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
p.admonition-title:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 5px;
|
||||
background-color: #eeffcc;
|
||||
color: #333333;
|
||||
line-height: 120%;
|
||||
border: 1px solid #ac9;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
code {
|
||||
background-color: #ecf0f3;
|
||||
padding: 0 1px 0 1px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #ede;
|
||||
}
|
||||
|
||||
.warning code {
|
||||
background: #efc2c2;
|
||||
}
|
||||
|
||||
.note code {
|
||||
background: #d6d6d6;
|
||||
}
|
||||
|
||||
.viewcode-back {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div.viewcode-block:target {
|
||||
background-color: #f4debf;
|
||||
border-top: 1px solid #ac9;
|
||||
border-bottom: 1px solid #ac9;
|
||||
}
|
||||
|
||||
div.code-block-caption {
|
||||
color: #efefef;
|
||||
background-color: #1c4e63;
|
||||
}
|
||||
@@ -1,256 +1 @@
|
||||
/*
|
||||
* default.css_t
|
||||
* ~~~~~~~~~~~~~
|
||||
*
|
||||
* Sphinx stylesheet -- default theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
font-size: 100%;
|
||||
background-color: #11303d;
|
||||
color: #000;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.document {
|
||||
background-color: #1c4e63;
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.bodywrapper {
|
||||
margin: 0 0 0 230px;
|
||||
}
|
||||
|
||||
div.body {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
padding: 0 20px 30px 20px;
|
||||
}
|
||||
|
||||
div.footer {
|
||||
color: #ffffff;
|
||||
width: 100%;
|
||||
padding: 9px 0 9px 0;
|
||||
text-align: center;
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
div.footer a {
|
||||
color: #ffffff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.related {
|
||||
background-color: #133f52;
|
||||
line-height: 30px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.related a {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 {
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
color: #ffffff;
|
||||
font-size: 1.4em;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 a {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h4 {
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
color: #ffffff;
|
||||
font-size: 1.3em;
|
||||
font-weight: normal;
|
||||
margin: 5px 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p.topless {
|
||||
margin: 5px 10px 10px 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
margin: 10px;
|
||||
padding: 0;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.sphinxsidebar a {
|
||||
color: #98dbcc;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #98dbcc;
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- hyperlink styles ------------------------------------------------------ */
|
||||
|
||||
a {
|
||||
color: #355f7c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #355f7c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
div.body h4,
|
||||
div.body h5,
|
||||
div.body h6 {
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
background-color: #f2f2f2;
|
||||
font-weight: normal;
|
||||
color: #20435c;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin: 20px -20px 10px -20px;
|
||||
padding: 3px 0 3px 10px;
|
||||
}
|
||||
|
||||
div.body h1 { margin-top: 0; font-size: 200%; }
|
||||
div.body h2 { font-size: 160%; }
|
||||
div.body h3 { font-size: 140%; }
|
||||
div.body h4 { font-size: 120%; }
|
||||
div.body h5 { font-size: 110%; }
|
||||
div.body h6 { font-size: 100%; }
|
||||
|
||||
a.headerlink {
|
||||
color: #c60f0f;
|
||||
font-size: 0.8em;
|
||||
padding: 0 4px 0 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.headerlink:hover {
|
||||
background-color: #c60f0f;
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li {
|
||||
text-align: justify;
|
||||
line-height: 130%;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title + p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.admonition p {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div.admonition pre {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div.admonition ul, div.admonition ol {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div.note {
|
||||
background-color: #eee;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
div.seealso {
|
||||
background-color: #ffc;
|
||||
border: 1px solid #ff6;
|
||||
}
|
||||
|
||||
div.topic {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
div.warning {
|
||||
background-color: #ffe4e4;
|
||||
border: 1px solid #f66;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
p.admonition-title:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 5px;
|
||||
background-color: #eeffcc;
|
||||
color: #333333;
|
||||
line-height: 120%;
|
||||
border: 1px solid #ac9;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
tt {
|
||||
background-color: #ecf0f3;
|
||||
padding: 0 1px 0 1px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #ede;
|
||||
}
|
||||
|
||||
.warning tt {
|
||||
background: #efc2c2;
|
||||
}
|
||||
|
||||
.note tt {
|
||||
background: #d6d6d6;
|
||||
}
|
||||
|
||||
.viewcode-back {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div.viewcode-block:target {
|
||||
background-color: #f4debf;
|
||||
border-top: 1px solid #ac9;
|
||||
border-bottom: 1px solid #ac9;
|
||||
}
|
||||
@import url("classic.css");
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Sphinx JavaScript utilities for all documentation.
|
||||
*
|
||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ jQuery.urlencode = encodeURIComponent;
|
||||
* it will always return arrays of strings for the value parts.
|
||||
*/
|
||||
jQuery.getQueryParameters = function(s) {
|
||||
if (typeof s == 'undefined')
|
||||
if (typeof s === 'undefined')
|
||||
s = document.location.search;
|
||||
var parts = s.substr(s.indexOf('?') + 1).split('&');
|
||||
var result = {};
|
||||
@@ -66,31 +66,81 @@ jQuery.getQueryParameters = function(s) {
|
||||
* span elements with the given class name.
|
||||
*/
|
||||
jQuery.fn.highlightText = function(text, className) {
|
||||
function highlight(node) {
|
||||
if (node.nodeType == 3) {
|
||||
function highlight(node, addItems) {
|
||||
if (node.nodeType === 3) {
|
||||
var val = node.nodeValue;
|
||||
var pos = val.toLowerCase().indexOf(text);
|
||||
if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
|
||||
var span = document.createElement("span");
|
||||
span.className = className;
|
||||
if (pos >= 0 &&
|
||||
!jQuery(node.parentNode).hasClass(className) &&
|
||||
!jQuery(node.parentNode).hasClass("nohighlight")) {
|
||||
var span;
|
||||
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
|
||||
if (isInSVG) {
|
||||
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
||||
} else {
|
||||
span = document.createElement("span");
|
||||
span.className = className;
|
||||
}
|
||||
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
|
||||
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
|
||||
document.createTextNode(val.substr(pos + text.length)),
|
||||
node.nextSibling));
|
||||
node.nodeValue = val.substr(0, pos);
|
||||
if (isInSVG) {
|
||||
var bbox = span.getBBox();
|
||||
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||||
rect.x.baseVal.value = bbox.x;
|
||||
rect.y.baseVal.value = bbox.y;
|
||||
rect.width.baseVal.value = bbox.width;
|
||||
rect.height.baseVal.value = bbox.height;
|
||||
rect.setAttribute('class', className);
|
||||
var parentOfText = node.parentNode.parentNode;
|
||||
addItems.push({
|
||||
"parent": node.parentNode,
|
||||
"target": rect});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!jQuery(node).is("button, select, textarea")) {
|
||||
jQuery.each(node.childNodes, function() {
|
||||
highlight(this);
|
||||
highlight(this, addItems);
|
||||
});
|
||||
}
|
||||
}
|
||||
return this.each(function() {
|
||||
highlight(this);
|
||||
var addItems = [];
|
||||
var result = this.each(function() {
|
||||
highlight(this, addItems);
|
||||
});
|
||||
for (var i = 0; i < addItems.length; ++i) {
|
||||
jQuery(addItems[i].parent).before(addItems[i].target);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
* backward compatibility for jQuery.browser
|
||||
* This will be supported until firefox bug is fixed.
|
||||
*/
|
||||
if (!jQuery.browser) {
|
||||
jQuery.uaMatch = function(ua) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(msie) ([\w.]+)/.exec(ua) ||
|
||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
|
||||
[];
|
||||
|
||||
return {
|
||||
browser: match[ 1 ] || "",
|
||||
version: match[ 2 ] || "0"
|
||||
};
|
||||
};
|
||||
jQuery.browser = {};
|
||||
jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Small JavaScript module for the documentation.
|
||||
*/
|
||||
@@ -100,27 +150,30 @@ var Documentation = {
|
||||
this.fixFirefoxAnchorBug();
|
||||
this.highlightSearchWords();
|
||||
this.initIndexTable();
|
||||
if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
|
||||
this.initOnKeyListeners();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* i18n support
|
||||
*/
|
||||
TRANSLATIONS : {},
|
||||
PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
|
||||
PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; },
|
||||
LOCALE : 'unknown',
|
||||
|
||||
// gettext and ngettext don't access this so that the functions
|
||||
// can safely bound to a different name (_ = Documentation.gettext)
|
||||
gettext : function(string) {
|
||||
var translated = Documentation.TRANSLATIONS[string];
|
||||
if (typeof translated == 'undefined')
|
||||
if (typeof translated === 'undefined')
|
||||
return string;
|
||||
return (typeof translated == 'string') ? translated : translated[0];
|
||||
return (typeof translated === 'string') ? translated : translated[0];
|
||||
},
|
||||
|
||||
ngettext : function(singular, plural, n) {
|
||||
var translated = Documentation.TRANSLATIONS[singular];
|
||||
if (typeof translated == 'undefined')
|
||||
if (typeof translated === 'undefined')
|
||||
return (n == 1) ? singular : plural;
|
||||
return translated[Documentation.PLURALEXPR(n)];
|
||||
},
|
||||
@@ -152,6 +205,7 @@ var Documentation = {
|
||||
|
||||
/**
|
||||
* workaround a firefox stupidity
|
||||
* see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
|
||||
*/
|
||||
fixFirefoxAnchorBug : function() {
|
||||
if (document.location.hash && $.browser.mozilla)
|
||||
@@ -190,7 +244,7 @@ var Documentation = {
|
||||
var src = $(this).attr('src');
|
||||
var idnum = $(this).attr('id').substr(7);
|
||||
$('tr.cg-' + idnum).toggle();
|
||||
if (src.substr(-9) == 'minus.png')
|
||||
if (src.substr(-9) === 'minus.png')
|
||||
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
|
||||
else
|
||||
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
|
||||
@@ -222,11 +276,34 @@ var Documentation = {
|
||||
var path = document.location.pathname;
|
||||
var parts = path.split(/\//);
|
||||
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
|
||||
if (this == '..')
|
||||
if (this === '..')
|
||||
parts.pop();
|
||||
});
|
||||
var url = parts.join('/');
|
||||
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
||||
},
|
||||
|
||||
initOnKeyListeners: function() {
|
||||
$(document).keyup(function(event) {
|
||||
var activeElementType = document.activeElement.tagName;
|
||||
// don't navigate when in search box or textarea
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
|
||||
switch (event.keyCode) {
|
||||
case 37: // left
|
||||
var prevHref = $('link[rel="prev"]').prop('href');
|
||||
if (prevHref) {
|
||||
window.location.href = prevHref;
|
||||
return false;
|
||||
}
|
||||
case 39: // right
|
||||
var nextHref = $('link[rel="next"]').prop('href');
|
||||
if (nextHref) {
|
||||
window.location.href = nextHref;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
10
doc/html/numpy/_static/documentation_options.js
Normal file
10
doc/html/numpy/_static/documentation_options.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||
VERSION: '1.0',
|
||||
LANGUAGE: 'None',
|
||||
COLLAPSE_INDEX: false,
|
||||
FILE_SUFFIX: '.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt',
|
||||
NAVIGATION_WITH_KEYS: false,
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 286 B |
17109
doc/html/numpy/_static/jquery.js
vendored
17109
doc/html/numpy/_static/jquery.js
vendored
File diff suppressed because it is too large
Load Diff
297
doc/html/numpy/_static/language_data.js
Normal file
297
doc/html/numpy/_static/language_data.js
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* language_data.js
|
||||
* ~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* This script contains the language-specific data used by searchtools.js,
|
||||
* namely the list of stopwords, stemmer, scorer and splitter.
|
||||
*
|
||||
* :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
|
||||
|
||||
|
||||
/* Non-minified version JS is _stemmer.js if file is provided */
|
||||
/**
|
||||
* Porter Stemmer
|
||||
*/
|
||||
var Stemmer = function() {
|
||||
|
||||
var step2list = {
|
||||
ational: 'ate',
|
||||
tional: 'tion',
|
||||
enci: 'ence',
|
||||
anci: 'ance',
|
||||
izer: 'ize',
|
||||
bli: 'ble',
|
||||
alli: 'al',
|
||||
entli: 'ent',
|
||||
eli: 'e',
|
||||
ousli: 'ous',
|
||||
ization: 'ize',
|
||||
ation: 'ate',
|
||||
ator: 'ate',
|
||||
alism: 'al',
|
||||
iveness: 'ive',
|
||||
fulness: 'ful',
|
||||
ousness: 'ous',
|
||||
aliti: 'al',
|
||||
iviti: 'ive',
|
||||
biliti: 'ble',
|
||||
logi: 'log'
|
||||
};
|
||||
|
||||
var step3list = {
|
||||
icate: 'ic',
|
||||
ative: '',
|
||||
alize: 'al',
|
||||
iciti: 'ic',
|
||||
ical: 'ic',
|
||||
ful: '',
|
||||
ness: ''
|
||||
};
|
||||
|
||||
var c = "[^aeiou]"; // consonant
|
||||
var v = "[aeiouy]"; // vowel
|
||||
var C = c + "[^aeiouy]*"; // consonant sequence
|
||||
var V = v + "[aeiou]*"; // vowel sequence
|
||||
|
||||
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
|
||||
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
|
||||
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
|
||||
var s_v = "^(" + C + ")?" + v; // vowel in stem
|
||||
|
||||
this.stemWord = function (w) {
|
||||
var stem;
|
||||
var suffix;
|
||||
var firstch;
|
||||
var origword = w;
|
||||
|
||||
if (w.length < 3)
|
||||
return w;
|
||||
|
||||
var re;
|
||||
var re2;
|
||||
var re3;
|
||||
var re4;
|
||||
|
||||
firstch = w.substr(0,1);
|
||||
if (firstch == "y")
|
||||
w = firstch.toUpperCase() + w.substr(1);
|
||||
|
||||
// Step 1a
|
||||
re = /^(.+?)(ss|i)es$/;
|
||||
re2 = /^(.+?)([^s])s$/;
|
||||
|
||||
if (re.test(w))
|
||||
w = w.replace(re,"$1$2");
|
||||
else if (re2.test(w))
|
||||
w = w.replace(re2,"$1$2");
|
||||
|
||||
// Step 1b
|
||||
re = /^(.+?)eed$/;
|
||||
re2 = /^(.+?)(ed|ing)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(fp[1])) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1];
|
||||
re2 = new RegExp(s_v);
|
||||
if (re2.test(stem)) {
|
||||
w = stem;
|
||||
re2 = /(at|bl|iz)$/;
|
||||
re3 = new RegExp("([^aeiouylsz])\\1$");
|
||||
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re2.test(w))
|
||||
w = w + "e";
|
||||
else if (re3.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
else if (re4.test(w))
|
||||
w = w + "e";
|
||||
}
|
||||
}
|
||||
|
||||
// Step 1c
|
||||
re = /^(.+?)y$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(s_v);
|
||||
if (re.test(stem))
|
||||
w = stem + "i";
|
||||
}
|
||||
|
||||
// Step 2
|
||||
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step2list[suffix];
|
||||
}
|
||||
|
||||
// Step 3
|
||||
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step3list[suffix];
|
||||
}
|
||||
|
||||
// Step 4
|
||||
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
||||
re2 = /^(.+?)(s|t)(ion)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
if (re.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1] + fp[2];
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re2.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
|
||||
// Step 5
|
||||
re = /^(.+?)e$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
re2 = new RegExp(meq1);
|
||||
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
|
||||
w = stem;
|
||||
}
|
||||
re = /ll$/;
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re.test(w) && re2.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
|
||||
// and turn initial Y back to y
|
||||
if (firstch == "y")
|
||||
w = firstch.toLowerCase() + w.substr(1);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var splitChars = (function() {
|
||||
var result = {};
|
||||
var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
|
||||
1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
|
||||
2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
|
||||
2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
|
||||
3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
|
||||
3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
|
||||
4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
|
||||
8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
|
||||
11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
|
||||
43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
|
||||
var i, j, start, end;
|
||||
for (i = 0; i < singles.length; i++) {
|
||||
result[singles[i]] = true;
|
||||
}
|
||||
var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
|
||||
[722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
|
||||
[1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
|
||||
[1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
|
||||
[1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
|
||||
[2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
|
||||
[2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
|
||||
[2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
|
||||
[2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
|
||||
[2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
|
||||
[2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
|
||||
[2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
|
||||
[3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
|
||||
[3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
|
||||
[3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
|
||||
[3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
|
||||
[3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
|
||||
[3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
|
||||
[4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
|
||||
[4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
|
||||
[4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
|
||||
[4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
|
||||
[5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
|
||||
[6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
|
||||
[6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
|
||||
[6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
|
||||
[6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
|
||||
[7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
|
||||
[7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
|
||||
[8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
|
||||
[8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
|
||||
[8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
|
||||
[10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
|
||||
[11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
|
||||
[12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
|
||||
[12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
|
||||
[12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
|
||||
[19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
|
||||
[42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
|
||||
[42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
|
||||
[43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
|
||||
[43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
|
||||
[43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
|
||||
[43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
|
||||
[44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
|
||||
[57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
|
||||
[64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
|
||||
[65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
|
||||
[65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
|
||||
for (i = 0; i < ranges.length; i++) {
|
||||
start = ranges[i][0];
|
||||
end = ranges[i][1];
|
||||
for (j = start; j <= end; j++) {
|
||||
result[j] = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
|
||||
function splitQuery(query) {
|
||||
var result = [];
|
||||
var start = -1;
|
||||
for (var i = 0; i < query.length; i++) {
|
||||
if (splitChars[query.charCodeAt(i)]) {
|
||||
if (start !== -1) {
|
||||
result.push(query.slice(start, i));
|
||||
start = -1;
|
||||
}
|
||||
} else if (start === -1) {
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
if (start !== -1) {
|
||||
result.push(query.slice(start));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 90 B |
Binary file not shown.
|
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 90 B |
@@ -4,8 +4,10 @@
|
||||
.highlight .err { border: 1px solid #FF0000 } /* Error */
|
||||
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
|
||||
.highlight .o { color: #666666 } /* Operator */
|
||||
.highlight .ch { color: #408080; font-style: italic } /* Comment.Hashbang */
|
||||
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
||||
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
|
||||
.highlight .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
|
||||
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
||||
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
|
||||
.highlight .gd { color: #A00000 } /* Generic.Deleted */
|
||||
@@ -40,12 +42,15 @@
|
||||
.highlight .nv { color: #19177C } /* Name.Variable */
|
||||
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
||||
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.highlight .mb { color: #666666 } /* Literal.Number.Bin */
|
||||
.highlight .mf { color: #666666 } /* Literal.Number.Float */
|
||||
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
|
||||
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
|
||||
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
|
||||
.highlight .sa { color: #BA2121 } /* Literal.String.Affix */
|
||||
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
|
||||
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
|
||||
.highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */
|
||||
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
||||
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
|
||||
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
||||
@@ -56,7 +61,9 @@
|
||||
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
|
||||
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
|
||||
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
|
||||
.highlight .fm { color: #0000FF } /* Name.Function.Magic */
|
||||
.highlight .vc { color: #19177C } /* Name.Variable.Class */
|
||||
.highlight .vg { color: #19177C } /* Name.Variable.Global */
|
||||
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
|
||||
.highlight .vm { color: #19177C } /* Name.Variable.Magic */
|
||||
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
|
||||
@@ -1,229 +1,51 @@
|
||||
/*
|
||||
* searchtools.js_t
|
||||
* searchtools.js
|
||||
* ~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* Sphinx JavaScript utilties for the full-text search.
|
||||
* Sphinx JavaScript utilities for the full-text search.
|
||||
*
|
||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
if (!Scorer) {
|
||||
/**
|
||||
* Simple result scoring code.
|
||||
*/
|
||||
var Scorer = {
|
||||
// Implement the following function to further tweak the score for each result
|
||||
// The function takes a result array [filename, title, anchor, descr, score]
|
||||
// and returns the new score.
|
||||
/*
|
||||
score: function(result) {
|
||||
return result[4];
|
||||
},
|
||||
*/
|
||||
|
||||
/**
|
||||
* Porter Stemmer
|
||||
*/
|
||||
var Stemmer = function() {
|
||||
// query matches the full name of an object
|
||||
objNameMatch: 11,
|
||||
// or matches in the last dotted part of the object name
|
||||
objPartialMatch: 6,
|
||||
// Additive scores depending on the priority of the object
|
||||
objPrio: {0: 15, // used to be importantResults
|
||||
1: 5, // used to be objectResults
|
||||
2: -5}, // used to be unimportantResults
|
||||
// Used when the priority is not in the mapping.
|
||||
objPrioDefault: 0,
|
||||
|
||||
var step2list = {
|
||||
ational: 'ate',
|
||||
tional: 'tion',
|
||||
enci: 'ence',
|
||||
anci: 'ance',
|
||||
izer: 'ize',
|
||||
bli: 'ble',
|
||||
alli: 'al',
|
||||
entli: 'ent',
|
||||
eli: 'e',
|
||||
ousli: 'ous',
|
||||
ization: 'ize',
|
||||
ation: 'ate',
|
||||
ator: 'ate',
|
||||
alism: 'al',
|
||||
iveness: 'ive',
|
||||
fulness: 'ful',
|
||||
ousness: 'ous',
|
||||
aliti: 'al',
|
||||
iviti: 'ive',
|
||||
biliti: 'ble',
|
||||
logi: 'log'
|
||||
// query found in title
|
||||
title: 15,
|
||||
// query found in terms
|
||||
term: 5
|
||||
};
|
||||
|
||||
var step3list = {
|
||||
icate: 'ic',
|
||||
ative: '',
|
||||
alize: 'al',
|
||||
iciti: 'ic',
|
||||
ical: 'ic',
|
||||
ful: '',
|
||||
ness: ''
|
||||
};
|
||||
|
||||
var c = "[^aeiou]"; // consonant
|
||||
var v = "[aeiouy]"; // vowel
|
||||
var C = c + "[^aeiouy]*"; // consonant sequence
|
||||
var V = v + "[aeiou]*"; // vowel sequence
|
||||
|
||||
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
|
||||
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
|
||||
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
|
||||
var s_v = "^(" + C + ")?" + v; // vowel in stem
|
||||
|
||||
this.stemWord = function (w) {
|
||||
var stem;
|
||||
var suffix;
|
||||
var firstch;
|
||||
var origword = w;
|
||||
|
||||
if (w.length < 3)
|
||||
return w;
|
||||
|
||||
var re;
|
||||
var re2;
|
||||
var re3;
|
||||
var re4;
|
||||
|
||||
firstch = w.substr(0,1);
|
||||
if (firstch == "y")
|
||||
w = firstch.toUpperCase() + w.substr(1);
|
||||
|
||||
// Step 1a
|
||||
re = /^(.+?)(ss|i)es$/;
|
||||
re2 = /^(.+?)([^s])s$/;
|
||||
|
||||
if (re.test(w))
|
||||
w = w.replace(re,"$1$2");
|
||||
else if (re2.test(w))
|
||||
w = w.replace(re2,"$1$2");
|
||||
|
||||
// Step 1b
|
||||
re = /^(.+?)eed$/;
|
||||
re2 = /^(.+?)(ed|ing)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(fp[1])) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1];
|
||||
re2 = new RegExp(s_v);
|
||||
if (re2.test(stem)) {
|
||||
w = stem;
|
||||
re2 = /(at|bl|iz)$/;
|
||||
re3 = new RegExp("([^aeiouylsz])\\1$");
|
||||
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re2.test(w))
|
||||
w = w + "e";
|
||||
else if (re3.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
else if (re4.test(w))
|
||||
w = w + "e";
|
||||
}
|
||||
}
|
||||
|
||||
// Step 1c
|
||||
re = /^(.+?)y$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(s_v);
|
||||
if (re.test(stem))
|
||||
w = stem + "i";
|
||||
}
|
||||
|
||||
// Step 2
|
||||
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step2list[suffix];
|
||||
}
|
||||
|
||||
// Step 3
|
||||
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step3list[suffix];
|
||||
}
|
||||
|
||||
// Step 4
|
||||
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
||||
re2 = /^(.+?)(s|t)(ion)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
if (re.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1] + fp[2];
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re2.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
|
||||
// Step 5
|
||||
re = /^(.+?)e$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
re2 = new RegExp(meq1);
|
||||
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
|
||||
w = stem;
|
||||
}
|
||||
re = /ll$/;
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re.test(w) && re2.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
|
||||
// and turn initial Y back to y
|
||||
if (firstch == "y")
|
||||
w = firstch.toLowerCase() + w.substr(1);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simple result scoring code.
|
||||
*/
|
||||
var Scorer = {
|
||||
// Implement the following function to further tweak the score for each result
|
||||
// The function takes a result array [filename, title, anchor, descr, score]
|
||||
// and returns the new score.
|
||||
/*
|
||||
score: function(result) {
|
||||
return result[4];
|
||||
},
|
||||
*/
|
||||
|
||||
// query matches the full name of an object
|
||||
objNameMatch: 11,
|
||||
// or matches in the last dotted part of the object name
|
||||
objPartialMatch: 6,
|
||||
// Additive scores depending on the priority of the object
|
||||
objPrio: {0: 15, // used to be importantResults
|
||||
1: 5, // used to be objectResults
|
||||
2: -5}, // used to be unimportantResults
|
||||
// Used when the priority is not in the mapping.
|
||||
objPrioDefault: 0,
|
||||
|
||||
// query found in title
|
||||
title: 15,
|
||||
// query found in terms
|
||||
term: 5
|
||||
};
|
||||
|
||||
if (!splitQuery) {
|
||||
function splitQuery(query) {
|
||||
return query.split(/\s+/);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Module
|
||||
@@ -316,14 +138,13 @@ var Search = {
|
||||
*/
|
||||
query : function(query) {
|
||||
var i;
|
||||
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
|
||||
|
||||
// stem the searchterms and add them to the correct list
|
||||
var stemmer = new Stemmer();
|
||||
var searchterms = [];
|
||||
var excluded = [];
|
||||
var hlterms = [];
|
||||
var tmp = query.split(/\s+/);
|
||||
var tmp = splitQuery(query);
|
||||
var objectterms = [];
|
||||
for (i = 0; i < tmp.length; i++) {
|
||||
if (tmp[i] !== "") {
|
||||
@@ -337,6 +158,10 @@ var Search = {
|
||||
}
|
||||
// stem the word
|
||||
var word = stemmer.stemWord(tmp[i].toLowerCase());
|
||||
// prevent stemmer from cutting word smaller than two chars
|
||||
if(word.length < 3 && tmp[i].length >= 3) {
|
||||
word = tmp[i];
|
||||
}
|
||||
var toAppend;
|
||||
// select the correct list
|
||||
if (word[0] == '-') {
|
||||
@@ -373,8 +198,7 @@ var Search = {
|
||||
}
|
||||
|
||||
// lookup as search terms in fulltext
|
||||
results = results.concat(this.performTermsSearch(searchterms, excluded, terms, Scorer.term))
|
||||
.concat(this.performTermsSearch(searchterms, excluded, titleterms, Scorer.title));
|
||||
results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms));
|
||||
|
||||
// let the scorer override scores with a custom scoring function
|
||||
if (Scorer.score) {
|
||||
@@ -435,11 +259,15 @@ var Search = {
|
||||
displayNextItem();
|
||||
});
|
||||
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
|
||||
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt',
|
||||
var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX;
|
||||
if (suffix === undefined) {
|
||||
suffix = '.txt';
|
||||
}
|
||||
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix),
|
||||
dataType: "text",
|
||||
complete: function(jqxhr, textstatus) {
|
||||
var data = jqxhr.responseText;
|
||||
if (data !== '') {
|
||||
if (data !== '' && data !== undefined) {
|
||||
listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
|
||||
}
|
||||
Search.output.append(listItem);
|
||||
@@ -474,6 +302,7 @@ var Search = {
|
||||
*/
|
||||
performObjectSearch : function(object, otherterms) {
|
||||
var filenames = this._index.filenames;
|
||||
var docnames = this._index.docnames;
|
||||
var objects = this._index.objects;
|
||||
var objnames = this._index.objnames;
|
||||
var titles = this._index.titles;
|
||||
@@ -527,7 +356,7 @@ var Search = {
|
||||
} else {
|
||||
score += Scorer.objPrioDefault;
|
||||
}
|
||||
results.push([filenames[match[0]], fullname, '#'+anchor, descr, score]);
|
||||
results.push([docnames[match[0]], fullname, '#'+anchor, descr, score, filenames[match[0]]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -538,23 +367,48 @@ var Search = {
|
||||
/**
|
||||
* search for full-text terms in the index
|
||||
*/
|
||||
performTermsSearch : function(searchterms, excluded, terms, score) {
|
||||
performTermsSearch : function(searchterms, excluded, terms, titleterms) {
|
||||
var docnames = this._index.docnames;
|
||||
var filenames = this._index.filenames;
|
||||
var titles = this._index.titles;
|
||||
|
||||
var i, j, file, files;
|
||||
var i, j, file;
|
||||
var fileMap = {};
|
||||
var scoreMap = {};
|
||||
var results = [];
|
||||
|
||||
// perform the search on the required terms
|
||||
for (i = 0; i < searchterms.length; i++) {
|
||||
var word = searchterms[i];
|
||||
var files = [];
|
||||
var _o = [
|
||||
{files: terms[word], score: Scorer.term},
|
||||
{files: titleterms[word], score: Scorer.title}
|
||||
];
|
||||
|
||||
// no match but word was a required one
|
||||
if ((files = terms[word]) === undefined)
|
||||
if ($u.every(_o, function(o){return o.files === undefined;})) {
|
||||
break;
|
||||
if (files.length === undefined) {
|
||||
files = [files];
|
||||
}
|
||||
// found search word in contents
|
||||
$u.each(_o, function(o) {
|
||||
var _files = o.files;
|
||||
if (_files === undefined)
|
||||
return
|
||||
|
||||
if (_files.length === undefined)
|
||||
_files = [_files];
|
||||
files = files.concat(_files);
|
||||
|
||||
// set score for the word in each file to Scorer.term
|
||||
for (j = 0; j < _files.length; j++) {
|
||||
file = _files[j];
|
||||
if (!(file in scoreMap))
|
||||
scoreMap[file] = {}
|
||||
scoreMap[file][word] = o.score;
|
||||
}
|
||||
});
|
||||
|
||||
// create the mapping
|
||||
for (j = 0; j < files.length; j++) {
|
||||
file = files[j];
|
||||
@@ -576,7 +430,9 @@ var Search = {
|
||||
// ensure that none of the excluded terms is in the search result
|
||||
for (i = 0; i < excluded.length; i++) {
|
||||
if (terms[excluded[i]] == file ||
|
||||
$u.contains(terms[excluded[i]] || [], file)) {
|
||||
titleterms[excluded[i]] == file ||
|
||||
$u.contains(terms[excluded[i]] || [], file) ||
|
||||
$u.contains(titleterms[excluded[i]] || [], file)) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
@@ -584,7 +440,10 @@ var Search = {
|
||||
|
||||
// if we have still a valid result we can add it to the result list
|
||||
if (valid) {
|
||||
results.push([filenames[file], titles[file], '', null, score]);
|
||||
// select one (max) score for the file.
|
||||
// for better ranking, we should calculate ranking by using words statistics like basic tf-idf...
|
||||
var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[file][w]}));
|
||||
results.push([docnames[file], titles[file], '', null, score, filenames[file]]);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
@@ -594,7 +453,7 @@ var Search = {
|
||||
* helper function to return a node containing the
|
||||
* search summary for a given text. keywords is a list
|
||||
* of stemmed words, hlwords is the list of normal, unstemmed
|
||||
* words. the first one is used to find the occurance, the
|
||||
* words. the first one is used to find the occurrence, the
|
||||
* latter for highlighting it.
|
||||
*/
|
||||
makeSearchSummary : function(text, keywords, hlwords) {
|
||||
@@ -619,4 +478,4 @@ var Search = {
|
||||
|
||||
$(document).ready(function() {
|
||||
Search.init();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* Once the browser is closed the cookie is deleted and the position
|
||||
* reset to the default (expanded).
|
||||
*
|
||||
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,7 @@
|
||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="#" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="index.html" />
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="#" />
|
||||
|
||||
Binary file not shown.
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -69,7 +70,7 @@
|
||||
<div class="section" id="binary-ufunc">
|
||||
<h1><a class="toc-backref" href="#id1">binary_ufunc</a></h1>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first">Table of Contents</p>
|
||||
<p class="topic-title">Table of Contents</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#binary-ufunc" id="id1">binary_ufunc</a><ul>
|
||||
<li><a class="reference internal" href="#synopsis" id="id2">synopsis</a></li>
|
||||
@@ -80,12 +81,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>A <tt class="docutils literal"><span class="pre">binary_ufunc</span></tt> is a struct used as an intermediate step to broadcast two arguments so that a C++ function can be converted to a ufunc like function</p>
|
||||
<p>A <code class="docutils literal notranslate"><span class="pre">binary_ufunc</span></code> is a struct used as an intermediate step to broadcast two arguments so that a C++ function can be converted to a ufunc like function</p>
|
||||
<blockquote>
|
||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ufunc.hpp></span></tt> contains the <tt class="docutils literal"><span class="pre">binary_ufunc</span></tt> structure definitions</div></blockquote>
|
||||
<div><code class="docutils literal notranslate"><span class="pre"><boost/python/numpy/ufunc.hpp></span></code> contains the <code class="docutils literal notranslate"><span class="pre">binary_ufunc</span></code> structure definitions</div></blockquote>
|
||||
<div class="section" id="synopsis">
|
||||
<h2><a class="toc-backref" href="#id2">synopsis</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">namespace</span> <span class="n">python</span>
|
||||
<span class="p">{</span>
|
||||
@@ -116,7 +117,7 @@
|
||||
</div>
|
||||
<div class="section" id="constructors">
|
||||
<h2><a class="toc-backref" href="#id3">constructors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">example_binary_ufunc</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">example_binary_ufunc</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">typedef</span> <span class="n">any_valid</span> <span class="n">first_argument_type</span><span class="p">;</span>
|
||||
<span class="k">typedef</span> <span class="n">any_valid</span> <span class="n">second_argument_type</span><span class="p">;</span>
|
||||
@@ -128,16 +129,16 @@
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The <tt class="docutils literal"><span class="pre">any_valid</span></tt> type must be defined using typedef as a valid C++ type in order to use the struct methods correctly</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The <code class="docutils literal notranslate"><span class="pre">any_valid</span></code> type must be defined using typedef as a valid C++ type in order to use the struct methods correctly</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">The struct must be exposed as a Python class, and an instance of the class must be created to use the <tt class="docutils literal"><span class="pre">call</span></tt> method corresponding to the <tt class="docutils literal"><span class="pre">__call__</span></tt> attribute of the Python object</td>
|
||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">The struct must be exposed as a Python class, and an instance of the class must be created to use the <code class="docutils literal notranslate"><span class="pre">call</span></code> method corresponding to the <code class="docutils literal notranslate"><span class="pre">__call__</span></code> attribute of the Python object</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="accessors">
|
||||
<h2><a class="toc-backref" href="#id4">accessors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="p">,</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TArgument1</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">first_argument_type</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TArgument2</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">second_argument_type</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
||||
@@ -150,13 +151,13 @@
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TBinaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument1</span></tt> and <tt class="docutils literal"><span class="pre">TArgument2</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <code class="docutils literal notranslate"><span class="pre">TBinaryFunctor</span></code> and optionally <code class="docutils literal notranslate"><span class="pre">TArgument1</span></code> and <code class="docutils literal notranslate"><span class="pre">TArgument2</span></code> for argument type and <code class="docutils literal notranslate"><span class="pre">TResult</span></code> for result type</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Effects:</th><td class="field-body">Passes a Python object to the underlying C++ functor after broadcasting its arguments</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="p">,</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TArgument1</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">first_argument_type</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TArgument2</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">second_argument_type</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TBinaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
||||
@@ -167,7 +168,7 @@
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TBinaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument1</span></tt> and <tt class="docutils literal"><span class="pre">TArgument2</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <code class="docutils literal notranslate"><span class="pre">TBinaryFunctor</span></code> and optionally <code class="docutils literal notranslate"><span class="pre">TArgument1</span></code> and <code class="docutils literal notranslate"><span class="pre">TArgument2</span></code> for argument type and <code class="docutils literal notranslate"><span class="pre">TResult</span></code> for result type</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A Python function object to call the overloaded () operator in the struct (in typical usage)</td>
|
||||
</tr>
|
||||
@@ -176,7 +177,7 @@
|
||||
</div>
|
||||
<div class="section" id="example-s">
|
||||
<h2><a class="toc-backref" href="#id5">Example(s)</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
|
||||
<span class="k">struct</span> <span class="n">BinarySquare</span>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -69,7 +70,7 @@
|
||||
<div class="section" id="dtype">
|
||||
<h1><a class="toc-backref" href="#id2">dtype</a></h1>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first">Table of Contents</p>
|
||||
<p class="topic-title">Table of Contents</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#dtype" id="id2">dtype</a><ul>
|
||||
<li><a class="reference internal" href="#synopsis" id="id3">synopsis</a></li>
|
||||
@@ -82,10 +83,10 @@
|
||||
</div>
|
||||
<p>A <a class="reference external" href="http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#data-type-objects-dtype">dtype</a> is an object describing the type of the elements of an ndarray</p>
|
||||
<blockquote>
|
||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/dtype.hpp></span></tt> contains the method calls necessary to generate a python object equivalent to a numpy.dtype from builtin C++ objects, as well as to create custom dtypes from user defined types</div></blockquote>
|
||||
<div><code class="docutils literal notranslate"><span class="pre"><boost/python/numpy/dtype.hpp></span></code> contains the method calls necessary to generate a python object equivalent to a numpy.dtype from builtin C++ objects, as well as to create custom dtypes from user defined types</div></blockquote>
|
||||
<div class="section" id="synopsis">
|
||||
<h2><a class="toc-backref" href="#id3">synopsis</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">namespace</span> <span class="n">python</span>
|
||||
<span class="p">{</span>
|
||||
@@ -95,7 +96,7 @@
|
||||
<span class="k">class</span> <span class="nc">dtype</span> <span class="o">:</span> <span class="k">public</span> <span class="n">object</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">static</span> <span class="n">python</span><span class="o">::</span><span class="n">detail</span><span class="o">::</span><span class="n">new_reference</span> <span class="n">convert</span><span class="p">(</span><span class="n">object</span><span class="o">::</span><span class="n">object_cref</span> <span class="n">arg</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">align</span><span class="p">);</span>
|
||||
<span class="nl">public:</span>
|
||||
<span class="k">public</span><span class="o">:</span>
|
||||
|
||||
<span class="c1">// Convert an arbitrary Python object to a data-type descriptor object.</span>
|
||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span>
|
||||
@@ -105,7 +106,7 @@
|
||||
<span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="k">static</span> <span class="n">dtype</span> <span class="n">get_builtin</span><span class="p">();</span>
|
||||
|
||||
<span class="c1">// Return the size of the data type in bytes.</span>
|
||||
<span class="kt">int</span> <span class="n">get_itemsize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="nf">get_itemsize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="p">};</span>
|
||||
|
||||
<span class="p">}</span>
|
||||
@@ -116,7 +117,7 @@
|
||||
</div>
|
||||
<div class="section" id="constructors">
|
||||
<h2><a class="toc-backref" href="#id4">constructors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span>
|
||||
<span class="k">explicit</span> <span class="n">dtype</span><span class="p">(</span><span class="n">T</span> <span class="n">arg</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">align</span><span class="o">=</span><span class="nb">false</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -124,7 +125,7 @@
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">T</span></tt> must be either :</p>
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first"><code class="docutils literal notranslate"><span class="pre">T</span></code> must be either :</p>
|
||||
<ul class="simple">
|
||||
<li>a built-in C++ typename convertible to object</li>
|
||||
<li>a valid python object or convertible to object</li>
|
||||
@@ -140,14 +141,14 @@ to object / builtin C++ data type</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="k">static</span> <span class="n">dtype</span> <span class="n">get_builtin</span><span class="p">();</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="k">static</span> <span class="n">dtype</span> <span class="n">get_builtin</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The typename supplied, <tt class="docutils literal"><span class="pre">T</span></tt> must be a builtin C++ type also supported by numpy</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The typename supplied, <code class="docutils literal notranslate"><span class="pre">T</span></code> must be a builtin C++ type also supported by numpy</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Numpy dtype corresponding to builtin C++ type</td>
|
||||
</tr>
|
||||
@@ -156,7 +157,7 @@ to object / builtin C++ data type</p>
|
||||
</div>
|
||||
<div class="section" id="accessors">
|
||||
<h2><a class="toc-backref" href="#id5">accessors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">get_itemsize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="nf">get_itemsize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -170,7 +171,7 @@ to object / builtin C++ data type</p>
|
||||
</div>
|
||||
<div class="section" id="example-s">
|
||||
<h2><a class="toc-backref" href="#id6">Example(s)</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">double</span><span class="o">></span><span class="p">();</span>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -67,7 +68,7 @@
|
||||
<div class="section" id="multi-iter">
|
||||
<h1><a class="toc-backref" href="#id1">multi_iter</a></h1>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first">Table of Contents</p>
|
||||
<p class="topic-title">Table of Contents</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#multi-iter" id="id1">multi_iter</a><ul>
|
||||
<li><a class="reference internal" href="#synopsis" id="id2">synopsis</a></li>
|
||||
@@ -77,12 +78,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>A <tt class="docutils literal"><span class="pre">multi_iter</span></tt> is a Python object, intended to be used as an iterator It should generally only be used in loops.</p>
|
||||
<p>A <code class="docutils literal notranslate"><span class="pre">multi_iter</span></code> is a Python object, intended to be used as an iterator It should generally only be used in loops.</p>
|
||||
<blockquote>
|
||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ufunc.hpp></span></tt> contains the class definitions for <tt class="docutils literal"><span class="pre">multi_iter</span></tt></div></blockquote>
|
||||
<div><code class="docutils literal notranslate"><span class="pre"><boost/python/numpy/ufunc.hpp></span></code> contains the class definitions for <code class="docutils literal notranslate"><span class="pre">multi_iter</span></code></div></blockquote>
|
||||
<div class="section" id="synopsis">
|
||||
<h2><a class="toc-backref" href="#id2">synopsis</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">namespace</span> <span class="n">python</span>
|
||||
<span class="p">{</span>
|
||||
@@ -91,13 +92,13 @@
|
||||
|
||||
<span class="k">class</span> <span class="nc">multi_iter</span> <span class="o">:</span> <span class="k">public</span> <span class="n">object</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nl">public:</span>
|
||||
<span class="k">public</span><span class="o">:</span>
|
||||
<span class="kt">void</span> <span class="n">next</span><span class="p">();</span>
|
||||
<span class="kt">bool</span> <span class="n">not_done</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">bool</span> <span class="nf">not_done</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">char</span> <span class="o">*</span> <span class="nf">get_data</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="nf">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="nf">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="nf">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="p">};</span>
|
||||
|
||||
|
||||
@@ -113,7 +114,7 @@
|
||||
</div>
|
||||
<div class="section" id="constructors">
|
||||
<h2><a class="toc-backref" href="#id3">constructors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">);</span>
|
||||
<span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a2</span><span class="p">);</span>
|
||||
<span class="n">multi_iter</span> <span class="nf">make_multi_iter</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a1</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a2</span><span class="p">,</span> <span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">a3</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
@@ -129,7 +130,7 @@
|
||||
</div>
|
||||
<div class="section" id="accessors">
|
||||
<h2><a class="toc-backref" href="#id4">accessors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">next</span><span class="p">();</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">next</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -140,7 +141,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">bool</span> <span class="n">not_done</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">bool</span> <span class="nf">not_done</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -151,7 +152,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">char</span> <span class="o">*</span> <span class="nf">get_data</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -162,7 +163,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="k">const</span> <span class="nf">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -173,7 +174,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="nf">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -184,7 +185,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="nf">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -69,7 +70,7 @@
|
||||
<div class="section" id="ndarray">
|
||||
<h1><a class="toc-backref" href="#id2">ndarray</a></h1>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first">Table of Contents</p>
|
||||
<p class="topic-title">Table of Contents</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#ndarray" id="id2">ndarray</a><ul>
|
||||
<li><a class="reference internal" href="#synopsis" id="id3">synopsis</a></li>
|
||||
@@ -80,12 +81,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>A <a class="reference external" href="http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html">ndarray</a> is an N-dimensional array which contains items of the same type and size, where N is the number of dimensions and is specified in the form of a <tt class="docutils literal"><span class="pre">shape</span></tt> tuple. Optionally, the numpy <tt class="docutils literal"><span class="pre">dtype</span></tt> for the objects contained may also be specified.</p>
|
||||
<p>A <a class="reference external" href="http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html">ndarray</a> is an N-dimensional array which contains items of the same type and size, where N is the number of dimensions and is specified in the form of a <code class="docutils literal notranslate"><span class="pre">shape</span></code> tuple. Optionally, the numpy <code class="docutils literal notranslate"><span class="pre">dtype</span></code> for the objects contained may also be specified.</p>
|
||||
<blockquote>
|
||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ndarray.hpp></span></tt> contains the structures and methods necessary to move raw data between C++ and Python and create ndarrays from the data</div></blockquote>
|
||||
<div><code class="docutils literal notranslate"><span class="pre"><boost/python/numpy/ndarray.hpp></span></code> contains the structures and methods necessary to move raw data between C++ and Python and create ndarrays from the data</div></blockquote>
|
||||
<div class="section" id="synopsis">
|
||||
<h2><a class="toc-backref" href="#id3">synopsis</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">namespace</span> <span class="n">python</span>
|
||||
<span class="p">{</span>
|
||||
@@ -95,7 +96,7 @@
|
||||
<span class="k">class</span> <span class="nc">ndarray</span> <span class="o">:</span> <span class="k">public</span> <span class="n">object</span>
|
||||
<span class="p">{</span>
|
||||
|
||||
<span class="nl">public:</span>
|
||||
<span class="k">public</span><span class="o">:</span>
|
||||
|
||||
<span class="k">enum</span> <span class="n">bitflag</span>
|
||||
<span class="p">{</span>
|
||||
@@ -106,25 +107,25 @@
|
||||
<span class="n">UPDATE_ALL</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x4</span><span class="p">,</span> <span class="n">VARRAY</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x8</span><span class="p">,</span> <span class="n">ALL</span><span class="o">=</span><span class="mh">0x1</span><span class="o">|</span><span class="mh">0x2</span><span class="o">|</span><span class="mh">0x4</span><span class="o">|</span><span class="mh">0x8</span>
|
||||
<span class="p">};</span>
|
||||
|
||||
<span class="n">ndarray</span> <span class="n">view</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="n">astype</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="n">copy</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">strides</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">dtype</span> <span class="n">get_dtype</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="nf">view</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="nf">astype</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="nf">copy</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="nf">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="nf">strides</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">char</span> <span class="o">*</span> <span class="nf">get_data</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">dtype</span> <span class="nf">get_dtype</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">python</span><span class="o">::</span><span class="n">object</span> <span class="n">get_base</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">set_base</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">base</span><span class="p">);</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_strides</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="nf">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="nf">get_strides</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="k">const</span> <span class="nf">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
|
||||
<span class="n">bitflag</span> <span class="k">const</span> <span class="n">get_flags</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">bitflag</span> <span class="k">const</span> <span class="nf">get_flags</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
|
||||
<span class="n">ndarray</span> <span class="n">transpose</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="n">squeeze</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="n">reshape</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">object</span> <span class="n">scalarize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="nf">transpose</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="nf">squeeze</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">ndarray</span> <span class="nf">reshape</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="n">object</span> <span class="nf">scalarize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<span class="p">};</span>
|
||||
|
||||
<span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
@@ -157,7 +158,7 @@
|
||||
</div>
|
||||
<div class="section" id="constructors">
|
||||
<h2><a class="toc-backref" href="#id4">constructors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">view</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">view</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -168,7 +169,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">astype</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">astype</span><span class="p">(</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -179,7 +180,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">copy</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">copy</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -190,7 +191,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">transpose</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">transpose</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -201,7 +202,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">squeeze</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">squeeze</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -212,20 +213,20 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="n">reshape</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">reshape</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The new <tt class="docutils literal"><span class="pre">shape</span></tt> of the ndarray must be supplied as a tuple</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The new <code class="docutils literal notranslate"><span class="pre">shape</span></code> of the ndarray must be supplied as a tuple</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">An ndarray with the same data but reshaped to the <tt class="docutils literal"><span class="pre">shape</span></tt> supplied</td>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">An ndarray with the same data but reshaped to the <code class="docutils literal notranslate"><span class="pre">shape</span></code> supplied</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">object</span> <span class="n">scalarize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">object</span> <span class="nf">scalarize</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -236,7 +237,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
<span class="n">ndarray</span> <span class="nf">zeros</span><span class="p">(</span><span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -246,10 +247,10 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied as required :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> or the size of all dimensions, as a tuple</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">dtype</span></tt> of the data</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">nd</span></tt> size for a square shaped ndarray</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> Py_intptr_t</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">shape</span></code> or the size of all dimensions, as a tuple</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">dtype</span></code> of the data</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">nd</span></code> size for a square shaped ndarray</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">shape</span></code> Py_intptr_t</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -258,7 +259,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">empty</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">empty</span><span class="p">(</span><span class="n">tuple</span> <span class="k">const</span> <span class="o">&</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
<span class="n">ndarray</span> <span class="nf">empty</span><span class="p">(</span><span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -268,9 +269,9 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> or the size of all dimensions, as a tuple</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">dtype</span></tt> of the data</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> Py_intptr_t</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">shape</span></code> or the size of all dimensions, as a tuple</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">dtype</span></code> of the data</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">shape</span></code> Py_intptr_t</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -279,7 +280,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">array</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">array</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">);</span>
|
||||
<span class="n">ndarray</span> <span class="nf">array</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -291,7 +292,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Container</span><span class="o">></span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Container</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_data</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span><span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="n">Container</span> <span class="n">shape</span><span class="p">,</span><span class="n">Container</span> <span class="n">strides</span><span class="p">,</span><span class="n">python</span><span class="o">::</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">owner</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -301,23 +302,23 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">data</span></tt> which is a generic C++ data container</li>
|
||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">shape</span></tt> of the ndarray as Python object</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">strides</span></tt> of each dimension of the array as a Python object</li>
|
||||
<li>the <tt class="docutils literal"><span class="pre">owner</span></tt> of the data, in case it is not the ndarray itself</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">data</span></code> which is a generic C++ data container</li>
|
||||
<li>the dtype <code class="docutils literal notranslate"><span class="pre">dt</span></code> of the data</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">shape</span></code> of the ndarray as Python object</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">strides</span></code> of each dimension of the array as a Python object</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">owner</span></code> of the data, in case it is not the ndarray itself</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">ndarray with attributes and data supplied</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-odd field"><th class="field-name">Note:</th><td class="field-body"><p class="first last">The <tt class="docutils literal"><span class="pre">Container</span></tt> typename must be one that is convertible to a std::vector or python object type</p>
|
||||
<tr class="field-odd field"><th class="field-name">Note:</th><td class="field-body"><p class="first last">The <code class="docutils literal notranslate"><span class="pre">Container</span></code> typename must be one that is convertible to a std::vector or python object type</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span><span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -326,11 +327,11 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
||||
<li>minimum number of dimensions <tt class="docutils literal"><span class="pre">nd_min</span></tt> of the ndarray as Python object</li>
|
||||
<li>maximum number of dimensions <tt class="docutils literal"><span class="pre">nd_max</span></tt> of the ndarray as Python object</li>
|
||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">obj</span></code> Python object to convert to ndarray</li>
|
||||
<li>the dtype <code class="docutils literal notranslate"><span class="pre">dt</span></code> of the data</li>
|
||||
<li>minimum number of dimensions <code class="docutils literal notranslate"><span class="pre">nd_min</span></code> of the ndarray as Python object</li>
|
||||
<li>maximum number of dimensions <code class="docutils literal notranslate"><span class="pre">nd_max</span></code> of the ndarray as Python object</li>
|
||||
<li>optional <code class="docutils literal notranslate"><span class="pre">flags</span></code> bitflags</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -339,7 +340,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kr">inline</span> <span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -348,19 +349,19 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
||||
<li>number of dimensions <tt class="docutils literal"><span class="pre">nd</span></tt> of the ndarray as Python object</li>
|
||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">obj</span></code> Python object to convert to ndarray</li>
|
||||
<li>the dtype <code class="docutils literal notranslate"><span class="pre">dt</span></code> of the data</li>
|
||||
<li>number of dimensions <code class="docutils literal notranslate"><span class="pre">nd</span></code> of the ndarray as Python object</li>
|
||||
<li>optional <code class="docutils literal notranslate"><span class="pre">flags</span></code> bitflags</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray with dimensions <tt class="docutils literal"><span class="pre">nd</span></tt> x <tt class="docutils literal"><span class="pre">nd</span></tt> and suplied parameters</p>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray with dimensions <code class="docutils literal notranslate"><span class="pre">nd</span></code> x <code class="docutils literal notranslate"><span class="pre">nd</span></code> and suplied parameters</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">)</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">dtype</span> <span class="k">const</span> <span class="o">&</span> <span class="n">dt</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -369,9 +370,9 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">obj</span></code> Python object to convert to ndarray</li>
|
||||
<li>the dtype <code class="docutils literal notranslate"><span class="pre">dt</span></code> of the data</li>
|
||||
<li>optional <code class="docutils literal notranslate"><span class="pre">flags</span></code> bitflags</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -380,7 +381,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_min</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd_max</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -389,10 +390,10 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
||||
<li>minimum number of dimensions <tt class="docutils literal"><span class="pre">nd_min</span></tt> of the ndarray as Python object</li>
|
||||
<li>maximum number of dimensions <tt class="docutils literal"><span class="pre">nd_max</span></tt> of the ndarray as Python object</li>
|
||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">obj</span></code> Python object to convert to ndarray</li>
|
||||
<li>minimum number of dimensions <code class="docutils literal notranslate"><span class="pre">nd_min</span></code> of the ndarray as Python object</li>
|
||||
<li>maximum number of dimensions <code class="docutils literal notranslate"><span class="pre">nd_max</span></code> of the ndarray as Python object</li>
|
||||
<li>optional <code class="docutils literal notranslate"><span class="pre">flags</span></code> bitflags</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -404,7 +405,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kr">inline</span> <span class="n">ndarray</span> <span class="nf">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">int</span> <span class="n">nd</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -413,19 +414,19 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
||||
<li>the dtype <tt class="docutils literal"><span class="pre">dt</span></tt> of the data</li>
|
||||
<li>number of dimensions <tt class="docutils literal"><span class="pre">nd</span></tt> of the ndarray as Python object</li>
|
||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">obj</span></code> Python object to convert to ndarray</li>
|
||||
<li>the dtype <code class="docutils literal notranslate"><span class="pre">dt</span></code> of the data</li>
|
||||
<li>number of dimensions <code class="docutils literal notranslate"><span class="pre">nd</span></code> of the ndarray as Python object</li>
|
||||
<li>optional <code class="docutils literal notranslate"><span class="pre">flags</span></code> bitflags</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray of <tt class="docutils literal"><span class="pre">nd</span></tt> x <tt class="docutils literal"><span class="pre">nd</span></tt> dimensions constructed from the supplied object</p>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">ndarray of <code class="docutils literal notranslate"><span class="pre">nd</span></code> x <code class="docutils literal notranslate"><span class="pre">nd</span></code> dimensions constructed from the supplied object</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">)</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kr">inline</span> <span class="n">ndarray</span> <span class="n">from_object</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">obj</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">flags</span><span class="o">=</span><span class="n">ndarray</span><span class="o">::</span><span class="n">NONE</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -434,8 +435,8 @@
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body"><p class="first">The following parameters must be supplied :</p>
|
||||
<ul class="simple">
|
||||
<li>the <tt class="docutils literal"><span class="pre">obj</span></tt> Python object to convert to ndarray</li>
|
||||
<li>optional <tt class="docutils literal"><span class="pre">flags</span></tt> bitflags</li>
|
||||
<li>the <code class="docutils literal notranslate"><span class="pre">obj</span></code> Python object to convert to ndarray</li>
|
||||
<li>optional <code class="docutils literal notranslate"><span class="pre">flags</span></code> bitflags</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -447,7 +448,7 @@
|
||||
</div>
|
||||
<div class="section" id="accessors">
|
||||
<h2><a class="toc-backref" href="#id5">accessors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="k">const</span> <span class="nf">shape</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -458,7 +459,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">strides</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="k">const</span> <span class="nf">strides</span><span class="p">(</span><span class="kt">int</span> <span class="n">n</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -469,53 +470,53 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">char</span> <span class="o">*</span> <span class="n">get_data</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">char</span> <span class="o">*</span> <span class="nf">get_data</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array’s raw data pointer as a char</td>
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array’s raw data pointer as a char</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">This returns char so stride math works properly on it.User will have to reinterpret_cast it.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">dtype</span> <span class="n">get_dtype</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">dtype</span> <span class="nf">get_dtype</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array’s data-type descriptor object (dtype)</td>
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array’s data-type descriptor object (dtype)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">object</span> <span class="n">get_base</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">object</span> <span class="nf">get_base</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Object that owns the array’s data, or None if the array owns its own data.</td>
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Object that owns the array’s data, or None if the array owns its own data.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">set_base</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">base</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">set_base</span><span class="p">(</span><span class="n">object</span> <span class="k">const</span> <span class="o">&</span> <span class="n">base</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Set the object that owns the array’s data. Exercise caution while using this</td>
|
||||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Set the object that owns the array’s data. Exercise caution while using this</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="nf">get_shape</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -526,7 +527,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="n">get_strides</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">Py_intptr_t</span> <span class="k">const</span> <span class="o">*</span> <span class="nf">get_strides</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -537,7 +538,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="k">const</span> <span class="n">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="k">const</span> <span class="nf">get_nd</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -548,7 +549,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">bitflag</span> <span class="k">const</span> <span class="n">get_flags</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">bitflag</span> <span class="k">const</span> <span class="nf">get_flags</span><span class="p">()</span> <span class="k">const</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -559,7 +560,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">|</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">)</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kr">inline</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">|</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -570,7 +571,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kr">inline</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">&</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">)</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kr">inline</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="k">operator</span><span class="o">&</span><span class="p">(</span><span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">a</span><span class="p">,</span> <span class="n">ndarray</span><span class="o">::</span><span class="n">bitflag</span> <span class="n">b</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -584,7 +585,7 @@
|
||||
</div>
|
||||
<div class="section" id="example-s">
|
||||
<h2><a class="toc-backref" href="#id6">Example(s)</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">tu</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="sc">'a'</span><span class="p">,</span><span class="sc">'b'</span><span class="p">,</span><span class="sc">'c'</span><span class="p">)</span> <span class="p">;</span>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -69,7 +70,7 @@
|
||||
<div class="section" id="unary-ufunc">
|
||||
<h1><a class="toc-backref" href="#id1">unary_ufunc</a></h1>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first">Table of Contents</p>
|
||||
<p class="topic-title">Table of Contents</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#unary-ufunc" id="id1">unary_ufunc</a><ul>
|
||||
<li><a class="reference internal" href="#synopsis" id="id2">synopsis</a></li>
|
||||
@@ -80,12 +81,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>A <tt class="docutils literal"><span class="pre">unary_ufunc</span></tt> is a struct used as an intermediate step to broadcast a single argument so that a C++ function can be converted to a ufunc like function</p>
|
||||
<p>A <code class="docutils literal notranslate"><span class="pre">unary_ufunc</span></code> is a struct used as an intermediate step to broadcast a single argument so that a C++ function can be converted to a ufunc like function</p>
|
||||
<blockquote>
|
||||
<div><tt class="docutils literal"><span class="pre"><boost/python/numpy/ufunc.hpp></span></tt> contains the <tt class="docutils literal"><span class="pre">unary_ufunc</span></tt> structure definitions</div></blockquote>
|
||||
<div><code class="docutils literal notranslate"><span class="pre"><boost/python/numpy/ufunc.hpp></span></code> contains the <code class="docutils literal notranslate"><span class="pre">unary_ufunc</span></code> structure definitions</div></blockquote>
|
||||
<div class="section" id="synopsis">
|
||||
<h2><a class="toc-backref" href="#id2">synopsis</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">boost</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">namespace</span> <span class="n">python</span>
|
||||
<span class="p">{</span>
|
||||
@@ -113,7 +114,7 @@
|
||||
</div>
|
||||
<div class="section" id="constructors">
|
||||
<h2><a class="toc-backref" href="#id3">constructors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">example_unary_ufunc</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">example_unary_ufunc</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">typedef</span> <span class="n">any_valid_type</span> <span class="n">argument_type</span><span class="p">;</span>
|
||||
<span class="k">typedef</span> <span class="n">any_valid_type</span> <span class="n">result_type</span><span class="p">;</span>
|
||||
@@ -124,16 +125,16 @@
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The <tt class="docutils literal"><span class="pre">any_valid</span></tt> type must be defined using typedef as a valid C++ type in order to use the struct methods correctly</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requirements:</th><td class="field-body">The <code class="docutils literal notranslate"><span class="pre">any_valid</span></code> type must be defined using typedef as a valid C++ type in order to use the struct methods correctly</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">The struct must be exposed as a Python class, and an instance of the class must be created to use the <tt class="docutils literal"><span class="pre">call</span></tt> method corresponding to the <tt class="docutils literal"><span class="pre">__call__</span></tt> attribute of the Python object</td>
|
||||
<tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">The struct must be exposed as a Python class, and an instance of the class must be created to use the <code class="docutils literal notranslate"><span class="pre">call</span></code> method corresponding to the <code class="docutils literal notranslate"><span class="pre">__call__</span></code> attribute of the Python object</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="accessors">
|
||||
<h2><a class="toc-backref" href="#id4">accessors</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="p">,</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TArgument</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">argument_type</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
||||
<span class="k">static</span> <span class="n">object</span> <span class="n">call</span><span class="p">(</span><span class="n">TUnaryFunctor</span> <span class="o">&</span> <span class="n">self</span><span class="p">,</span>
|
||||
@@ -145,13 +146,13 @@
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TUnaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <code class="docutils literal notranslate"><span class="pre">TUnaryFunctor</span></code> and optionally <code class="docutils literal notranslate"><span class="pre">TArgument</span></code> for argument type and <code class="docutils literal notranslate"><span class="pre">TResult</span></code> for result type</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Effects:</th><td class="field-body">Passes a Python object to the underlying C++ functor after broadcasting its arguments</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="p">,</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TArgument</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">argument_type</span><span class="p">,</span>
|
||||
<span class="k">typename</span> <span class="n">TResult</span><span class="o">=</span><span class="k">typename</span> <span class="n">TUnaryFunctor</span><span class="o">::</span><span class="n">result_type</span><span class="o">></span>
|
||||
<span class="k">static</span> <span class="n">object</span> <span class="n">make</span><span class="p">();</span>
|
||||
@@ -161,7 +162,7 @@
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <tt class="docutils literal"><span class="pre">TUnaryFunctor</span></tt> and optionally <tt class="docutils literal"><span class="pre">TArgument</span></tt> for argument type and <tt class="docutils literal"><span class="pre">TResult</span></tt> for result type</td>
|
||||
<tr class="field-odd field"><th class="field-name">Requires:</th><td class="field-body">Typenames <code class="docutils literal notranslate"><span class="pre">TUnaryFunctor</span></code> and optionally <code class="docutils literal notranslate"><span class="pre">TArgument</span></code> for argument type and <code class="docutils literal notranslate"><span class="pre">TResult</span></code> for result type</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A Python function object to call the overloaded () operator in the struct (in typical usage)</td>
|
||||
</tr>
|
||||
@@ -170,14 +171,14 @@
|
||||
</div>
|
||||
<div class="section" id="example-s">
|
||||
<h2><a class="toc-backref" href="#id5">Example(s)</a></h2>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
|
||||
<span class="k">struct</span> <span class="n">UnarySquare</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">argument_type</span><span class="p">;</span>
|
||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">result_type</span><span class="p">;</span>
|
||||
<span class="kt">double</span> <span class="k">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">r</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">r</span> <span class="o">*</span> <span class="n">r</span><span class="p">;}</span>
|
||||
<span class="kt">double</span> <span class="nf">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">r</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">r</span> <span class="o">*</span> <span class="n">r</span><span class="p">;}</span>
|
||||
<span class="p">};</span>
|
||||
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">UnarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"UnarySquare"</span><span class="p">).</span><span class="n">def</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">unary_ufunc</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">>::</span><span class="n">make</span><span class="p">());</span>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="_static/searchtools.js"></script>
|
||||
<script type="text/javascript" src="_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="#" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="index.html" />
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -70,8 +71,8 @@
|
||||
<h1>How to use dtypes</h1>
|
||||
<p>Here is a brief tutorial to show how to create ndarrays with built-in python data types, and extract the types and values of member variables</p>
|
||||
<p>Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
||||
<span class="cp">#include <iostream></span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><boost/python/numpy.hpp></span><span class="cp"></span>
|
||||
<span class="cp">#include</span> <span class="cpf"><iostream></span><span class="cp"></span>
|
||||
|
||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
@@ -84,35 +85,35 @@
|
||||
</div>
|
||||
<p>Next, we create the shape and dtype. We use the get_builtin method to get the numpy dtype corresponding to the builtin C++ dtype
|
||||
Here, we will create a 3x3 array passing a tuple with (3,3) for the size, and double as the data type</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">double</span><span class="o">></span><span class="p">();</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Finally, we can print the array using the extract method in the python namespace.
|
||||
Here, we first convert the variable into a string, and then extract it as a C++ character array from the python string using the <char const * > template</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Original array:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Original array:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We can also print the dtypes of the data members of the ndarray by using the get_dtype method for the ndarray</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Datatype is:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">get_dtype</span><span class="p">()))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Datatype is:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">get_dtype</span><span class="p">()))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We can also create custom dtypes and build ndarrays with the custom dtypes</p>
|
||||
<p>We use the dtype constructor to create a custom dtype. This constructor takes a list as an argument.</p>
|
||||
<p>The list should contain one or more tuples of the format (variable name, variable type)</p>
|
||||
<p>So first create a tuple with a variable name and its dtype, double, to create a custom dtype</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">for_custom_dtype</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="s">"ha"</span><span class="p">,</span><span class="n">dtype</span><span class="p">)</span> <span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">for_custom_dtype</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="s">"ha"</span><span class="p">,</span><span class="n">dtype</span><span class="p">)</span> <span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Next, create a list, and add this tuple to the list. Then use the list to create the custom dtype</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">list_for_dtype</span> <span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">list_for_dtype</span> <span class="p">;</span>
|
||||
<span class="n">list_for_dtype</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">for_custom_dtype</span><span class="p">)</span> <span class="p">;</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">custom_dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="p">(</span><span class="n">list_for_dtype</span><span class="p">)</span> <span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We are now ready to create an ndarray with dimensions specified by *shape* and of custom dtpye</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">new_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span><span class="n">custom_dtype</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span> <span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">new_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span><span class="n">custom_dtype</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -71,8 +72,8 @@
|
||||
<p>One of the advantages of the ndarray wrapper is that the same data can be used in both Python and C++ and changes can be made to reflect at both ends.
|
||||
The from_data method makes this possible.</p>
|
||||
<p>Like before, first get the necessary headers, setup the namespaces and initialize the Python runtime and numpy module:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
||||
<span class="cp">#include <iostream></span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><boost/python/numpy.hpp></span><span class="cp"></span>
|
||||
<span class="cp">#include</span> <span class="cpf"><iostream></span><span class="cp"></span>
|
||||
|
||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
@@ -84,7 +85,7 @@ The from_data method makes this possible.</p>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Create an array in C++ , and pass the pointer to it to the from_data method to create an ndarray:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">arr</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">};</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="n">arr</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">};</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">py_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">(),</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">int</span><span class="p">)),</span>
|
||||
@@ -92,7 +93,7 @@ The from_data method makes this possible.</p>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Print the source C++ array, as well as the ndarray, to check if they are the same:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"C++ array :"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"C++ array :"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">j</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="n">j</span><span class="o"><</span><span class="mi">4</span><span class="p">;</span><span class="n">j</span><span class="o">++</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="n">arr</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o"><<</span> <span class="sc">' '</span><span class="p">;</span>
|
||||
@@ -102,7 +103,7 @@ The from_data method makes this possible.</p>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now, change an element in the Python ndarray, and check if the value changed correspondingly in the source C++ array:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">py_array</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mi">5</span> <span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">py_array</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mi">5</span> <span class="p">;</span>
|
||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Is the change reflected in the C++ array used to create the ndarray ? "</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">j</span> <span class="o"><</span> <span class="mi">5</span><span class="p">;</span> <span class="n">j</span><span class="o">++</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
@@ -111,7 +112,7 @@ The from_data method makes this possible.</p>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Next, change an element of the source C++ array and see if it is reflected in the Python ndarray:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">arr</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span> <span class="n">arr</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span><span class="p">;</span>
|
||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<span class="o"><<</span> <span class="s">"Is the change reflected in the Python ndarray ?"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">py_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -72,8 +73,8 @@
|
||||
ndarrays can also be created from arbitrary python sequences as well as from data and dtypes.</p>
|
||||
<p>This tutorial will introduce you to some of the ways in which you can create ndarrays. The methods covered here include creating ndarrays from arbitrary Python sequences, as well as from C++ containers, using both unit and non-unit strides</p>
|
||||
<p>First, as before, initialise the necessary namepaces and runtimes</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
||||
<span class="cp">#include <iostream></span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><boost/python/numpy.hpp></span><span class="cp"></span>
|
||||
<span class="cp">#include</span> <span class="cpf"><iostream></span><span class="cp"></span>
|
||||
|
||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
@@ -84,66 +85,66 @@ ndarrays can also be created from arbitrary python sequences as well as from dat
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Let’s now create an ndarray from a simple tuple. We first create a tuple object, and then pass it to the array method, to generate the necessary tuple</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">tu</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="sc">'a'</span><span class="p">,</span><span class="sc">'b'</span><span class="p">,</span><span class="sc">'c'</span><span class="p">);</span>
|
||||
<p>Let’s now create an ndarray from a simple tuple. We first create a tuple object, and then pass it to the array method, to generate the necessary tuple</p>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">tu</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="sc">'a'</span><span class="p">,</span><span class="sc">'b'</span><span class="p">,</span><span class="sc">'c'</span><span class="p">);</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_tuple</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span><span class="p">(</span><span class="n">tu</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Let’s now try the same with a list. We create an empty list, add an element using the append method, and as before, call the array method</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">l</span><span class="p">;</span>
|
||||
<p>Let’s now try the same with a list. We create an empty list, add an element using the append method, and as before, call the array method</p>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">l</span><span class="p">;</span>
|
||||
<span class="n">l</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="sc">'a'</span><span class="p">);</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_list</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span> <span class="p">(</span><span class="n">l</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Optionally, we can also specify a dtype for the array</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">();</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">();</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">example_list1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">array</span> <span class="p">(</span><span class="n">l</span><span class="p">,</span><span class="n">dt</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We can also create an array by supplying data arrays and a few other parameters.</p>
|
||||
<p>First,create an integer array</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">data</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">};</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="n">data</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">};</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Create a shape, and strides, needed by the function</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">stride</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">int</span><span class="p">));</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Here, shape is (4,) , and the stride is <cite>sizeof(int)`</cite>.
|
||||
A stride is the number of bytes that must be traveled to get to the next desired element while constructing the ndarray.</p>
|
||||
<p>The function also needs an owner, to keep track of the data array passed. Passing none is dangerous</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">own</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">own</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The from_data function takes the data array, datatype,shape,stride and owner as arguments and returns an ndarray</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">data_ex1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">dt</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span><span class="n">stride</span><span class="p">,</span><span class="n">own</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">data_ex1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">dt</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span><span class="n">stride</span><span class="p">,</span><span class="n">own</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now let’s print the ndarray we created</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Single dimensional array ::"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<p>Now let’s print the ndarray we created</p>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Single dimensional array ::"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">data_ex</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Let’s make it a little more interesting. Lets make an 3x2 ndarray from a multi-dimensional array using non-unit strides</p>
|
||||
<p>Let’s make it a little more interesting. Lets make an 3x2 ndarray from a multi-dimensional array using non-unit strides</p>
|
||||
<p>First lets create a 3x4 array of 8-bit integers</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">uint8_t</span> <span class="n">mul_data</span><span class="p">[][</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="p">{{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">},{</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">8</span><span class="p">},{</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">7</span><span class="p">}};</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">uint8_t</span> <span class="n">mul_data</span><span class="p">[][</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="p">{{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">},{</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">8</span><span class="p">},{</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">7</span><span class="p">}};</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now let’s create an array of 3x2 elements, picking the first and third elements from each row . For that, the shape will be 3x2.
|
||||
<p>Now let’s create an array of 3x2 elements, picking the first and third elements from each row . For that, the shape will be 3x2.
|
||||
The strides will be 4x2 i.e. 4 bytes to go to the next desired row, and 2 bytes to go to the next desired column</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">);</span>
|
||||
<span class="n">stride</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">uint8_t</span><span class="p">)</span><span class="o">*</span><span class="mi">2</span><span class="p">,</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">uint8_t</span><span class="p">));</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Get the numpy dtype for the built-in 8-bit integer data type</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">uint8_t</span><span class="o">></span><span class="p">();</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dt1</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">uint8_t</span><span class="o">></span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now lets first create and print out the ndarray as is.
|
||||
Notice how we can pass the shape and strides in the function directly, as well as the owner. The last part can be done because we don’t have any use to
|
||||
manipulate the “owner” object</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span> <span class="n">dt1</span><span class="p">,</span>
|
||||
Notice how we can pass the shape and strides in the function directly, as well as the owner. The last part can be done because we don’t have any use to
|
||||
manipulate the “owner” object</p>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span> <span class="n">dt1</span><span class="p">,</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">),</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
||||
@@ -152,7 +153,7 @@ manipulate the “owner” object</p>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now create the new ndarray using the shape and strides and print out the array we created using non-unit strides</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span> <span class="n">dt1</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span> <span class="n">stride</span><span class="p">,</span> <span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span> <span class="n">mul_data_ex</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">mul_data</span><span class="p">,</span> <span class="n">dt1</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span> <span class="n">stride</span><span class="p">,</span> <span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
||||
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Selective multidimensional array :: "</span><span class="o"><<</span><span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">mul_data_ex</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
@@ -160,7 +161,7 @@ manipulate the “owner” object</p>
|
||||
</div>
|
||||
<div class="admonition note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p class="last">The from_data method will throw <tt class="docutils literal"><span class="pre">error_already_set</span></tt> if the number of elements dictated by the shape and the corresponding strides don’t match.</p>
|
||||
<p class="last">The from_data method will throw <code class="docutils literal notranslate"><span class="pre">error_already_set</span></code> if the number of elements dictated by the shape and the corresponding strides don’t match.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -68,34 +69,34 @@
|
||||
|
||||
<div class="section" id="a-simple-tutorial-on-arrays">
|
||||
<h1>A simple tutorial on Arrays</h1>
|
||||
<p>Let’s start with a simple tutorial to create and modify arrays.</p>
|
||||
<p>Let’s start with a simple tutorial to create and modify arrays.</p>
|
||||
<p>Get the necessary headers for numpy components and set up necessary namespaces:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
||||
<span class="cp">#include <iostream></span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><boost/python/numpy.hpp></span><span class="cp"></span>
|
||||
<span class="cp">#include</span> <span class="cpf"><iostream></span><span class="cp"></span>
|
||||
|
||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Initialise the Python runtime, and the numpy module. Failure to call these results in segmentation errors:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">Py_Initialize</span><span class="p">();</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Zero filled n-dimensional arrays can be created using the shape and data-type of the array as a parameter. Here, the shape is 3x3 and the datatype is the built-in float type:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">tuple</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">dtype</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">float</span><span class="o">></span><span class="p">();</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>You can also create an empty array like this</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">empty</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span><span class="n">dtype</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">empty</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span><span class="n">dtype</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Print the original and reshaped array. The array a which is a list is first converted to a string, and each value in the list is extracted using extract< >:</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Original array:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Original array:</span><span class="se">\n</span><span class="s">"</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
|
||||
<span class="c1">// Reshape the array into a 1D array</span>
|
||||
<span class="n">a</span> <span class="o">=</span> <span class="n">a</span><span class="p">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">9</span><span class="p">));</span>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="top" title="Boost.Python NumPy extension 1.0 documentation" href="../index.html" />
|
||||
@@ -71,20 +72,20 @@
|
||||
<p>Ufuncs or universal functions operate on ndarrays element by element, and support array broadcasting, type casting, and other features.</p>
|
||||
<p>Lets try and see how we can use the binary and unary ufunc methods</p>
|
||||
<p>After the neccessary includes</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <boost/python/numpy.hpp></span>
|
||||
<span class="cp">#include <iostream></span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><boost/python/numpy.hpp></span><span class="cp"></span>
|
||||
<span class="cp">#include</span> <span class="cpf"><iostream></span><span class="cp"></span>
|
||||
|
||||
<span class="k">namespace</span> <span class="n">p</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span>
|
||||
<span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now we create the structs necessary to implement the ufuncs. The typedefs <em>must</em> be made as the ufunc generators take these typedefs as inputs and return an error otherwise</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">UnarySquare</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">UnarySquare</span>
|
||||
<span class="p">{</span>
|
||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">argument_type</span><span class="p">;</span>
|
||||
<span class="k">typedef</span> <span class="kt">double</span> <span class="n">result_type</span><span class="p">;</span>
|
||||
|
||||
<span class="kt">double</span> <span class="k">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">r</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">r</span> <span class="o">*</span> <span class="n">r</span><span class="p">;}</span>
|
||||
<span class="kt">double</span> <span class="nf">operator</span><span class="p">()(</span><span class="kt">double</span> <span class="n">r</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">r</span> <span class="o">*</span> <span class="n">r</span><span class="p">;}</span>
|
||||
<span class="p">};</span>
|
||||
|
||||
<span class="k">struct</span> <span class="n">BinarySquare</span>
|
||||
@@ -98,87 +99,87 @@
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Initialise the Python runtime and the numpy module</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">Py_Initialize</span><span class="p">();</span>
|
||||
<span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now expose the struct UnarySquare to Python as a class, and let ud be the class object.</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">UnarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"UnarySquare"</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">UnarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"UnarySquare"</span><span class="p">);</span>
|
||||
<span class="n">ud</span><span class="p">.</span><span class="n">def</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">unary_ufunc</span><span class="o"><</span><span class="n">UnarySquare</span><span class="o">>::</span><span class="n">make</span><span class="p">());</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Let inst be an instance of the class ud</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Use the “__call__” method to call the overloaded () operator and print the value</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of unary scalar 1.0 is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="mf">1.0</span><span class="p">)))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<p>Use the “__call__” method to call the overloaded () operator and print the value</p>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of unary scalar 1.0 is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="mf">1.0</span><span class="p">)))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Create an array in C++</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">arr</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">}</span> <span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="n">arr</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">}</span> <span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>..and use it to create the ndarray in Python</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">demo_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">(),</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">demo_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">::</span><span class="n">from_data</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o"><</span><span class="kt">int</span><span class="o">></span><span class="p">(),</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span>
|
||||
<span class="n">p</span><span class="o">::</span><span class="n">object</span><span class="p">());</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Print out the demo array</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Demo array is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">demo_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Demo array is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">demo_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Call the “__call__” method to perform the operation and assign the value to result_array</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">demo_array</span><span class="p">);</span>
|
||||
<p>Call the “__call__” method to perform the operation and assign the value to result_array</p>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">object</span> <span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">demo_array</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Print the resultant array</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of demo array is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of demo array is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Lets try the same with a list</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">li</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">p</span><span class="o">::</span><span class="n">list</span> <span class="n">li</span><span class="p">;</span>
|
||||
<span class="n">li</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span>
|
||||
<span class="n">li</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="mi">7</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Print out the demo list</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Demo list is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">li</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Demo list is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">li</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Call the ufunc for the list</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">li</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">li</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>And print the list out</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of demo list is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of demo list is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now lets try Binary ufuncs. Again, expose the struct BinarySquare to Python as a class, and let ud be the class object</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">BinarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">BinarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"BinarySquare"</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">ud</span> <span class="o">=</span> <span class="n">p</span><span class="o">::</span><span class="n">class_</span><span class="o"><</span><span class="n">BinarySquare</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o"><</span><span class="n">BinarySquare</span><span class="o">></span> <span class="o">></span><span class="p">(</span><span class="s">"BinarySquare"</span><span class="p">);</span>
|
||||
<span class="n">ud</span><span class="p">.</span><span class="n">def</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">,</span> <span class="n">np</span><span class="o">::</span><span class="n">binary_ufunc</span><span class="o"><</span><span class="n">BinarySquare</span><span class="o">>::</span><span class="n">make</span><span class="p">());</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>And initialise ud</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">inst</span> <span class="o">=</span> <span class="n">ud</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Print the two input lists</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"The two input list for binary ufunc are "</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"The two input list for binary ufunc are "</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">demo_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span>
|
||||
<span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">demo_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Call the binary ufunc taking demo_array as both inputs</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre><span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">demo_array</span><span class="p">,</span><span class="n">demo_array</span><span class="p">);</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">result_array</span> <span class="o">=</span> <span class="n">inst</span><span class="p">.</span><span class="n">attr</span><span class="p">(</span><span class="s">"__call__"</span><span class="p">)(</span><span class="n">demo_array</span><span class="p">,</span><span class="n">demo_array</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>And print the output</p>
|
||||
<div class="highlight-c++"><div class="highlight"><pre> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of list with binary ufunc is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Square of list with binary ufunc is "</span> <span class="o"><<</span> <span class="n">p</span><span class="o">::</span><span class="n">extract</span><span class="o"><</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*></span><span class="p">(</span><span class="n">p</span><span class="o">::</span><span class="n">str</span><span class="p">(</span><span class="n">result_array</span><span class="p">))</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 1. Concepts</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="prev" href="index.html" title="Boost.Python Reference Manual">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Dereferenceable</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../concepts.html" title="Chapter 1. Concepts">
|
||||
<link rel="prev" href="../concepts.html" title="Chapter 1. Concepts">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Extractor</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../concepts.html" title="Chapter 1. Concepts">
|
||||
<link rel="prev" href="dereferenceable.html" title="Dereferenceable">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>HolderGenerator</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../concepts.html" title="Chapter 1. Concepts">
|
||||
<link rel="prev" href="extractor.html" title="Extractor">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>ObjectWrapper</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../concepts.html" title="Chapter 1. Concepts">
|
||||
<link rel="prev" href="resultconverter.html" title="ResultConverter">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>ResultConverter</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../concepts.html" title="Chapter 1. Concepts">
|
||||
<link rel="prev" href="holdergenerator.html" title="HolderGenerator">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 6. Embedding</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="prev" href="to_from_python_type_conversion/boost_python_register_ptr_to_pyt.html" title="boost/python/register_ptr_to_python.hpp">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>boost/python/import.hpp</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../embedding.html" title="Chapter 6. Embedding">
|
||||
<link rel="prev" href="../embedding.html" title="Chapter 6. Embedding">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 4. Function Invocation and Creation</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="prev" href="object_wrappers/boost_python_tuple_hpp.html" title="boost/python/tuple.hpp">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>boost/python/call.hpp</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../function_invocation_and_creation.html" title="Chapter 4. Function Invocation and Creation">
|
||||
<link rel="prev" href="../function_invocation_and_creation.html" title="Chapter 4. Function Invocation and Creation">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>boost/python/call_method.hpp</title>
|
||||
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
||||
<link rel="up" href="../function_invocation_and_creation.html" title="Chapter 4. Function Invocation and Creation">
|
||||
<link rel="prev" href="boost_python_call_hpp.html" title="boost/python/call.hpp">
|
||||
@@ -81,6 +81,8 @@
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="keyword">class</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">call_method</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cstring</span><span class="special">></span>
|
||||
|
||||
@@ -89,7 +91,7 @@
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">virtual</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">class_name</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="string">"Base"</span><span class="special">;</span> <span class="special">}</span>
|
||||
<span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">Base</span><span class="special">();</span>
|
||||
<span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">Base</span><span class="special">()</span> <span class="special">{};</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">bool</span> <span class="identifier">is_base</span><span class="special">(</span><span class="identifier">Base</span><span class="special">*</span> <span class="identifier">b</span><span class="special">)</span>
|
||||
@@ -117,7 +119,7 @@
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"is_base"</span><span class="special">,</span> <span class="identifier">is_base</span><span class="special">);</span>
|
||||
|
||||
<span class="identifier">class_</span><span class="special"><</span><span class="identifier">Base</span><span class="special">,</span><span class="identifier">Base_callback</span><span class="special">,</span> <span class="identifier">noncopyable</span><span class="special">>(</span><span class="string">"Base"</span><span class="special">)</span>
|
||||
<span class="identifier">class_</span><span class="special"><</span><span class="identifier">Base</span><span class="special">,</span><span class="identifier">Base_callback</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span><span class="special">>(</span><span class="string">"Base"</span><span class="special">)</span>
|
||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"class_name"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">Base_callback</span><span class="special">::</span><span class="identifier">Base_name</span><span class="special">)</span>
|
||||
<span class="special">;</span>
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user