├── .gitignore
├── .gitmodules
├── .travis.yml
├── LICENSE.txt
├── MANIFEST.in
├── README.rst
├── doc
├── Makefile
├── release
│ ├── 0.15.0-notes.rst
│ ├── 0.16.0-notes.rst
│ └── 0.17.0-notes.rst
├── source
│ ├── _static
│ │ ├── scipy_fallback.css
│ │ └── scipyshiny_small.png
│ ├── _templates
│ │ ├── autosummary
│ │ │ └── class.rst
│ │ ├── indexsidebar.html
│ │ └── layout.html
│ ├── api_reference.rst
│ ├── conf.py
│ ├── index.rst
│ ├── release.0.15.0.rst
│ ├── release.0.16.0.rst
│ ├── release.0.17.0.rst
│ ├── release.rst
│ └── tutorial.rst
├── tutorial.txt
└── tutorial_original.html
├── examples
├── array3d.py
├── binary_search.py
├── cast_copy_transpose.py
├── dict_sort.py
├── fibonacci.py
├── functional.py
├── increment_example.py
├── md5_speed.py
├── object.py
├── print_example.py
├── py_none.py
├── ramp.c
├── ramp.py
├── ramp2.py
├── support_code_example.py
├── swig2_example.py
├── swig2_ext.h
├── swig2_ext.i
├── tuple_return.py
├── vq.py
├── vtk_example.py
├── wx_example.py
└── wx_speed.py
├── runtests.py
├── setup.py
├── tox.ini
└── weave
├── __init__.py
├── _dumb_shelve.py
├── _dumbdbm_patched.py
├── accelerate_tools.py
├── ast_tools.py
├── base_info.py
├── base_spec.py
├── blitz
└── blitz
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── README
│ ├── applics.h
│ ├── array-impl.h
│ ├── array-old.h
│ ├── array.h
│ ├── array
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── asexpr.h
│ ├── bops.cc
│ ├── cartesian.h
│ ├── cgsolve.h
│ ├── complex.cc
│ ├── convolve.cc
│ ├── convolve.h
│ ├── cycle.cc
│ ├── domain.h
│ ├── et.h
│ ├── eval.cc
│ ├── expr.h
│ ├── fastiter.h
│ ├── funcs.h
│ ├── functorExpr.h
│ ├── geometry.h
│ ├── indirect.h
│ ├── interlace.cc
│ ├── io.cc
│ ├── iter.h
│ ├── map.h
│ ├── methods.cc
│ ├── misc.cc
│ ├── multi.h
│ ├── newbops.cc
│ ├── newet-macros.h
│ ├── newet.h
│ ├── ops.cc
│ ├── ops.h
│ ├── reduce.cc
│ ├── reduce.h
│ ├── resize.cc
│ ├── shape.h
│ ├── slice.h
│ ├── slicing.cc
│ ├── stencil-et.h
│ ├── stencil.cc
│ ├── stencil.h
│ ├── stencilops.h
│ ├── stencils.cc
│ ├── stencils.h
│ ├── storage.h
│ ├── uops.cc
│ ├── where.h
│ └── zip.h
│ ├── bench.cc
│ ├── bench.h
│ ├── benchext.cc
│ ├── benchext.h
│ ├── blitz.h
│ ├── bzconfig.h
│ ├── bzdebug.h
│ ├── compiler.h
│ ├── config.h.in
│ ├── etbase.h
│ ├── extremum.h
│ ├── funcs.h
│ ├── generate
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── arroperands.h
│ ├── arroptuple.h
│ ├── bzfstream.h
│ ├── genarrbops.cpp
│ ├── genarruops.cpp
│ ├── genmatbops.cpp
│ ├── genmathfunc.cpp
│ ├── genmatuops.cpp
│ ├── genpromote.cpp
│ ├── genvecbfn.cpp
│ ├── genvecbops.cpp
│ ├── genvecuops.cpp
│ ├── genvecwhere.cpp
│ ├── operands.h
│ ├── operands2.h
│ ├── optuple.h
│ └── optuple2.h
│ ├── gnu
│ └── bzconfig.h
│ ├── indexexpr.h
│ ├── limits-hack.h
│ ├── listinit.h
│ ├── matbops.h
│ ├── matdiag.h
│ ├── matexpr.h
│ ├── matgen.h
│ ├── mathf2.h
│ ├── mathfunc.h
│ ├── matltri.h
│ ├── matref.h
│ ├── matrix.cc
│ ├── matrix.h
│ ├── matsymm.h
│ ├── mattoep.h
│ ├── matuops.h
│ ├── matutri.h
│ ├── memblock.cc
│ ├── memblock.h
│ ├── meta
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── dot.h
│ ├── matassign.h
│ ├── matmat.h
│ ├── matvec.h
│ ├── metaprog.h
│ ├── product.h
│ ├── sum.h
│ └── vecassign.h
│ ├── minmax.h
│ ├── mstruct.h
│ ├── numinquire.h
│ ├── numtrait.h
│ ├── ops.h
│ ├── prettyprint.h
│ ├── promote-old.h
│ ├── promote.h
│ ├── rand-dunif.h
│ ├── rand-normal.h
│ ├── rand-tt800.h
│ ├── rand-uniform.h
│ ├── random.h
│ ├── randref.h
│ ├── range.h
│ ├── reduce.h
│ ├── shapecheck.h
│ ├── tau.h
│ ├── timer.h
│ ├── tiny.h
│ ├── tinymat.h
│ ├── tinymatexpr.h
│ ├── tinymatio.cc
│ ├── tinyvec-et.h
│ ├── tinyvec.cc
│ ├── tinyvec.h
│ ├── tinyvecio.cc
│ ├── tinyveciter.h
│ ├── traversal.cc
│ ├── traversal.h
│ ├── tuning.h
│ ├── tvcross.h
│ ├── tvecglobs.h
│ ├── update.h
│ ├── vecaccum.cc
│ ├── vecall.cc
│ ├── vecany.cc
│ ├── vecbfn.cc
│ ├── vecbops.cc
│ ├── veccount.cc
│ ├── vecdelta.cc
│ ├── vecdot.cc
│ ├── vecexpr.h
│ ├── vecexprwrap.h
│ ├── vecglobs.cc
│ ├── vecglobs.h
│ ├── vecio.cc
│ ├── veciter.h
│ ├── vecmax.cc
│ ├── vecmin.cc
│ ├── vecnorm.cc
│ ├── vecnorm1.cc
│ ├── vecpick.cc
│ ├── vecpick.h
│ ├── vecpickio.cc
│ ├── vecpickiter.h
│ ├── vecsum.cc
│ ├── vector-et.h
│ ├── vector.cc
│ ├── vector.h
│ ├── vecuops.cc
│ ├── vecwhere.cc
│ ├── vecwhere.h
│ ├── wrap-climits.h
│ ├── zero.cc
│ └── zero.h
├── blitz_spec.py
├── blitz_tools.py
├── build_tools.py
├── bytecodecompiler.py
├── c_spec.py
├── catalog.py
├── common_info.py
├── converters.py
├── cpp_namespace_spec.py
├── ext_tools.py
├── inline_tools.py
├── numpy_scalar_spec.py
├── platform_info.py
├── scxx
├── README.txt
├── dict.h
├── list.h
├── notes.txt
├── number.h
├── object.h
├── sequence.h
├── str.h
├── tuple.h
└── weave_imp.cpp
├── setup.py
├── size_check.py
├── slice_handler.py
├── standard_array_spec.py
├── swig2_spec.py
├── swigptr.py
├── swigptr2.py
├── tests
├── scxx_timings.py
├── test_ast_tools.py
├── test_blitz_tools.py
├── test_build_tools.py
├── test_c_spec.py
├── test_catalog.py
├── test_ext_tools.py
├── test_inline_tools.py
├── test_numpy_scalar_spec.py
├── test_scxx_dict.py
├── test_scxx_object.py
├── test_scxx_sequence.py
├── test_size_check.py
├── test_slice_handler.py
├── test_standard_array_spec.py
└── weave_test_utils.py
└── vtk_spec.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Editor temporary/working/backup files #
2 | #########################################
3 | .#*
4 | [#]*#
5 | *~
6 | *$
7 | *.bak
8 | *.kdev4
9 | *.org
10 | .project
11 | .pydevproject
12 | *.rej
13 | .settings/
14 | .*.sw[nop]
15 | .sw[nop]
16 | *.tmp
17 | *.vim
18 | tags
19 |
20 | # Compiled source #
21 | ###################
22 | *.a
23 | *.com
24 | *.class
25 | *.dll
26 | *.exe
27 | *.l[ao]
28 | *.o
29 | *.py[ocd]
30 | *.so
31 | _configtest.c
32 |
33 | # Packages #
34 | ############
35 | # it's better to unpack these files and commit the raw source
36 | # git has its own built in compression methods
37 | *.7z
38 | *.bz2
39 | *.bzip2
40 | *.dmg
41 | *.gz
42 | *.iso
43 | *.jar
44 | *.rar
45 | *.tar
46 | *.tbz2
47 | *.tgz
48 | *.zip
49 |
50 | # Python files #
51 | ################
52 | # setup.py working directory
53 | build
54 | # sphinx build directory
55 | doc/_build
56 | # cython files
57 | cythonize.dat
58 | # setup.py dist directory
59 | dist
60 | # Egg metadata
61 | *.egg-info
62 | # tox testing tool
63 | .tox
64 | # The shelf plugin uses this dir
65 | ./.shelf
66 | MANIFEST
67 | # distutils configuration
68 | site.cfg
69 | # other temporary files
70 | .deps
71 | .libs
72 |
73 | # Paver generated files #
74 | #########################
75 | /release
76 |
77 | # Logs and databases #
78 | ######################
79 | *.log
80 | *.sql
81 | *.sqlite
82 |
83 | # Patches #
84 | ###########
85 | *.patch
86 | *.diff
87 |
88 | # OS generated files #
89 | ######################
90 | .directory
91 | .fseventsd
92 | .DS_Store*
93 | .gdb_history
94 | .VolumeIcon.icns
95 | ehthumbs.db
96 | Icon?
97 | Thumbs.db
98 |
99 | # Documentation generated files #
100 | #################################
101 | doc/frontpage/build
102 | doc/source/generated
103 |
104 | # Things specific to this project #
105 | ###################################
106 | weave/__config__.py
107 | weave/version.py
108 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scipy/weave/c0f6df08eaabc21d0c08b45317fc9b61d6fbd9ef/.gitmodules
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # After changing this file, check it on:
2 | # http://lint.travis-ci.org/
3 | language: python
4 | sudo: false
5 | matrix:
6 | include:
7 | - python: 3.7
8 | env:
9 | - TESTMODE=full
10 | - COVERAGE=--coverage
11 | - python: 3.6
12 | env:
13 | - TESTMODE=fast
14 | addons:
15 | apt:
16 | packages:
17 | - libatlas-dev
18 | - libatlas-base-dev
19 | - liblapack-dev
20 | - ccache
21 | cache:
22 | directories:
23 | - $HOME/.ccache
24 | before_install:
25 | - export PATH=/usr/lib/ccache:$PATH
26 | - uname -a
27 | - free -m
28 | - df -h
29 | - ulimit -a
30 | - mkdir builds
31 | - pushd builds
32 | - travis_retry pip install numpy
33 | - travis_retry pip install nose argparse
34 | - travis_retry pip install coverage
35 | - python -V
36 | - popd
37 | script:
38 | - python $OPTIMIZE runtests.py -g -m $TESTMODE $COVERAGE
39 | notifications:
40 | # Perhaps we should have status emails sent to the mailing list, but
41 | # let's wait to see what people think before turning that on.
42 | email: false
43 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include MANIFEST.in
2 | include *.txt
3 | # Top-level build scripts
4 | include setup.py
5 | # All source files
6 | recursive-include weave *
7 | # All documentation
8 | recursive-include doc *
9 | # Add build and testing tools
10 | include tox.ini
11 | # Exclude what we don't want to include
12 | prune doc/build
13 | prune doc/source/generated
14 | prune */__pycache__
15 | global-exclude *.pyc *~ *.bak *.swp *.pyo
16 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | ``scipy-weave`` provides tools for including C/C++ code within Python code.
2 | Inlining C/C++ code within Python generally results in speedups of 1.5x to 30x
3 | over algorithms written in pure Python.
4 |
5 | ``scipy-weave`` is the stand-alone version of the removed SciPy submodule
6 | ``scipy.weave``. It is provided for users that need versions of SciPy from
7 | which the ``weave`` submodule has been removed but have existing code that
8 | still depends on ``scipy.weave``. **For new code, users are recommended to use
9 | Cython.**
10 |
11 | Note that the Python 3.x support is new as of version 0.19.0 (Nov 2022), and is
12 | *experimental*. It is not tested on all Python 3.x versions.
13 | For Python 2.6-2.7, use versions 0.17.0 or 0.18.0
14 |
15 | To install ``scipy-weave``, use of pip is recommended::
16 |
17 | pip install scipy-weave
18 |
19 | Note that the import name for ``scipy-weave`` is ``weave``. To run the tests::
20 |
21 | python -c "import weave; weave.test('full')"
22 |
--------------------------------------------------------------------------------
/doc/release/0.15.0-notes.rst:
--------------------------------------------------------------------------------
1 | ==========================
2 | Weave 0.15.0 Release Notes
3 | ==========================
4 |
5 | Weave provides tools for including C/C++ code within Python code. Inlining
6 | C/C++ code within Python generally results in speedups of 1.5x to 30x over
7 | algorithms written in pure Python.
8 |
9 | Weave is the stand-alone version of the deprecated Scipy submodule scipy.weave.
10 | It is Python 2.x only, and is provided for users that need new versions of
11 | Scipy (from which the weave submodule may be removed) but have existing code
12 | that still depends on scipy.weave. For new code, users are recommended to use
13 | Cython.
14 |
15 | Weave 0.15.0 is the first release of Weave as a standalone package. It is
16 | numbered 0.15.0, because it was split from Scipy after the 0.14.0 release of
17 | that package. No new functionality is included in this release compared to
18 | Scipy 0.14.0, only changes needed to make Weave a standalone package.
19 |
20 | This release requires Python 2.6 or 2.7.
21 |
--------------------------------------------------------------------------------
/doc/release/0.16.0-notes.rst:
--------------------------------------------------------------------------------
1 | ==========================
2 | Weave 0.16.0 Release Notes
3 | ==========================
4 |
5 | Weave provides tools for including C/C++ code within Python code. Inlining
6 | C/C++ code within Python generally results in speedups of 1.5x to 30x over
7 | algorithms written in pure Python.
8 |
9 | Weave is the stand-alone version of the deprecated Scipy submodule scipy.weave.
10 | It is Python 2.x only, and is provided for users that need new versions of
11 | Scipy (from which the weave submodule may be removed) but have existing code
12 | that still depends on scipy.weave. For new code, users are recommended to use
13 | Cython.
14 |
15 | Weave 0.16.0 is a maintenance release that accounts for changes in SciPy since
16 | the Weave 0.15.0 release.
17 |
18 | This release requires Python 2.6 or 2.7.
19 |
--------------------------------------------------------------------------------
/doc/release/0.17.0-notes.rst:
--------------------------------------------------------------------------------
1 | ==========================
2 | Weave 0.17.0 Release Notes
3 | ==========================
4 |
5 | Weave provides tools for including C/C++ code within Python code. Inlining
6 | C/C++ code within Python generally results in speedups of 1.5x to 30x over
7 | algorithms written in pure Python.
8 |
9 | Weave is the stand-alone version of the now-removed SciPy submodule ``scipy.weave``.
10 | It is Python 2.x only, and is provided for users that need new versions of
11 | SciPy but have existing code that still depends on ``scipy.weave``. For new code,
12 | users are recommended to use Cython.
13 |
14 | Weave 0.17.0 is a maintenance release that fixes compatibility with NumPy
15 | 1.16.x.
16 |
17 | This release requires Python 2.6 or 2.7.
18 |
--------------------------------------------------------------------------------
/doc/source/_static/scipy_fallback.css:
--------------------------------------------------------------------------------
1 | @import "default.css";
2 |
3 | /**
4 | * Spacing fixes
5 | */
6 |
7 | div.body p, div.body dd, div.body li {
8 | line-height: 125%;
9 | }
10 |
11 | ul.simple {
12 | margin-top: 0;
13 | margin-bottom: 0;
14 | padding-top: 0;
15 | padding-bottom: 0;
16 | }
17 |
18 | /* spacing around blockquoted fields in parameters/attributes/returns */
19 | td.field-body > blockquote {
20 | margin-top: 0.1em;
21 | margin-bottom: 0.5em;
22 | }
23 |
24 | /* spacing around example code */
25 | div.highlight > pre {
26 | padding: 2px 5px 2px 5px;
27 | }
28 |
29 | /* spacing in see also definition lists */
30 | dl.last > dd {
31 | margin-top: 1px;
32 | margin-bottom: 5px;
33 | margin-left: 30px;
34 | }
35 |
36 | /* hide overflowing content in the sidebar */
37 | div.sphinxsidebarwrapper p.topless {
38 | overflow: hidden;
39 | }
40 |
41 | /**
42 | * Hide dummy toctrees
43 | */
44 |
45 | ul {
46 | padding-top: 0;
47 | padding-bottom: 0;
48 | margin-top: 0;
49 | margin-bottom: 0;
50 | }
51 | ul li {
52 | padding-top: 0;
53 | padding-bottom: 0;
54 | margin-top: 0;
55 | margin-bottom: 0;
56 | }
57 | ul li a.reference {
58 | padding-top: 0;
59 | padding-bottom: 0;
60 | margin-top: 0;
61 | margin-bottom: 0;
62 | }
63 |
64 | /**
65 | * Make high-level subsections easier to distinguish from top-level ones
66 | */
67 | div.body h3 {
68 | background-color: transparent;
69 | }
70 |
71 | div.body h4 {
72 | border: none;
73 | background-color: transparent;
74 | }
75 |
76 | /**
77 | * Scipy colors
78 | */
79 |
80 | body {
81 | background-color: rgb(100,135,220);
82 | }
83 |
84 | div.document {
85 | background-color: rgb(230,230,230);
86 | }
87 |
88 | div.sphinxsidebar {
89 | background-color: rgb(230,230,230);
90 | overflow: hidden;
91 | }
92 |
93 | div.related {
94 | background-color: rgb(100,135,220);
95 | }
96 |
97 | div.sphinxsidebar h3 {
98 | color: rgb(0,102,204);
99 | }
100 |
101 | div.sphinxsidebar h3 a {
102 | color: rgb(0,102,204);
103 | }
104 |
105 | div.sphinxsidebar h4 {
106 | color: rgb(0,82,194);
107 | }
108 |
109 | div.sphinxsidebar p {
110 | color: black;
111 | }
112 |
113 | div.sphinxsidebar a {
114 | color: #355f7c;
115 | }
116 |
117 | div.sphinxsidebar ul.want-points {
118 | list-style: disc;
119 | }
120 |
121 | .field-list th {
122 | color: rgb(0,102,204);
123 | white-space: nowrap;
124 | }
125 |
126 | /**
127 | * Extra admonitions
128 | */
129 |
130 | div.tip {
131 | background-color: #ffffe4;
132 | border: 1px solid #ee6;
133 | }
134 |
135 | div.plot-output {
136 | clear-after: both;
137 | }
138 |
139 | div.plot-output .figure {
140 | float: left;
141 | text-align: center;
142 | margin-bottom: 0;
143 | padding-bottom: 0;
144 | }
145 |
146 | div.plot-output .caption {
147 | margin-top: 2;
148 | padding-top: 0;
149 | }
150 |
151 | div.plot-output:after {
152 | content: "";
153 | display: block;
154 | height: 0;
155 | clear: both;
156 | }
157 |
158 |
159 | /*
160 | div.admonition-example {
161 | background-color: #e4ffe4;
162 | border: 1px solid #ccc;
163 | }*/
164 |
165 |
166 | /**
167 | * Styling for field lists
168 | */
169 |
170 | table.field-list th {
171 | border-left: 1px solid #aaa !important;
172 | padding-left: 5px;
173 | }
174 |
175 | table.field-list {
176 | border-collapse: separate;
177 | border-spacing: 10px;
178 | }
179 |
180 | /**
181 | * Styling for footnotes
182 | */
183 |
184 | table.footnote td, table.footnote th {
185 | border: none;
186 | }
187 |
--------------------------------------------------------------------------------
/doc/source/_static/scipyshiny_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scipy/weave/c0f6df08eaabc21d0c08b45317fc9b61d6fbd9ef/doc/source/_static/scipyshiny_small.png
--------------------------------------------------------------------------------
/doc/source/_templates/autosummary/class.rst:
--------------------------------------------------------------------------------
1 | {% extends "!autosummary/class.rst" %}
2 |
3 | {% block methods %}
4 | {% if methods %}
5 | .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
6 | .. autosummary::
7 | :toctree:
8 | {% for item in all_methods %}
9 | {%- if not item.startswith('_') or item in ['__call__'] %}
10 | {{ name }}.{{ item }}
11 | {%- endif -%}
12 | {%- endfor %}
13 | {% endif %}
14 | {% endblock %}
15 |
16 | {% block attributes %}
17 | {% if attributes %}
18 | .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
19 | .. autosummary::
20 | :toctree:
21 | {% for item in all_attributes %}
22 | {%- if not item.startswith('_') %}
23 | {{ name }}.{{ item }}
24 | {%- endif -%}
25 | {%- endfor %}
26 | {% endif %}
27 | {% endblock %}
28 |
--------------------------------------------------------------------------------
/doc/source/_templates/indexsidebar.html:
--------------------------------------------------------------------------------
1 |
Resources
2 |
6 |
--------------------------------------------------------------------------------
/doc/source/_templates/layout.html:
--------------------------------------------------------------------------------
1 | {% extends "!layout.html" %}
2 |
3 | {% block sidebarsearch %}
4 | {%- if sourcename %}
5 |
12 | {%- endif %}
13 | {{ super() }}
14 | {% endblock %}
15 |
--------------------------------------------------------------------------------
/doc/source/api_reference.rst:
--------------------------------------------------------------------------------
1 | *************
2 | API reference
3 | *************
4 |
5 | .. warning::
6 |
7 | This documentation is work-in-progress; incomplete and unorganized.
8 |
9 | .. automodule:: weave
10 | :members:
11 |
12 |
13 | .. autosummary::
14 | :toctree: generated/
15 |
16 | inline
17 |
--------------------------------------------------------------------------------
/doc/source/index.rst:
--------------------------------------------------------------------------------
1 | Weave
2 | =====
3 |
4 | :Release: |release|
5 | :Date: |today|
6 |
7 | Weave provides tools for including C/C++ code within Python code. Inlining
8 | C/C++ code within Python generally results in speedups of 1.5x to 30x over
9 | algorithms written in pure Python.
10 |
11 | Weave is the stand-alone version of the deprecated Scipy submodule
12 | ``scipy.weave``. It is Python 2.x only, and is provided for users that need
13 | new versions of Scipy (from which the ``weave`` submodule may be removed) but
14 | have existing code that still depends on ``scipy.weave``. For new code, users
15 | are recommended to use Cython.
16 |
17 |
18 | .. toctree::
19 | :maxdepth: 2
20 |
21 | release
22 | tutorial
23 | api_reference
24 |
--------------------------------------------------------------------------------
/doc/source/release.0.15.0.rst:
--------------------------------------------------------------------------------
1 | .. include:: ../release/0.15.0-notes.rst
2 |
--------------------------------------------------------------------------------
/doc/source/release.0.16.0.rst:
--------------------------------------------------------------------------------
1 | .. include:: ../release/0.16.0-notes.rst
2 |
--------------------------------------------------------------------------------
/doc/source/release.0.17.0.rst:
--------------------------------------------------------------------------------
1 | .. include:: ../release/0.17.0-notes.rst
2 |
--------------------------------------------------------------------------------
/doc/source/release.rst:
--------------------------------------------------------------------------------
1 | *************
2 | Release Notes
3 | *************
4 |
5 | .. toctree::
6 | :maxdepth: 1
7 |
8 | release.0.15.0
9 | release.0.16.0
10 | release.0.17.0
11 |
--------------------------------------------------------------------------------
/examples/array3d.py:
--------------------------------------------------------------------------------
1 | """ A simple example to show how to access a 3D numpy array. One
2 | example shows how to access the numpy array using blitz type
3 | converters and the other shows how it can be done without using blitz
4 | by accessing the numpy array data directly.
5 |
6 | """
7 |
8 |
9 | import weave
10 | from weave import converters
11 | import numpy
12 |
13 |
14 | def create_array():
15 | """Creates a simple 3D numpy array with unique values at each
16 | location in the matrix.
17 |
18 | """
19 | rows, cols, depth = 2, 3, 4
20 | arr = numpy.zeros((rows, cols, depth), 'i')
21 | count = 0
22 | for i in range(rows):
23 | for j in range(cols):
24 | for k in range(depth):
25 | arr[i,j,k] = count
26 | count += 1
27 | return arr
28 |
29 |
30 | def pure_inline(arr):
31 | """Prints the given 3D array by accessing the raw numpy data and
32 | without using blitz converters.
33 |
34 | Notice the following:
35 | 1. '\\n' to escape generating a newline in the C++ code.
36 | 2. rows, cols = Narr[0], Narr[1].
37 | 3. Array access using arr[(i*cols + j)*depth + k].
38 |
39 | """
40 |
41 | code = """
42 | int rows = Narr[0];
43 | int cols = Narr[1];
44 | int depth = Narr[2];
45 | for (int i=0; i < rows; i++)
46 | {
47 | for (int j=0; j < cols; j++)
48 | {
49 | printf("img[%3d][%3d]=", i, j);
50 | for (int k=0; k< depth; ++k)
51 | {
52 | printf(" %3d", arr[(i*cols + j)*depth + k]);
53 | }
54 | printf("\\n");
55 | }
56 | }
57 | """
58 |
59 | weave.inline(code, ['arr'])
60 |
61 |
62 | def blitz_inline(arr):
63 | """Prints the given 3D array by using blitz converters which
64 | provides a numpy-like syntax for accessing the numpy data.
65 |
66 | Notice the following:
67 | 1. '\\n' to escape generating a newline in the C++ code.
68 | 2. rows, cols = Narr[0], Narr[1].
69 | 3. Array access using arr(i, j, k).
70 |
71 | """
72 |
73 | code = """
74 | int rows = Narr[0];
75 | int cols = Narr[1];
76 | int depth = Narr[2];
77 | for (int i=0; i < rows; i++)
78 | {
79 | for (int j=0; j < cols; j++)
80 | {
81 | printf("img[%3d][%3d]=", i, j);
82 | for (int k=0; k< depth; ++k)
83 | {
84 | printf(" %3d", arr(i, j, k));
85 | }
86 | printf("\\n");
87 | }
88 | }
89 | """
90 |
91 | weave.inline(code, ['arr'], type_converters=converters.blitz)
92 |
93 |
94 | def main():
95 | arr = create_array()
96 | print("numpy:")
97 | print(arr)
98 |
99 | print("Pure Inline:")
100 | pure_inline(arr)
101 |
102 | print("Blitz Inline:")
103 | blitz_inline(arr)
104 |
105 |
106 | if __name__ == '__main__':
107 | main()
108 |
--------------------------------------------------------------------------------
/examples/functional.py:
--------------------------------------------------------------------------------
1 | # C:\home\eric\wrk\weave\examples>python functional.py
2 | # desired: [2, 3, 4]
3 | # actual: [2, 3, 4]
4 | # actual2: [2, 3, 4]
5 | # python speed: 0.039999961853
6 | # SCXX speed: 0.0599999427795
7 | # speed up: 0.666666666667
8 | # c speed: 0.0200001001358
9 | # speed up: 1.99998807913
10 |
11 |
12 | import sys
13 | sys.path.insert(0,'..')
14 | import inline_tools
15 | from types import *
16 |
17 |
18 | def c_list_map(func,seq):
19 | """ Uses CXX C code to implement a simple map-like function.
20 | It does not provide any error checking.
21 | """
22 | assert(type(func) in [FunctionType,MethodType,type(len)])
23 | code = """
24 | #line 22 "functional.py"
25 | py::tuple args(1);
26 | int N = seq.len();
27 | py::list result(N);
28 | for(int i = 0; i < N;i++)
29 | {
30 | args[0] = seq[i];
31 | result[i] = func.call(args);
32 | }
33 | return_val = result;
34 | """
35 | return inline_tools.inline(code,['func','seq'])
36 |
37 |
38 | def c_list_map2(func,seq):
39 | """ Uses Python API more than CXX to implement a simple map-like function.
40 | It does not provide any error checking.
41 | """
42 | assert(type(func) in [FunctionType,MethodType,type(len)])
43 | code = """
44 | #line 40 "functional.py"
45 | py::tuple args(1);
46 | PyObject* py_args = (PyObject*)args;
47 | py::list result(seq.len());
48 | PyObject* py_result = (PyObject*)result;
49 | PyObject* item = NULL;
50 | PyObject* this_result = NULL;
51 | int N = seq.len();
52 | for(int i = 0; i < N;i++)
53 | {
54 | item = PyList_GET_ITEM(py_seq,i);
55 | Py_INCREF(item);
56 | PyTuple_SetItem(py_args,0,item);
57 | this_result = PyEval_CallObject(py_func,py_args);
58 | PyList_SetItem(py_result,i,this_result);
59 | }
60 | return_val = result;
61 | """
62 | return inline_tools.inline(code,['func','seq'])
63 |
64 |
65 | def main():
66 | seq = ['aa','bbb','cccc']
67 | print('desired:', list(map(len,seq)))
68 | print('actual:', c_list_map(len,seq))
69 | print('actual2:', c_list_map2(len,seq))
70 |
71 |
72 | def time_it(m,n):
73 | import time
74 | seq = ['aadasdf'] * n
75 | t1 = time.time()
76 | for i in range(m):
77 | result = list(map(len,seq))
78 | t2 = time.time()
79 | py = t2 - t1
80 | print('python speed:', py)
81 |
82 | #load cache
83 | result = c_list_map(len,seq)
84 | t1 = time.time()
85 | for i in range(m):
86 | result = c_list_map(len,seq)
87 | t2 = time.time()
88 | c = t2-t1
89 | print('SCXX speed:', c)
90 | print('speed up:', py / c)
91 |
92 | #load cache
93 | result = c_list_map2(len,seq)
94 | t1 = time.time()
95 | for i in range(m):
96 | result = c_list_map2(len,seq)
97 | t2 = time.time()
98 | c = t2-t1
99 | print('c speed:', c)
100 | print('speed up:', py / c)
101 |
102 | if __name__ == "__main__":
103 | main()
104 | time_it(100,1000)
105 |
--------------------------------------------------------------------------------
/examples/increment_example.py:
--------------------------------------------------------------------------------
1 | # examples/increment_example.py
2 |
3 | # from weave import ext_tools
4 |
5 | # use the following so that development version is used.
6 |
7 |
8 | import sys
9 | sys.path.insert(0,'..')
10 | import weave.ext_tools as ext_tools
11 |
12 |
13 | def build_increment_ext():
14 | """ Build a simple extension with functions that increment numbers.
15 | The extension will be built in the local directory.
16 | """
17 | mod = ext_tools.ext_module('increment_ext')
18 |
19 | # Effectively a type declaration for 'a' in the following functions.
20 | a = 1
21 |
22 | ext_code = "return_val = PyLong_FromLong(a+1);"
23 | func = ext_tools.ext_function('increment',ext_code,['a'])
24 | mod.add_function(func)
25 |
26 | ext_code = "return_val = PyLong_FromLong(a+2);"
27 | func = ext_tools.ext_function('increment_by_2',ext_code,['a'])
28 | mod.add_function(func)
29 |
30 | mod.compile()
31 |
32 | if __name__ == "__main__":
33 | try:
34 | import increment_ext
35 | except ImportError:
36 | build_increment_ext()
37 | import increment_ext
38 | a = 1
39 | print('a, a+1:', a, increment_ext.increment(a))
40 | print('a, a+2:', a, increment_ext.increment_by_2(a))
41 |
--------------------------------------------------------------------------------
/examples/md5_speed.py:
--------------------------------------------------------------------------------
1 | """
2 | Storing actual strings instead of their md5 value appears to
3 | be about 10 times faster.
4 |
5 | >>> md5_speed.run(200,50000)
6 | md5 build(len,sec): 50000 0.870999932289
7 | md5 retrv(len,sec): 50000 0.680999994278
8 | std build(len,sec): 50000 0.259999990463
9 | std retrv(len,sec): 50000 0.0599999427795
10 |
11 | This test actually takes several minutes to generate the random
12 | keys used to populate the dictionaries. Here is a smaller run,
13 | but with longer keys.
14 |
15 | >>> md5_speed.run(1000,4000)
16 | md5 build(len,sec,per): 4000 0.129999995232 3.24999988079e-005
17 | md5 retrv(len,sec,per): 4000 0.129999995232 3.24999988079e-005
18 | std build(len,sec,per): 4000 0.0500000715256 1.25000178814e-005
19 | std retrv(len,sec,per): 4000 0.00999999046326 2.49999761581e-006
20 |
21 | Results are similar, though not statistically to good because of
22 | the short times used and the available clock resolution.
23 |
24 | Still, I think it is safe to say that, for speed, it is better
25 | to store entire strings instead of using md5 versions of
26 | their strings. Yeah, the expected result, but it never hurts
27 | to check...
28 |
29 | """
30 |
31 |
32 | import random
33 | import md5
34 | import time
35 | import io
36 |
37 |
38 | def speed(n,m):
39 | s = 'a'*n
40 | t1 = time.time()
41 | for i in range(m):
42 | q = md5.new(s).digest()
43 | t2 = time.time()
44 | print((t2 - t1) / m)
45 |
46 | #speed(50,1e6)
47 |
48 |
49 | def generate_random(avg_length,count):
50 | all_str = []
51 | alphabet = 'abcdefghijklmnopqrstuvwxyz'
52 | lo,hi = [30,avg_length*2+30]
53 | for i in range(count):
54 | new_str = io.StringIO()
55 | l = random.randrange(lo,hi)
56 | for i in range(l):
57 | new_str.write(random.choice(alphabet))
58 | all_str.append(new_str.getvalue())
59 | return all_str
60 |
61 |
62 | def md5_dict(lst):
63 | catalog = {}
64 | t1 = time.time()
65 | for s in lst:
66 | key = md5.new(s).digest()
67 | catalog[key] = None
68 | t2 = time.time()
69 | print('md5 build(len,sec,per):', len(lst), t2 - t1, (t2-t1)/len(lst))
70 |
71 | t1 = time.time()
72 | for s in lst:
73 | key = md5.new(s).digest()
74 | val = catalog[key]
75 | t2 = time.time()
76 | print('md5 retrv(len,sec,per):', len(lst), t2 - t1, (t2-t1)/len(lst))
77 |
78 |
79 | def std_dict(lst):
80 | catalog = {}
81 | t1 = time.time()
82 | for s in lst:
83 | catalog[s] = None
84 | t2 = time.time()
85 | print('std build(len,sec,per):', len(lst), t2 - t1, (t2-t1)/len(lst))
86 |
87 | t1 = time.time()
88 | for s in lst:
89 | val = catalog[s]
90 | t2 = time.time()
91 | print('std retrv(len,sec,per):', len(lst), t2 - t1, (t2-t1)/len(lst))
92 |
93 |
94 | def run(m=200,n=10):
95 | lst = generate_random(m,n)
96 | md5_dict(lst)
97 | std_dict(lst)
98 |
99 | run(2000,100)
100 |
--------------------------------------------------------------------------------
/examples/object.py:
--------------------------------------------------------------------------------
1 | """ Attribute and method access on Python objects from C++.
2 |
3 | Note: std::cout type operations currently crash python...
4 | Not sure what is up with this...
5 | """
6 |
7 |
8 | import weave
9 |
10 | #----------------------------------------------------------------------------
11 | # get/set attribute and call methods example
12 | #----------------------------------------------------------------------------
13 |
14 |
15 | class Foo(object):
16 | def __init__(self):
17 | self.val = 1
18 |
19 | def inc(self,amount):
20 | self.val += amount
21 | return self.val
22 | obj = Foo()
23 | code = """
24 | py::tuple result(3);
25 |
26 | int i = obj.attr("val");
27 | result[0] = i;
28 |
29 | py::tuple args(1);
30 | args[0] = 2;
31 | i = obj.mcall("inc",args);
32 | result[1] = i;
33 |
34 | obj.set_attr("val",5);
35 | i = obj.attr("val");
36 | result[2] = i;
37 |
38 | return_val = result;
39 | """
40 |
41 | print('initial, inc(2), set(5)/get:', weave.inline(code,['obj']))
42 |
43 | #----------------------------------------------------------------------------
44 | # indexing of values.
45 | #----------------------------------------------------------------------------
46 | from collections import UserList
47 | obj = UserList([1,[1,2],"hello"])
48 | code = """
49 | int i;
50 | // find obj length and access each of its items
51 | //std::cout << "UserList items: ";
52 | //for(i = 0; i < obj.length(); i++)
53 | // std::cout << obj[i].str() << " ";
54 | //std::cout << std::endl;
55 | // assign new values to each of its items
56 | for(i = 0; i < obj.length(); i++)
57 | obj[i] = "goodbye";
58 | """
59 | weave.inline(code,['obj'])
60 | print("obj with new values:", obj)
61 |
--------------------------------------------------------------------------------
/examples/print_example.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | import sys
4 | sys.path.insert(0,'..')
5 | import inline_tools
6 |
7 | import time
8 |
9 |
10 | def print_compare(n):
11 | print('Printing %d integers:' % n)
12 | t1 = time.time()
13 | for i in range(n):
14 | print(i, end=' ')
15 | t2 = time.time()
16 | py = (t2-t1)
17 |
18 | # get it in cache
19 | inline_tools.inline('printf("%d",i);',['i'])
20 | t1 = time.time()
21 | for i in range(n):
22 | inline_tools.inline('printf("%d",i);',['i'])
23 | t2 = time.time()
24 | print(' speed in python:', py)
25 | print(' speed in c:',(t2 - t1))
26 | print(' speed up: %3.2f' % (py/(t2-t1)))
27 |
28 |
29 | def cout_example(lst):
30 | # get it in cache
31 | i = lst[0]
32 | inline_tools.inline('std::cout << i << std::endl;',['i'])
33 | t1 = time.time()
34 | for i in lst:
35 | inline_tools.inline('std::cout << i << std::endl;',['i'])
36 | t2 = time.time()
37 |
38 | if __name__ == "__main__":
39 | n = 3000
40 | print_compare(n)
41 | print("calling cout with integers:")
42 | cout_example([1,2,3])
43 | print("calling cout with strings:")
44 | cout_example(['a','bb', 'ccc'])
45 |
--------------------------------------------------------------------------------
/examples/py_none.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | # This tests the amount of overhead added for inline() function calls.
4 | # It isn't a "real world" test, but is somewhat informative.
5 | # C:\home\ej\wrk\weave\examples>python py_none.py
6 | # python: 0.0199999809265
7 | # inline: 0.160000085831
8 | # speed up: 0.124999813736 (this is about a factor of 8 slower)
9 |
10 | import time
11 | import sys
12 | sys.path.insert(0,'..')
13 | from inline_tools import inline
14 |
15 |
16 | def py_func():
17 | return None
18 |
19 | n = 10000
20 | t1 = time.time()
21 | for i in range(n):
22 | py_func()
23 | t2 = time.time()
24 | py_time = t2 - t1
25 | print('python:', py_time)
26 |
27 | inline("",[])
28 | t1 = time.time()
29 | for i in range(n):
30 | inline("",[])
31 | t2 = time.time()
32 | print('inline:', (t2-t1))
33 | print('speed up:', py_time/(t2-t1))
34 | print('or (more likely) slow down:', (t2-t1)/py_time)
35 |
--------------------------------------------------------------------------------
/examples/ramp.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | void Ramp(double* result, int size, double start, double end)
5 | {
6 | double step = (end-start)/(size-1);
7 | double val = start;
8 | int i;
9 | for (i = 0; i < size; i++)
10 | {
11 | *result++ = val;
12 | val += step;
13 | }
14 | }
15 |
16 | void main()
17 | {
18 | double array[10000];
19 | int i;
20 | clock_t t1, t2;
21 | float seconds;
22 | t1 = clock();
23 | for (i = 0; i < 10000; i++)
24 | Ramp(array, 10000, 0.0, 1.0);
25 | t2 = clock();
26 | seconds = (float)(t2-t1)/CLOCKS_PER_SEC;
27 | printf("c version (seconds): %f\n", seconds);
28 | printf("array[500]: %f\n", array[500]);
29 | }
--------------------------------------------------------------------------------
/examples/ramp2.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | #
4 | # C:\home\eric\wrk\weave\examples>python ramp2.py
5 | # python (seconds): 2.94499993324
6 | # arr[500]: 0.0500050005001
7 | #
8 | # compiled numeric (seconds, speed up): 3.47500002384 42.3740994682
9 | # arr[500]: 0.0500050005001
10 |
11 | import time
12 | from weave import ext_tools
13 | from numpy import *
14 |
15 |
16 | def Ramp(result, size, start, end):
17 | step = (end-start)/(size-1)
18 | for i in range(size):
19 | result[i] = start + step*i
20 |
21 |
22 | def build_ramp_ext():
23 | mod = ext_tools.ext_module('ramp_ext')
24 |
25 | # type declarations
26 | result = array([0],float64)
27 | start,end = 0.,0.
28 | code = """
29 | const int size = Nresult[0];
30 | const double step = (end-start)/(size-1);
31 | double val = start;
32 | for (int i = 0; i < size; i++)
33 | {
34 | result[i] = val;
35 | val += step;
36 | }
37 | """
38 | func = ext_tools.ext_function('Ramp',code,['result','start','end'])
39 | mod.add_function(func)
40 | mod.compile(compiler='gcc')
41 |
42 |
43 | def main():
44 | arr = [0]*10000
45 | t1 = time.time()
46 | for i in range(200):
47 | Ramp(arr, 10000, 0.0, 1.0)
48 | t2 = time.time()
49 | py_time = t2 - t1
50 | print('python (seconds):', py_time)
51 | print('arr[500]:', arr[500])
52 | print()
53 |
54 | try:
55 | import ramp_ext
56 | except:
57 | build_ramp_ext()
58 | import ramp_ext
59 | arr = array([0]*10000,float64)
60 | for i in range(10000):
61 | ramp_ext.Ramp(arr, 0.0, 1.0)
62 | t2 = time.time()
63 | c_time = (t2 - t1)
64 | print('compiled numeric (seconds, speed up):', c_time, (py_time*10000/200.) / c_time)
65 | print('arr[500]:', arr[500])
66 |
67 | if __name__ == '__main__':
68 | main()
69 |
--------------------------------------------------------------------------------
/examples/support_code_example.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | import sys
4 | sys.path.insert(0,'..')
5 | import inline_tools
6 |
7 |
8 | support_code = """
9 | PyObject* length(std::string a)
10 | {
11 | int l = a.length();
12 | return PyLong_FromLong(l);
13 | }
14 | """
15 | a = 'some string'
16 | val = inline_tools.inline("return_val = length(a);",['a'],
17 | support_code=support_code)
18 | print(val)
19 |
--------------------------------------------------------------------------------
/examples/swig2_example.py:
--------------------------------------------------------------------------------
1 | """Simple example to show how to use weave.inline on SWIG2 wrapped
2 | objects. SWIG2 refers to SWIG versions >= 1.3.
3 |
4 | To run this example you must build the trivial SWIG2 extension called
5 | swig2_ext. To do this you need to do something like this::
6 |
7 | $ swig -c++ -python -I. -o swig2_ext_wrap.cxx swig2_ext.i
8 |
9 | $ g++ -Wall -O2 -I/usr/include/python2.3 -fPIC -I. -c \
10 | -o swig2_ext_wrap.os swig2_ext_wrap.cxx
11 |
12 | $ g++ -shared -o _swig2_ext.so swig2_ext_wrap.os \
13 | -L/usr/lib/python2.3/config
14 |
15 | The files swig2_ext.i and swig2_ext.h are included in the same
16 | directory that contains this file.
17 |
18 | Note that weave's SWIG2 support works fine whether SWIG_COBJECT_TYPES
19 | are used or not.
20 |
21 | Author: Prabhu Ramachandran
22 | Copyright (c) 2004, Prabhu Ramachandran
23 | License: BSD Style.
24 |
25 | """
26 |
27 |
28 | # Import our SWIG2 wrapped library
29 | import swig2_ext
30 |
31 | import weave
32 | from weave import swig2_spec, converters
33 |
34 | # SWIG2 support is not enabled by default. We do this by adding the
35 | # swig2 converter to the default list of converters.
36 | converters.default.insert(0, swig2_spec.swig2_converter())
37 |
38 |
39 | def test():
40 | """Instantiate the SWIG wrapped object and then call its method
41 | from C++ using weave.inline
42 |
43 | """
44 | a = swig2_ext.A()
45 | b = swig2_ext.foo() # This will be an APtr instance.
46 | b.thisown = 1 # Prevent memory leaks.
47 | code = """a->f();
48 | b->f();
49 | """
50 | weave.inline(code, ['a', 'b'], include_dirs=['.'],
51 | headers=['"swig2_ext.h"'], verbose=1)
52 |
53 |
54 | if __name__ == "__main__":
55 | test()
56 |
--------------------------------------------------------------------------------
/examples/swig2_ext.h:
--------------------------------------------------------------------------------
1 | #include
2 | class A {
3 | public:
4 | void f() {std::cout << "A::f()\n";}
5 | };
6 |
7 | A* foo()
8 | {
9 | A* a = new A;
10 | return a;
11 | }
12 |
--------------------------------------------------------------------------------
/examples/swig2_ext.i:
--------------------------------------------------------------------------------
1 | %module swig2_ext
2 | %{
3 | #include "swig2_ext.h"
4 | %}
5 |
6 | %include "swig2_ext.h"
7 |
--------------------------------------------------------------------------------
/examples/tuple_return.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | import sys
4 | sys.path.insert(0,'..')
5 | import inline_tools
6 |
7 |
8 | def multi_return():
9 | return 1, '2nd'
10 |
11 |
12 | def c_multi_return():
13 |
14 | code = """
15 | py::tuple results(2);
16 | results[0] = 1;
17 | results[1] = "2nd";
18 | return_val = results;
19 | """
20 | return inline_tools.inline(code,[])
21 |
22 |
23 | def compare(m):
24 | import time
25 | t1 = time.time()
26 | for i in range(m):
27 | py_result = multi_return()
28 | t2 = time.time()
29 | py = t2 - t1
30 | print('python speed:', py)
31 |
32 | #load cache
33 | result = c_multi_return()
34 | t1 = time.time()
35 | for i in range(m):
36 | c_result = c_multi_return()
37 | t2 = time.time()
38 | c = t2-t1
39 | print('c speed:', c)
40 | print('speed up:', py / c)
41 | print('or slow down (more likely:', c / py)
42 | print('python result:', py_result)
43 | print('c result:', c_result)
44 |
45 | if __name__ == "__main__":
46 | compare(10000)
47 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | # 'Tox' is a tool for automating sdist/build/test cycles against
2 | # multiple Python versions:
3 | # http://pypi.python.org/pypi/tox
4 | # http://tox.testrun.org/
5 |
6 | # Running the command 'tox' while in the root of the weave source
7 | # directory will:
8 | # - Create a weave source distribution (setup.py sdist)
9 | # - Then for every supported version of Python:
10 | # - Create a virtualenv in {homedir}/.tox/weave/py$VERSION and
11 | # install dependencies. (These virtualenvs are cached across
12 | # runs unless you use --recreate.)
13 | # - Use pip to install the weave sdist into the virtualenv
14 | # - Run the weave tests
15 | # To run against a specific subset of Python versions, use:
16 | # tox -e py27
17 |
18 | # Extra arguments will be passed to runtests.py. To run the full testsuite:
19 | # tox full
20 | # To run with extra verbosity:
21 | # tox -- -v
22 |
23 | # Tox assumes that you have appropriate Python interpreters already
24 | # installed and that they can be run as 'python2.6', 'python2.7', etc.
25 |
26 | [tox]
27 | toxworkdir = {homedir}/.tox/weave/
28 | envlist = py26,py27,py34
29 |
30 | [testenv]
31 | deps=
32 | nose
33 | numpy
34 | changedir={envdir}
35 | commands=python {toxinidir}/runtests.py -n -m full {posargs:}
36 |
37 | [pep8]
38 | max_line_length=79
39 | statistics = True
40 | ignore = E121,E122,E123,E125,E126,E127,E128,E226,E231,E265,E501,E712,W291,W293,W391
41 |
--------------------------------------------------------------------------------
/weave/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | C/C++ integration for Python
3 |
4 | Main functions are::
5 |
6 | inline -- a function for including C/C++ code within Python
7 | blitz -- a function for compiling Numeric expressions to C++
8 | ext_tools -- a module that helps construct C/C++ extension modules.
9 | accelerate -- a module that inline accelerates Python functions
10 |
11 |
12 | .. note:: On Linux one needs to have the Python development headers installed
13 | in order to be able to compile things with the `weave` module.
14 | Since this is a runtime dependency these headers (typically in a
15 | pythonX.Y-dev package) are not always installed when installing
16 | weave.
17 |
18 | """
19 |
20 |
21 | import sys
22 |
23 | from weave.version import version as __version__
24 |
25 | from .blitz_tools import blitz, BlitzWarning
26 | from .inline_tools import inline
27 | from . import ext_tools
28 | from .ext_tools import ext_module, ext_function
29 | try:
30 | from .accelerate_tools import accelerate
31 | except:
32 | pass
33 |
34 |
35 | from numpy.testing import Tester
36 | test = Tester().test
37 |
--------------------------------------------------------------------------------
/weave/_dumb_shelve.py:
--------------------------------------------------------------------------------
1 | from shelve import Shelf
2 | import collections
3 | try:
4 | import zlib
5 | except ImportError:
6 | zlib = None
7 |
8 | class ZlibMapping(collections.MutableMapping):
9 | """Mapping adapter that applies zlib compression.
10 | """
11 |
12 | def __init__(self, dict):
13 | self.dict = dict
14 | if hasattr(dict, 'close'):
15 | self.close = dict.close
16 | if hasattr(dict, 'sync'):
17 | self.sync = dict.sync
18 | if hasattr(dict, 'keys'):
19 | self.keys = dict.keys
20 |
21 | def __iter__(self):
22 | return iter(self.dict)
23 |
24 | def __len__(self):
25 | return len(self.dict)
26 |
27 | def __contains__(self, key):
28 | return key in self.dict
29 |
30 | def __getitem__(self, key):
31 | return zlib.decompress(self.dict[key])
32 |
33 | def __setitem__(self, key, value):
34 | self.dict[key] = zlib.compress(value)
35 |
36 | def __delitem__(self, key):
37 | del self.dict[key]
38 |
39 |
40 | def open(filename, flag='c'):
41 | """Open a persistent dictionary for reading and writing.
42 |
43 | The filename parameter is the base filename for the underlying
44 | database. As a side-effect, an extension may be added to the
45 | filename and more than one file may be created. The optional flag
46 | parameter has the same interpretation as the flag parameter of
47 | dbm.open().
48 | """
49 | writeback = False
50 |
51 | from . import _dumbdbm_patched
52 | d = _dumbdbm_patched.open(filename, flag)
53 | return Shelf(ZlibMapping(d) if zlib is not None else d)
54 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Written by Patrick Guio
3 | #
4 |
5 | SUBDIRS = generate meta array
6 |
7 | blitzdir = $(includedir)/blitz
8 | generatedir = ./generate
9 |
10 | genheaders = matbops.h mathfunc.h matuops.h promote-old.h vecbops.cc vecuops.cc vecwhere.cc
11 |
12 | blitz_HEADERS = applics.h array-impl.h array-old.h array.h bench.cc bench.h \
13 | benchext.cc benchext.h blitz.h bzconfig.h bzdebug.h compiler.h \
14 | etbase.h extremum.h funcs.h indexexpr.h limits-hack.h listinit.h \
15 | matdiag.h matexpr.h matgen.h mathf2.h matltri.h matref.h matrix.cc \
16 | matrix.h matsymm.h mattoep.h matutri.h memblock.cc memblock.h \
17 | minmax.h mstruct.h numinquire.h numtrait.h ops.h prettyprint.h \
18 | promote.h rand-dunif.h rand-mt.h rand-normal.h rand-tt800.h rand-uniform.h \
19 | random.h randref.h range.h reduce.h shapecheck.h tau.h timer.h tiny.h \
20 | tinymat.h tinymatexpr.h tinymatio.cc tinyvec-et.h tinyvec.cc tinyvec.h \
21 | tinyvecio.cc tinyveciter.h traversal.cc traversal.h tuning.h tvcross.h \
22 | tvecglobs.h update.h vecaccum.cc vecall.cc vecany.cc vecbfn.cc \
23 | veccount.cc vecdelta.cc vecdot.cc vecexpr.h vecexprwrap.h vecglobs.cc \
24 | vecglobs.h vecio.cc veciter.h vecmax.cc vecmin.cc vecnorm.cc vecnorm1.cc \
25 | vecpick.cc vecpick.h vecpickio.cc vecpickiter.h vecsum.cc vector-et.h \
26 | vector.cc vector.h vecwhere.h wrap-climits.h zero.cc zero.h $(genheaders)
27 |
28 | EXTRA_HEADERS = apple/bzconfig.h intel/bzconfig.h ibm/bzconfig.h \
29 | compaq/bzconfig.h hp/bzconfig.h sgi/bzconfig.h gnu/bzconfig.h \
30 | pgi/bzconfig.h pathscale/bzconfig.h kai/bzconfig.h fujitsu/bzconfig.h
31 |
32 | nobase_blitz_HEADERS = $(COMPILER_SPECIFIC_HEADER)
33 |
34 | DISTCLEANFILES = apple/bzconfig.h intel/bzconfig.h ibm/bzconfig.h \
35 | compaq/bzconfig.h hp/bzconfig.h sgi/bzconfig.h gnu/bzconfig.h \
36 | pgi/bzconfig.h pathscale/bzconfig.h kai/bzconfig.h fujitsu/bzconfig.h
37 |
38 | clean-local:
39 | -rm -rf config.h
40 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/README:
--------------------------------------------------------------------------------
1 | Blitz header file notes
2 |
3 | 1) Some matrix headers are included in this release, but only because
4 | the Benchmark class needs them. Their design is not yet stable,
5 | and they are untested, so use them at your own peril.
6 |
7 | 2) A compiler-specific header file with configuration settings is included
8 | from the master header file . The compiler-specific
9 | header file is selected on the basis of preprocessor symbols. Since some
10 | C++ compilers (notably the IBM XL compiler for Darwin and for AIX systems)
11 | do not define a unique preprocessor symbol, we have added a -D option in
12 | the autoconf macro AC_CXX_FLAGS_PRESET (see file m4/ac_cxx_flags_preset.m4).
13 | Thus, we use the option -D__APPLE with xlc++ and -D__IBM with xlC.
14 | Please note that any user code must also be compiled with the same -D option
15 | in order to be compiled successfully with one of these compilers.
16 |
17 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array-old.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array-old.h Maximal include version of Array
3 | * Note: see for the class def.
4 | *
5 | * $Id: array-old.h 1414 2005-11-01 22:04:59Z cookedm $
6 | *
7 | * Copyright (C) 1997-2001 Todd Veldhuizen
8 | *
9 | * This code was relicensed under the modified BSD license for use in SciPy
10 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
11 | *
12 | *
13 | * Suggestions: blitz-dev@oonumerics.org
14 | * Bugs: blitz-bugs@oonumerics.org
15 | *
16 | * For more information, please see the Blitz++ Home Page:
17 | * http://oonumerics.org/blitz/
18 | *
19 | ***************************************************************************/
20 |
21 | #ifndef BZ_ARRAY_OLD_H
22 | #define BZ_ARRAY_OLD_H
23 |
24 | /*
25 | * used to include most of the Blitz++ library
26 | * functionality, totally ~ 120000 lines of source code. This
27 | * made for extremely slow compile times; processing #include
28 | * took gcc about 25 seconds on a 500 MHz pentium box.
29 | *
30 | * Much of this compile time was due to the old vector expression templates
31 | * implementation. Since this is not really needed for the Array
32 | * class, the headers were redesigned so that:
33 | *
34 | * #include is the old-style include, pulls in most
35 | * of Blitz++ including vector e.t.
36 | * #include pulls in much less of the library, and
37 | * in particular excludes the vector e.t. code
38 | *
39 | * With , one gets TinyVector expressions automatically.
40 | * With , one must now also include
41 | * to get TinyVector expressions.
42 | *
43 | * The implementation of Array has been moved to .
44 | */
45 |
46 | #include
47 | #include
48 |
49 | #endif // BZ_ARRAY_OLD_H
50 |
51 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array.h Minimal include version of Array
3 | *
4 | * $Id: array.h 1414 2005-11-01 22:04:59Z cookedm $
5 | *
6 | * Copyright (C) 1997-2000 Todd Veldhuizen
7 | *
8 | * This code was relicensed under the modified BSD license for use in SciPy
9 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
10 | *
11 | *
12 | * Suggestions: blitz-dev@oonumerics.org
13 | * Bugs: blitz-bugs@oonumerics.org
14 | *
15 | * For more information, please see the Blitz++ Home Page:
16 | * http://oonumerics.org/blitz/
17 | *
18 | ***************************************************************************/
19 |
20 | #ifndef BZ_ARRAY_ONLY_H
21 | #define BZ_ARRAY_ONLY_H
22 |
23 | // See comments in for an explanation of the new
24 | // headers arrangement.
25 |
26 | #include
27 |
28 | #endif // BZ_ARRAY_ONLY_H
29 |
30 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Written by Patrick Guio
3 | #
4 |
5 | arraydir = $(includedir)/blitz/array
6 | generatedir = ../generate
7 |
8 | genheaders = bops.cc uops.cc
9 |
10 | array_HEADERS = asexpr.h cartesian.h cgsolve.h complex.cc \
11 | convolve.cc convolve.h cycle.cc domain.h et.h eval.cc expr.h fastiter.h \
12 | funcs.h functorExpr.h geometry.h indirect.h interlace.cc io.cc iter.h map.h \
13 | methods.cc misc.cc multi.h newet-macros.h \
14 | newet.h ops.cc ops.h reduce.cc reduce.h resize.cc shape.h slice.h slicing.cc \
15 | stencil-et.h stencilops.h stencils.cc stencils.h storage.h where.h zip.h \
16 | $(genheaders)
17 |
18 | $(genheaders):
19 | cd $(generatedir) ; $(MAKE) generate-headers
20 |
21 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/asexpr.h:
--------------------------------------------------------------------------------
1 | // -*- C++ -*-
2 | /***************************************************************************
3 | * blitz/array/asexpr.h Declaration of the asExpr helper functions
4 | *
5 | * Copyright (C) 1997-2001 Todd Veldhuizen
6 | *
7 | * This code was relicensed under the modified BSD license for use in SciPy
8 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
9 | *
10 | *
11 | * Suggestions: blitz-dev@oonumerics.org
12 | * Bugs: blitz-bugs@oonumerics.org
13 | *
14 | * For more information, please see the Blitz++ Home Page:
15 | * http://oonumerics.org/blitz/
16 | *
17 | ***************************************************************************/
18 | #ifndef BZ_ARRAYASEXPR_H
19 | #define BZ_ARRAYASEXPR_H
20 |
21 | #ifndef BZ_ARRAY_H
22 | #error must be included via
23 | #endif
24 |
25 | BZ_NAMESPACE(blitz)
26 |
27 | // The traits class asExpr converts arbitrary things to
28 | // expression templatable operands.
29 |
30 | // Default to scalar.
31 |
32 | template
33 | struct asExpr {
34 | typedef _bz_ArrayExprConstant T_expr;
35 | static T_expr getExpr(const T& x) { return T_expr(x); }
36 | };
37 |
38 | // Already an expression template term
39 |
40 | template
41 | struct asExpr<_bz_ArrayExpr > {
42 | typedef _bz_ArrayExpr T_expr;
43 | static const T_expr& getExpr(const T_expr& x) { return x; }
44 | };
45 |
46 | // An array operand
47 |
48 | template
49 | struct asExpr > {
50 | typedef FastArrayIterator T_expr;
51 | static T_expr getExpr(const Array& x) { return x.beginFast(); }
52 | };
53 |
54 | // Index placeholder
55 |
56 | template
57 | struct asExpr > {
58 | typedef IndexPlaceholder T_expr;
59 | static T_expr getExpr(T_expr x) { return x; }
60 | };
61 |
62 | #ifdef BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS
63 |
64 | // A traits class that provides the return type of a binary operation.
65 |
66 | template class OP, typename O1>
67 | struct BzUnaryExprResult {
68 | typedef _bz_ArrayExpr<_bz_ArrayExprUnaryOp<
69 | typename asExpr::T_expr,
70 | OP::T_expr::T_numtype> > > T_result;
71 | };
72 |
73 | template class OP,
74 | typename O1, typename O2>
75 | struct BzBinaryExprResult {
76 | typedef _bz_ArrayExpr<_bz_ArrayExprBinaryOp<
77 | typename asExpr::T_expr,
78 | typename asExpr::T_expr,
79 | OP::T_expr::T_numtype,
80 | typename asExpr::T_expr::T_numtype> > > T_result;
81 | };
82 |
83 | template class OP,
84 | typename O1, typename O2, typename O3>
85 | struct BzTernaryExprResult {
86 | typedef _bz_ArrayExpr<_bz_ArrayExprTernaryOp<
87 | typename asExpr::T_expr,
88 | typename asExpr::T_expr,
89 | typename asExpr::T_expr,
90 | OP::T_expr::T_numtype,
91 | typename asExpr::T_expr::T_numtype,
92 | typename asExpr::T_expr::T_numtype> > > T_result;
93 | };
94 |
95 | #endif /* BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS */
96 |
97 | BZ_NAMESPACE_END
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/complex.cc:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/complex.cc Special functions for complex arrays
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ****************************************************************************/
17 | #ifndef BZ_ARRAYCOMPLEX_CC
18 | #define BZ_ARRAYCOMPLEX_CC
19 |
20 | // Special functions for complex arrays
21 |
22 | #ifndef BZ_ARRAY_H
23 | #error must be included via
24 | #endif
25 |
26 | BZ_NAMESPACE(blitz)
27 |
28 | #ifdef BZ_HAVE_COMPLEX
29 |
30 | template
31 | inline Array real(const Array,N_rank>& A)
32 | {
33 | return A.extractComponent(T_numtype(), 0, 2);
34 | }
35 |
36 | template
37 | inline Array imag(const Array,N_rank>& A)
38 | {
39 | return A.extractComponent(T_numtype(), 1, 2);
40 | }
41 |
42 |
43 | #endif
44 |
45 | BZ_NAMESPACE_END
46 |
47 | #endif // BZ_ARRAYCOMPLEX_CC
48 |
49 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/convolve.cc:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/convolve.cc One-dimensional convolution
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ****************************************************************************/
17 |
18 | #ifndef BZ_ARRAY_CONVOLVE_CC
19 | #define BZ_ARRAY_CONVOLVE_CC
20 |
21 | BZ_NAMESPACE(blitz)
22 |
23 | template
24 | Array convolve(const Array& B, const Array& C)
25 | {
26 | int Bl = B.lbound(0), Bh = B.ubound(0);
27 | int Cl = C.lbound(0), Ch = C.ubound(0);
28 |
29 | int lbound = Bl + Cl;
30 | int ubound = Bh + Ch;
31 |
32 | Array A(Range(lbound,ubound));
33 |
34 | for (int i=lbound; i <= ubound; ++i)
35 | {
36 | int jl = i - Ch;
37 | if (jl < Bl)
38 | jl = Bl;
39 |
40 | int jh = i - Cl;
41 | if (jh > Bh)
42 | jh = Bh;
43 |
44 | T result = 0;
45 | for (int j=jl; j <= jh; ++j)
46 | result += B(j) * C(i-j);
47 |
48 | A(i) = result;
49 | }
50 |
51 | return A;
52 | }
53 |
54 | BZ_NAMESPACE_END
55 |
56 | #endif // BZ_ARRAY_CONVOLVE_CC
57 |
58 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/convolve.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/convolve.h One-dimensional convolution
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ****************************************************************************/
17 | #ifndef BZ_ARRAY_CONVOLVE_H
18 | #define BZ_ARRAY_CONVOLVE_H
19 |
20 | #ifndef BZ_ARRAY_H
21 | #error must be included after
22 | #endif
23 |
24 | BZ_NAMESPACE(blitz)
25 |
26 | template
27 | Array convolve(const Array& B, const Array& C);
28 |
29 | BZ_NAMESPACE_END
30 |
31 | #include
32 |
33 | #endif // BZ_ARRAY_CONVOLVE_H
34 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/cycle.cc:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/cycle.cc Cycle arrays for time-stepping of PDEs.
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ****************************************************************************/
17 | #ifndef BZ_ARRAYCYCLE_CC
18 | #define BZ_ARRAYCYCLE_CC
19 |
20 | #ifndef BZ_ARRAY_H
21 | #error must be included via
22 | #endif
23 |
24 | BZ_NAMESPACE(blitz)
25 |
26 | template
27 | void cycleArrays(Array& a, Array& b)
28 | {
29 | Array tmp(a);
30 | a.reference(b);
31 | b.reference(tmp);
32 | }
33 |
34 | template
35 | void cycleArrays(Array& a, Array& b,
36 | Array& c)
37 | {
38 | Array tmp(a);
39 | a.reference(b);
40 | b.reference(c);
41 | c.reference(tmp);
42 | }
43 |
44 | template
45 | void cycleArrays(Array& a, Array& b,
46 | Array& c, Array& d)
47 | {
48 | Array tmp(a);
49 | a.reference(b);
50 | b.reference(c);
51 | c.reference(d);
52 | d.reference(tmp);
53 | }
54 |
55 | template
56 | void cycleArrays(Array& a, Array& b,
57 | Array& c, Array& d,
58 | Array& e)
59 | {
60 | Array tmp(a);
61 | a.reference(b);
62 | b.reference(c);
63 | c.reference(d);
64 | d.reference(e);
65 | e.reference(tmp);
66 | }
67 |
68 | BZ_NAMESPACE_END
69 |
70 | #endif // BZ_ARRAYCYCLE_CC
71 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/et.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/et.h Include expression templates implementation for arrays
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ****************************************************************************/
17 | #ifndef BZ_ARRAY_ET_H
18 | #define BZ_ARRAY_ET_H
19 |
20 | #ifdef BZ_NEW_EXPRESSION_TEMPLATES
21 | #include // Expression templates
22 | #else
23 | #include // Expression templates, two operands
24 | #include // Expression templates, math functions
25 | #include // Expression templates, miscellaneous
26 | #endif
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/geometry.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/geometry.h Basic mapping from Array to physical geometry,
3 | * used for some stencil operations.
4 | *
5 | * Copyright (C) 1997-2001 Todd Veldhuizen
6 | *
7 | * This code was relicensed under the modified BSD license for use in SciPy
8 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
9 | *
10 | *
11 | * Suggestions: blitz-dev@oonumerics.org
12 | * Bugs: blitz-bugs@oonumerics.org
13 | *
14 | * For more information, please see the Blitz++ Home Page:
15 | * http://oonumerics.org/blitz/
16 | *
17 | ****************************************************************************/
18 | #ifndef BZ_GEOMETRY_H
19 | #define BZ_GEOMETRY_H
20 |
21 | #ifndef BZ_ARRAY_H
22 | #error must be included after
23 | #endif
24 |
25 | BZ_NAMESPACE(blitz)
26 |
27 | typedef double T_defaultSpatialCoordinate;
28 |
29 | template
30 | class UniformOrthoGeometry {
31 | public:
32 | };
33 |
34 | template
35 | class UniformCubicGeometry {
36 | T h_;
37 | T recip_h_;
38 | T recip2_h_;
39 | T recip3_h_;
40 | TinyVector zero_;
41 |
42 | public:
43 | typedef T T_coord;
44 |
45 | UniformCubicGeometry()
46 | {
47 | h_ = 0.0;
48 | recip_h_ = 0.0;
49 | recip2_h_ = 0.0;
50 | recip3_h_ = 0.0;
51 | zero_ = 0.0;
52 | }
53 |
54 | UniformCubicGeometry(T spatialStep)
55 | {
56 | h_ = spatialStep;
57 | zero_ = T(0);
58 | setup();
59 | }
60 |
61 | UniformCubicGeometry(T spatialStep, TinyVector zeroCoordinates)
62 | {
63 | h_ = spatialStep;
64 | zero_ = zeroCoordinates;
65 | setup();
66 | }
67 |
68 | TinyVector toSpatial(TinyVector logicalCoord) const
69 | {
70 | return zero_ + h_ * logicalCoord;
71 | }
72 |
73 | T spatialStep() const
74 | { return h_; }
75 |
76 | T recipSpatialStep() const
77 | { return recip_h_; }
78 |
79 | T recipSpatialStepPow2() const
80 | { return recip2_h_; }
81 |
82 | private:
83 | void setup()
84 | {
85 | recip_h_ = 1.0 / h_;
86 | recip2_h_ = 1.0 / pow2(h_);
87 | recip3_h_ = 1.0 / pow3(h_);
88 | }
89 | };
90 |
91 | template
92 | class TensorProductGeometry {
93 | public:
94 | };
95 |
96 | BZ_NAMESPACE_END
97 |
98 | #endif // BZ_GEOMETRY_H
99 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/multi.h:
--------------------------------------------------------------------------------
1 | // -*- C++ -*-
2 | /***************************************************************************
3 | * blitz/array/multi.h Support for multicomponent arrays
4 | *
5 | * Copyright (C) 1997-2001 Todd Veldhuizen
6 | *
7 | * This code was relicensed under the modified BSD license for use in SciPy
8 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
9 | *
10 | *
11 | * Suggestions: blitz-dev@oonumerics.org
12 | * Bugs: blitz-bugs@oonumerics.org
13 | *
14 | * For more information, please see the Blitz++ Home Page:
15 | * http://oonumerics.org/blitz/
16 | *
17 | ****************************************************************************/
18 | #ifndef BZ_ARRAYMULTI_H
19 | #define BZ_ARRAYMULTI_H
20 |
21 | #ifndef BZ_ARRAY_H
22 | #error must be included via
23 | #endif
24 |
25 | BZ_NAMESPACE(blitz)
26 |
27 | /*
28 | * The multicomponent_traits class provides a mapping from multicomponent
29 | * tuples to the element type they contain. For example:
30 | *
31 | * multicomponent_traits >::T_numtype is float,
32 | * multicomponent_traits >::T_numtype is int.
33 | *
34 | * This is used to support Array::operator[], which extracts components
35 | * from a multicomponent array.
36 | */
37 |
38 | // By default, produce a harmless component type, and zero components.
39 | template
40 | struct multicomponent_traits {
41 | typedef T_component T_element;
42 | static const int numComponents = 0;
43 | };
44 |
45 | // TinyVector
46 | template
47 | struct multicomponent_traits > {
48 | typedef T_numtype T_element;
49 | static const int numComponents = N_rank;
50 | };
51 |
52 | #ifdef BZ_HAVE_COMPLEX
53 | // complex
54 | template
55 | struct multicomponent_traits > {
56 | typedef T T_element;
57 | static const int numComponents = 2;
58 | };
59 | #endif
60 |
61 | // This macro is provided so that users can register their own
62 | // multicomponent types.
63 |
64 | #define BZ_DECLARE_MULTICOMPONENT_TYPE(T_tuple,T,N) \
65 | BZ_NAMESPACE(blitz) \
66 | template<> \
67 | struct multicomponent_traits { \
68 | typedef T T_element; \
69 | static const int numComponents = N; \
70 | }; \
71 | BZ_NAMESPACE_END
72 |
73 | BZ_NAMESPACE_END
74 |
75 | #endif // BZ_ARRAYMULTI_H
76 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/newet.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/newet.h Gang include of new expression templates implementation
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ****************************************************************************/
17 | #ifndef BZ_ARRAY_NEWET_H
18 | #define BZ_ARRAY_NEWET_H
19 |
20 | // Gang include of new expression templates implementation.
21 |
22 | #include
23 | #include
24 |
25 | // ET support for functors acting on Arrays
26 |
27 | #include
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/shape.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/array/shape.h
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ****************************************************************************/
17 | #ifndef BZ_ARRAYSHAPE_H
18 | #define BZ_ARRAYSHAPE_H
19 |
20 | #ifndef BZ_ARRAY_H
21 | #error must be included via
22 | #endif
23 |
24 | BZ_NAMESPACE(blitz)
25 |
26 | /*
27 | * These routines make it easier to create shape parameters on
28 | * the fly: instead of having to write
29 | *
30 | * A.resize(TinyVector(8,8,8,12));
31 | *
32 | * you can just say
33 | *
34 | * A.resize(shape(8,8,8,12));
35 | *
36 | */
37 | inline TinyVector shape(int n1)
38 | { return TinyVector(n1); }
39 |
40 | inline TinyVector shape(int n1, int n2)
41 | { return TinyVector(n1,n2); }
42 |
43 | inline TinyVector shape(int n1, int n2, int n3)
44 | { return TinyVector(n1,n2,n3); }
45 |
46 | inline TinyVector shape(int n1, int n2, int n3, int n4)
47 | { return TinyVector(n1,n2,n3,n4); }
48 |
49 | inline TinyVector shape(int n1, int n2, int n3, int n4,
50 | int n5)
51 | { return TinyVector(n1,n2,n3,n4,n5); }
52 |
53 | inline TinyVector shape(int n1, int n2, int n3, int n4,
54 | int n5, int n6)
55 | { return TinyVector(n1,n2,n3,n4,n5,n6); }
56 |
57 | inline TinyVector shape(int n1, int n2, int n3, int n4,
58 | int n5, int n6, int n7)
59 | { return TinyVector(n1,n2,n3,n4,n5,n6,n7); }
60 |
61 | inline TinyVector shape(int n1, int n2, int n3, int n4,
62 | int n5, int n6, int n7, int n8)
63 | { return TinyVector(n1,n2,n3,n4,n5,n6,n7,n8); }
64 |
65 | inline TinyVector shape(int n1, int n2, int n3, int n4,
66 | int n5, int n6, int n7, int n8, int n9)
67 | { return TinyVector(n1,n2,n3,n4,n5,n6,n7,n8,n9); }
68 |
69 | inline TinyVector shape(int n1, int n2, int n3, int n4,
70 | int n5, int n6, int n7, int n8, int n9, int n10)
71 | { return TinyVector(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10); }
72 |
73 | inline TinyVector shape(int n1, int n2, int n3, int n4,
74 | int n5, int n6, int n7, int n8, int n9, int n10, int n11)
75 | { return TinyVector(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11); }
76 |
77 | BZ_NAMESPACE_END
78 |
79 | #endif // BZ_ARRAYSHAPE_H
80 |
81 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/array/zip.h:
--------------------------------------------------------------------------------
1 | // -*- C++ -*-
2 | /***************************************************************************
3 | * blitz/array/zip.h "zip" scalar arrays into a multicomponent array expr
4 | *
5 | * Copyright (C) 1997-2001 Todd Veldhuizen
6 | *
7 | * This code was relicensed under the modified BSD license for use in SciPy
8 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
9 | *
10 | *
11 | * Suggestions: blitz-dev@oonumerics.org
12 | * Bugs: blitz-bugs@oonumerics.org
13 | *
14 | * For more information, please see the Blitz++ Home Page:
15 | * http://oonumerics.org/blitz/
16 | *
17 | ****************************************************************************/
18 | #ifndef BZ_ARRAYZIP_H
19 | #define BZ_ARRAYZIP_H
20 |
21 | #ifndef BZ_ARRAY_H
22 | #error must be included via
23 | #endif
24 |
25 | BZ_NAMESPACE(blitz)
26 |
27 | template
28 | struct Zip2 {
29 | typedef P_component T_numtype;
30 |
31 | static inline T_numtype apply(T1 a, T2 b)
32 | { return T_numtype(a,b); }
33 |
34 | template
35 | static inline void prettyPrint(BZ_STD_SCOPE(string) &str,
36 | prettyPrintFormat& format, const T_left& t1,
37 | const T_right& t2)
38 | {
39 | str += "zip(";
40 | t1.prettyPrint(str, format);
41 | str += ",";
42 | t2.prettyPrint(str, format);
43 | str += ")";
44 | }
45 | };
46 |
47 | template
48 | inline _bz_ArrayExpr<_bz_ArrayExprBinaryOp<
49 | _bz_typename asExpr::T_expr,
50 | _bz_typename asExpr::T_expr,
51 | Zip2::T_expr::T_numtype,
53 | _bz_typename asExpr::T_expr::T_numtype> > >
54 | zip(const T1& a, const T2& b, T_component)
55 | {
56 | return _bz_ArrayExpr<_bz_ArrayExprBinaryOp<
57 | _bz_typename asExpr::T_expr,
58 | _bz_typename asExpr::T_expr,
59 | Zip2::T_expr::T_numtype,
61 | _bz_typename asExpr::T_expr::T_numtype> > >(a,b);
62 | }
63 |
64 | BZ_NAMESPACE_END
65 |
66 | #endif // BZ_ARRAYZIP_H
67 |
68 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/bench.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/bench.h Benchmark classes
3 | *
4 | * Copyright (C) 1997-2001 Todd Veldhuizen
5 | *
6 | * This code was relicensed under the modified BSD license for use in SciPy
7 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
8 | *
9 | *
10 | * Suggestions: blitz-dev@oonumerics.org
11 | * Bugs: blitz-bugs@oonumerics.org
12 | *
13 | * For more information, please see the Blitz++ Home Page:
14 | * http://oonumerics.org/blitz/
15 | *
16 | ***************************************************************************/
17 |
18 | #ifndef BZ_BENCH_H
19 | #define BZ_BENCH_H
20 |
21 | #ifndef BZ_MATRIX_H
22 | #include
23 | #endif
24 |
25 | #ifndef BZ_TIMER_H
26 | #include
27 | #endif
28 |
29 | #include
30 |
31 | BZ_NAMESPACE(blitz)
32 |
33 | // Forward declaration
34 | template
35 | class BenchmarkImplementation;
36 |
37 |
38 | // Declaration of class Benchmark
39 | // The template parameter T is the parameter type which is varied in
40 | // the benchmark. Typically T will be an unsigned, and will represent
41 | // the length of a vector, size of an array, etc.
42 |
43 | template
44 | class Benchmark {
45 |
46 | public:
47 | typedef P_parameter T_parameter;
48 |
49 | Benchmark(unsigned numImplementations);
50 |
51 | ~Benchmark();
52 |
53 | void addImplementation(BenchmarkImplementation*
54 | implementation);
55 |
56 | void run(ostream& log = cout);
57 |
58 | double getMflops(unsigned implementation, unsigned setting) const;
59 |
60 | double getRate(unsigned implementation, unsigned setting) const;
61 |
62 | void saveMatlabGraph(const char* filename) const;
63 |
64 | public:
65 | // Virtual functions
66 |
67 | virtual const char* description() const
68 | { return ""; }
69 |
70 | virtual const char* parameterDescription() const
71 | { return "Vector length"; }
72 |
73 | virtual unsigned numParameterSettings() const
74 | { return 19; }
75 |
76 | virtual T_parameter getParameterSetting(unsigned i) const
77 | { return ::pow(10.0, (i+1)/4.0); }
78 |
79 | virtual long getIterationSetting(unsigned i) const
80 | { return 1000000L / getParameterSetting(i); }
81 |
82 | private:
83 | Benchmark(const Benchmark&) { }
84 | void operator=(const Benchmark&) { }
85 |
86 | enum { uninitialized, initialized, running, done } state_;
87 |
88 | unsigned numImplementations_;
89 | unsigned numStoredImplementations_;
90 |
91 | BenchmarkImplementation** implementations_;
92 |
93 | Matrix rates_; // Iterations per second array
94 | Matrix Mflops_;
95 | };
96 |
97 | template
98 | class BenchmarkImplementation {
99 |
100 | public:
101 | typedef P_parameter T_parameter;
102 |
103 | virtual void initialize(P_parameter parameter) { }
104 |
105 | virtual void done() { }
106 |
107 | virtual const char* implementationName() const
108 | { return ""; }
109 |
110 | virtual void run(long iterations) = 0;
111 |
112 | virtual void runOverhead(long iterations)
113 | {
114 | for (long i=0; i < iterations; ++i)
115 | {
116 | }
117 | };
118 |
119 | virtual void tickle() { }
120 |
121 | virtual long flopsPerIteration() const
122 | { return 0; }
123 | };
124 |
125 | BZ_NAMESPACE_END
126 |
127 | #include
128 |
129 | #endif // BZ_BENCH_H
130 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/benchext.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/benchext.h BenchmarkExt classes (Benchmarks with external
3 | * control)
4 | *
5 | * Copyright (C) 1997-2001 Todd Veldhuizen
6 | *
7 | * This code was relicensed under the modified BSD license for use in SciPy
8 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
9 | *
10 | *
11 | * Suggestions: blitz-dev@oonumerics.org
12 | * Bugs: blitz-bugs@oonumerics.org
13 | *
14 | * For more information, please see the Blitz++ Home Page:
15 | * http://oonumerics.org/blitz/
16 | *
17 | ***************************************************************************/
18 |
19 | #ifndef BZ_BENCHEXT_H
20 | #define BZ_BENCHEXT_H
21 |
22 | #ifndef BZ_MATRIX_H
23 | #include
24 | #endif
25 |
26 | #ifndef BZ_TIMER_H
27 | #include
28 | #endif
29 |
30 | #include
31 |
32 | // NEEDS_WORK: replace use of const char* with , once standard
33 | // library is widely supported.
34 |
35 | BZ_NAMESPACE(blitz)
36 |
37 | // Declaration of class BenchmarkExt
38 | // The template parameter T is the parameter type which is varied in
39 | // the benchmark. Typically T will be an unsigned, and will represent
40 | // the length of a vector, size of an array, etc.
41 |
42 | template
43 | class BenchmarkExt {
44 |
45 | public:
46 | typedef P_parameter T_parameter;
47 |
48 | BenchmarkExt(const char* description, int numImplementations);
49 |
50 | ~BenchmarkExt();
51 |
52 | void setNumParameters(int numParameters);
53 | void setParameterVector(Vector parms);
54 | void setParameterDescription(const char* string);
55 | void setIterations(Vector iters);
56 | void setFlopsPerIteration(Vector flopsPerIteration);
57 | void setRateDescription(const char* string);
58 |
59 | void beginBenchmarking();
60 |
61 | void beginImplementation(const char* description);
62 |
63 | bool doneImplementationBenchmark() const;
64 |
65 | T_parameter getParameter() const;
66 | long getIterations() const;
67 |
68 | inline void start();
69 | inline void stop();
70 |
71 | void startOverhead();
72 | void stopOverhead();
73 |
74 | void endImplementation();
75 |
76 | void endBenchmarking();
77 |
78 | double getMflops(unsigned implementation, unsigned parameterNum) const;
79 |
80 | void saveMatlabGraph(const char* filename, const char* graphType="semilogx") const;
81 |
82 | protected:
83 | BenchmarkExt(const BenchmarkExt&) { }
84 | void operator=(const BenchmarkExt&) { }
85 |
86 | enum { initializing, benchmarking, benchmarkingImplementation,
87 | running, runningOverhead, done } state_;
88 |
89 | unsigned numImplementations_;
90 | unsigned implementationNumber_;
91 |
92 | const char* description_;
93 | Vector implementationDescriptions_;
94 |
95 | Matrix times_; // Elapsed time
96 |
97 | Vector parameters_;
98 | Vector iterations_;
99 | Vector flopsPerIteration_;
100 |
101 | Timer timer_;
102 | Timer overheadTimer_;
103 |
104 | const char* parameterDescription_;
105 | const char* rateDescription_;
106 |
107 | unsigned numParameters_;
108 | unsigned parameterNumber_;
109 | };
110 |
111 | BZ_NAMESPACE_END
112 |
113 | #include
114 |
115 | #endif // BZ_BENCHEXT_H
116 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/blitz.h:
--------------------------------------------------------------------------------
1 | // -*- C++ -*-
2 | /***************************************************************************
3 | * blitz/blitz.h Includes all the important header files
4 | *
5 | * $Id: blitz.h 1414 2005-11-01 22:04:59Z cookedm $
6 | *
7 | * Copyright (C) 1997-2001 Todd Veldhuizen
8 | *
9 | * This code was relicensed under the modified BSD license for use in SciPy
10 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
11 | *
12 | *
13 | * Suggestions: blitz-dev@oonumerics.org
14 | * Bugs: blitz-bugs@oonumerics.org
15 | *
16 | * For more information, please see the Blitz++ Home Page:
17 | * http://oonumerics.org/blitz/
18 | *
19 | ***************************************************************************/
20 |
21 | #ifndef BZ_BLITZ_H
22 | #define BZ_BLITZ_H
23 |
24 | /*
25 | * These symbols allow use of the IEEE and System V math libraries
26 | * (libm.a and libmsaa.a) on some platforms.
27 | */
28 |
29 | #ifdef BZ_ENABLE_XOPEN_SOURCE
30 | #ifndef _ALL_SOURCE
31 | #define _ALL_SOURCE
32 | #endif
33 | #ifndef _XOPEN_SOURCE
34 | #define _XOPEN_SOURCE
35 | #endif
36 | #ifndef _XOPEN_SOURCE_EXTENDED
37 | #define _XOPEN_SOURCE_EXTENDED 1
38 | #endif
39 | #endif
40 |
41 | #include // Compiler-specific directives
42 | #include // Performance tuning
43 | #include // Profiling
44 |
45 | #include
46 | #include // sprintf, etc.
47 |
48 | #ifdef BZ_HAVE_STD
49 | #include
50 | #include
51 | #else
52 | #include
53 | #include
54 | #endif
55 |
56 | #ifdef BZ_MATH_FN_IN_NAMESPACE_STD
57 | #include
58 | #else
59 | #include
60 | #endif
61 |
62 | #ifdef BZ_HAVE_COMPLEX
63 | #include
64 | #endif
65 |
66 | #define BZ_THROW // Needed in
67 |
68 | BZ_NAMESPACE(blitz)
69 |
70 | #ifdef BZ_HAVE_STD
71 | BZ_USING_NAMESPACE(std)
72 | #endif
73 |
74 | #ifdef BZ_GENERATE_GLOBAL_INSTANCES
75 | #define _bz_global
76 | #define BZ_GLOBAL_INIT(X) =X
77 | #else
78 | #define _bz_global extern
79 | #define BZ_GLOBAL_INIT(X)
80 | #endif
81 |
82 | BZ_NAMESPACE_END
83 |
84 | /*
85 | * Thread safety issues.
86 | * Compiling with -pthread under gcc, or -mt under solaris,
87 | * should automatically turn on BZ_THREADSAFE.
88 | */
89 | #ifdef _REENTRANT
90 | #ifndef BZ_THREADSAFE
91 | #define BZ_THREADSAFE
92 | #endif
93 | #endif
94 |
95 | /*
96 | * Which mutex implementation should be used for synchronizing
97 | * reference counts. Currently only one option -- pthreads.
98 | */
99 | #ifdef BZ_THREADSAFE
100 | #define BZ_THREADSAFE_USE_PTHREADS
101 | #endif
102 |
103 | #ifdef BZ_THREADSAFE_USE_PTHREADS
104 | #include
105 |
106 | #define BZ_MUTEX_DECLARE(name) mutable pthread_mutex_t name;
107 | #define BZ_MUTEX_INIT(name) pthread_mutex_init(&name,NULL);
108 | #define BZ_MUTEX_LOCK(name) pthread_mutex_lock(&name);
109 | #define BZ_MUTEX_UNLOCK(name) pthread_mutex_unlock(&name);
110 | #define BZ_MUTEX_DESTROY(name) pthread_mutex_destroy(&name);
111 | #else
112 | #define BZ_MUTEX_DECLARE(name)
113 | #define BZ_MUTEX_INIT(name)
114 | #define BZ_MUTEX_LOCK(name)
115 | #define BZ_MUTEX_UNLOCK(name)
116 | #define BZ_MUTEX_DESTROY(name)
117 | #endif
118 |
119 | #include // Debugging macros
120 |
121 | #endif // BZ_BLITZ_H
122 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/bzconfig.h:
--------------------------------------------------------------------------------
1 | /* Select the compiler-specific config.h header file */
2 | #ifndef BZCONFIG_H
3 | #define BZCONFIG_H
4 |
5 | #if defined(__APPLE)
6 | /* IBM xlc compiler for Darwin */
7 | #include
8 |
9 | #elif defined(__ICC)
10 | /* Intel icc compiler */
11 | #include
12 |
13 | #elif defined(_MSC_VER)
14 | /* Microsoft VS.NET compiler */
15 | #include
16 |
17 | #elif defined(__IBM)
18 | /* IBM xlC compiler */
19 | #include
20 |
21 | #elif defined(__DECCXX)
22 | /* Compaq cxx compiler */
23 | #include
24 |
25 | #elif defined(__HP_aCC)
26 | /* HP aCC compiler */
27 | #include
28 |
29 | #elif defined(_SGI_COMPILER_VERSION)
30 | /* SGI CC compiler */
31 | #include
32 |
33 | #elif defined(__SUNPRO_CC)
34 | /* SunPRO CC compiler */
35 | #include
36 |
37 | #elif defined(__GNUC__)
38 | /* GNU gcc compiler */
39 | #include
40 |
41 | #elif defined(__PGI)
42 | /* PGI pgCC compiler */
43 | #include
44 |
45 | #elif defined(__KCC)
46 | /* KAI KCC compiler */
47 | #include
48 |
49 | #elif defined(__FUJITSU)
50 | /* Fujitsu FCC compiler */
51 | #include
52 |
53 | #elif defined(__PATHSCALE)
54 | /* Pathscale pathCC compiler */
55 | #include
56 |
57 | /* Add other compilers here */
58 |
59 | #else
60 | #error Unknown compiler
61 | #endif
62 |
63 | #endif /* BZCONFIG_H */
64 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/etbase.h:
--------------------------------------------------------------------------------
1 | // -*- C++ -*-
2 | /***************************************************************************
3 | * blitz/etbase.h Declaration of the ETBase class
4 | *
5 | * $Id: etbase.h 1414 2005-11-01 22:04:59Z cookedm $
6 | *
7 | * Copyright (C) 1997-2001 Todd Veldhuizen
8 | *
9 | * This code was relicensed under the modified BSD license for use in SciPy
10 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
11 | *
12 | *
13 | * Suggestions: blitz-dev@oonumerics.org
14 | * Bugs: blitz-bugs@oonumerics.org
15 | *
16 | * For more information, please see the Blitz++ Home Page:
17 | * http://oonumerics.org/blitz/
18 | *
19 | ***************************************************************************/
20 |
21 | #ifndef BZ_ETBASE_H
22 | #define BZ_ETBASE_H
23 |
24 | BZ_NAMESPACE(blitz)
25 |
26 | template
27 | class ETBase {
28 | public:
29 | ETBase()
30 | { }
31 |
32 | ETBase(const ETBase&)
33 | { }
34 |
35 | T& unwrap() { return static_cast(*this); }
36 |
37 | const T& unwrap() const { return static_cast(*this); }
38 | };
39 |
40 | BZ_NAMESPACE_END
41 |
42 | #endif // BZ_ETBASE_H
43 |
44 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/extremum.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/extremum.h Declaration of the Extremum class
3 | *
4 | * $Id: extremum.h 1414 2005-11-01 22:04:59Z cookedm $
5 | *
6 | * Copyright (C) 1997-2001 Todd Veldhuizen
7 | *
8 | * This code was relicensed under the modified BSD license for use in SciPy
9 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
10 | *
11 | *
12 | * Suggestions: blitz-dev@oonumerics.org
13 | * Bugs: blitz-bugs@oonumerics.org
14 | *
15 | * For more information, please see the Blitz++ Home Page:
16 | * http://oonumerics.org/blitz/
17 | *
18 | ***************************************************************************/
19 |
20 | #ifndef BZ_EXTREMUM_H
21 | #define BZ_EXTREMUM_H
22 |
23 | #ifndef BZ_BLITZ_H
24 | #include
25 | #endif
26 |
27 | BZ_NAMESPACE(blitz)
28 |
29 | // The Extremum class is used for returning extreme values and their
30 | // locations in a numeric container. It's a simple 2-tuple, with the
31 | // first element being the extreme value, and the send its location.
32 | // An object of type Extremum can be automatically converted to
33 | // the numeric type via operator T_numtype().
34 | template
35 | class Extremum {
36 | public:
37 | typedef P_numtype T_numtype;
38 | typedef P_index T_index;
39 |
40 | Extremum(T_numtype value, T_index index)
41 | : value_(value), index_(index)
42 | { }
43 |
44 | T_numtype value() const
45 | { return value_; }
46 |
47 | T_index index() const
48 | { return index_; }
49 |
50 | void setValue(T_numtype value)
51 | { value_ = value; }
52 |
53 | void setIndex(T_index index)
54 | { index_ = index; }
55 |
56 | operator T_numtype() const
57 | { return value_; }
58 |
59 | protected:
60 | T_numtype value_;
61 | T_index index_;
62 | };
63 |
64 | BZ_NAMESPACE_END
65 |
66 | #endif // BZ_EXTREMUM_H
67 |
68 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/generate/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Written by Patrick Guio
3 | #
4 |
5 | noinst_HEADERS = arroperands.h arroptuple.h bzfstream.h operands.h operands2.h optuple.h optuple2.h
6 |
7 | EXTRA_PROGRAMS = genarrbops genmathfunc genvecbops genarruops genmatuops \
8 | genvecuops genmatbops genpromote genvecwhere genvecbfn
9 |
10 | genarrbops_SOURCES = genarrbops.cpp
11 | genmathfunc_SOURCES = genmathfunc.cpp
12 | genvecbops_SOURCES = genvecbops.cpp
13 | genarruops_SOURCES = genarruops.cpp
14 | genmatuops_SOURCES = genmatuops.cpp
15 | genvecuops_SOURCES = genvecuops.cpp
16 | genmatbops_SOURCES = genmatbops.cpp
17 | genpromote_SOURCES = genpromote.cpp
18 | genvecwhere_SOURCES = genvecwhere.cpp
19 | genvecbfn_SOURCES = genvecbfn.cpp
20 |
21 | %.h:
22 | $(MAKE) $(AM_MAKEFLAGS) $(patsubst %.cpp,%$(EXEEXT),$<)
23 | ./$(patsubst %.cpp,%$(EXEEXT),$<)
24 |
25 | %.cc:
26 | $(MAKE) $(AM_MAKEFLAGS) $(patsubst %.cpp,%$(EXEEXT),$<)
27 | ./$(patsubst %.cpp,%$(EXEEXT),$<)
28 |
29 | $(top_srcdir)/blitz/array/bops.cc: genarrbops.cpp bzfstream.h arroperands.h arroptuple.h
30 | $(top_srcdir)/blitz/array/uops.cc: genarruops.cpp bzfstream.h arroperands.h arroptuple.h
31 | $(top_srcdir)/blitz/matbops.h: genmatbops.cpp bzfstream.h operands2.h optuple2.h
32 | $(top_srcdir)/blitz/mathfunc.h: genmathfunc.cpp
33 | $(top_srcdir)/blitz/matuops.h: genmatuops.cpp bzfstream.h operands2.h optuple2.h
34 | $(top_srcdir)/blitz/promote-old.h: genpromote.cpp
35 | $(top_srcdir)/blitz/vecbops.cc: genvecbops.cpp bzfstream.h operands.h optuple.h
36 | $(top_srcdir)/blitz/vecuops.cc: genvecuops.cpp bzfstream.h operands.h optuple.h
37 | $(top_srcdir)/blitz/vecwhere.cc: genvecwhere.cpp bzfstream.h operands.h optuple.h
38 | $(top_srcdir)/blitz/vecbfn.cc: genvecbfn.cpp bzfstream.h operands.h optuple.h
39 |
40 | generate-headers: $(top_srcdir)/blitz/array/bops.cc \
41 | $(top_srcdir)/blitz/array/uops.cc $(top_srcdir)/blitz/matbops.h \
42 | $(top_srcdir)/blitz/mathfunc.h $(top_srcdir)/blitz/matuops.h \
43 | $(top_srcdir)/blitz/promote-old.h $(top_srcdir)/blitz/vecbops.cc \
44 | $(top_srcdir)/blitz/vecuops.cc $(top_srcdir)/blitz/vecwhere.cc \
45 | $(top_srcdir)/blitz/vecbfn.cc
46 |
47 | all-am:
48 | $(MAKE) $(AM_MAKEFLAGS) generate-headers
49 |
50 | clean-local:
51 | -rm -rf cxx_repository ti_files ii_files $(EXTRA_PROGRAMS)
52 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/generate/bzfstream.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * blitz/generate/bzfstream.h Definition of the bzofstream class
3 | *
4 | * $Id: bzfstream.h 1413 2005-11-01 22:04:15Z cookedm $
5 | *
6 | * Copyright (C) 1997-2001 Todd Veldhuizen
7 | *
8 | * This code was relicensed under the modified BSD license for use in SciPy
9 | * by Todd Veldhuizen (see LICENSE.txt in the weave directory).
10 | *
11 | *
12 | * Suggestions: blitz-dev@oonumerics.org
13 | * Bugs: blitz-bugs@oonumerics.org
14 | *
15 | * For more information, please see the Blitz++ Home Page:
16 | * http://oonumerics.org/blitz/
17 | *
18 | ***************************************************************************/
19 |
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | class bzofstream : public std::ofstream {
26 |
27 | public:
28 | bzofstream(const char* filename, const char* description,
29 | const char* sourceFile, const char* mnemonic)
30 | : std::ofstream(filename)
31 | {
32 | (*this) <<
33 | "/***************************************************************************\n"
34 | " * blitz/" << filename << "\t" << description << std::endl <<
35 | " *\n"
36 | " * This code was relicensed under the modified BSD license for use in SciPy\n"
37 | " * by Todd Veldhuizen (see LICENSE.txt in the weave directory).\n"
38 | " *\n"
39 | " *\n"
40 | " * Suggestions: blitz-suggest@cybervision.com\n"
41 | " * Bugs: blitz-bugs@cybervision.com\n"
42 | " *\n"
43 | " * For more information, please see the Blitz++ Home Page:\n"
44 | " * http://seurat.uwaterloo.ca/blitz/\n"
45 | " *\n"
46 | " ***************************************************************************\n"
47 | " *\n"
48 | " */ "
49 | << std::endl << std::endl
50 | << "// Generated source file. Do not edit. " << std::endl
51 | << "// " << sourceFile << " " << __DATE__ << " " << __TIME__
52 | << std::endl << std::endl
53 | << "#ifndef " << mnemonic << std::endl
54 | << "#define " << mnemonic << std::endl << std::endl;
55 | }
56 |
57 | void include(const char* filename)
58 | {
59 | (*this) << "#include " << std::endl;
60 | }
61 |
62 | void beginNamespace()
63 | {
64 | (*this) << "BZ_NAMESPACE(blitz)" << std::endl << std::endl;
65 | }
66 |
67 | ~bzofstream()
68 | {
69 | (*this) << "BZ_NAMESPACE_END" << std::endl << std::endl
70 | << "#endif" << std::endl;
71 | }
72 |
73 | };
74 |
75 |
--------------------------------------------------------------------------------
/weave/blitz/blitz/generate/genpromote.cpp:
--------------------------------------------------------------------------------
1 | #include