<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brainfold &#187; pyeigen</title>
	<atom:link href="http://www.brainfold.org/blog/tag/pyeigen/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brainfold.org/blog</link>
	<description>On Python, game development and everything</description>
	<lastBuildDate>Sat, 15 May 2010 21:58:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Help needed</title>
		<link>http://www.brainfold.org/blog/2010/05/15/help-needed/</link>
		<comments>http://www.brainfold.org/blog/2010/05/15/help-needed/#comments</comments>
		<pubDate>Sat, 15 May 2010 21:58:53 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=297</guid>
		<description><![CDATA[While PyEigen 0.2 is mostly ready for release, I'm stuck on weird problems with GCC on both Windows (MinGW) and Linux. PyEigen compiles fine on Visual C++, but GCC gives different errors depending on the version. On GCC 4.4 I get these mysterious errors: source/iterator/matrix2fiterator.cpp:39: error: insufficient contextual information to determine type source/iterator/matrix2fiterator.cpp:40: error: insufficient [...]]]></description>
			<content:encoded><![CDATA[<p>While PyEigen 0.2 is mostly ready for release, I'm stuck on weird problems with GCC on both Windows (MinGW) and Linux. PyEigen compiles fine on Visual C++, but GCC gives different errors depending on the version. On GCC 4.4 I get these mysterious errors:</p>
<pre>source/iterator/matrix2fiterator.cpp:39: error: insufficient contextual information to determine type
source/iterator/matrix2fiterator.cpp:40: error: insufficient contextual information to determine type
source/iterator/matrix2fiterator.cpp:41: error: too many initializers for ‘PyTypeObject’</pre>
<p>On GCC 4.5, apparently every template function in PyEigen results in an undefined reference, even though the implementations are (or at least should be, as MSVC finds them) included in the object files. Frankly I don't have the faintest idea why this is happening. I even completely restructured the code to try if the (admittedly confusing) header relationships were to blame for the errors, but nothing changed.</p>
<p>If someone wants to help (pretty please) and try to figure out what's wrong, you can grab the code here: <a href="http://code.launchpad.net/~knarkles/pyeigen/trunk">http://code.launchpad.net/~knarkles/pyeigen/trunk</a>. You need the Python headers and Eigen 2 to compile; feel free to ask me for help on getting a build setup up an running.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/05/15/help-needed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PyEigen 0.2 feature complete</title>
		<link>http://www.brainfold.org/blog/2010/05/03/pyeigen-0-2-feature-complete/</link>
		<comments>http://www.brainfold.org/blog/2010/05/03/pyeigen-0-2-feature-complete/#comments</comments>
		<pubDate>Mon, 03 May 2010 07:43:57 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[numpy]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=292</guid>
		<description><![CDATA[After a couple of weeks of hiatus, the 0.2 release of PyEigen is now feature complete. What's left is some testing and documentation, then release. I postponed quaternions and transformations to 0.3 because variable-size matrices were plenty of work for a single release and single programmer already; I don't want too much time between releases [...]]]></description>
			<content:encoded><![CDATA[<p>After a couple of weeks of hiatus, the 0.2 release of PyEigen is now feature complete. What's left is some testing and documentation, then release. I postponed quaternions and transformations to 0.3 because variable-size matrices were plenty of work for a single release and single programmer already; I don't want too much time between releases at such an early stage. If I'm not too busy, PyEigen 0.2 should be released in a week or two.</p>
<p>I did some benchmarking on 1000x1000 matrices. Insanely, enabling SSE2 instructions speeded up that test case by 10x; I was expecting a 4x increase at most, since SSE instructions handle 4 times the data per instruction. NumPy is slightly faster for 1000x1000 matrix multiplication, but there's an obvious optimization in PyEigen that will hopefully make it faster again. That will have to wait for 0.3 though, since it's a bit tedious to implement. For those interested: there's an extra matrix copy in all PyEigen functions and operators that return a value, which I can probably optimize away.</p>
<p>BTW, if you want more frequent progress updates, you can follow my <a href="http://twitter.com/Knarkles">Twitter feed</a>. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/05/03/pyeigen-0-2-feature-complete/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PyEigen 0.2 teaser</title>
		<link>http://www.brainfold.org/blog/2010/03/29/pyeigen-0-2-teaser/</link>
		<comments>http://www.brainfold.org/blog/2010/03/29/pyeigen-0-2-teaser/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 15:47:19 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[pybindgen]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=277</guid>
		<description><![CDATA[I just want to assure everyone that development of PyEigen didn't stop at the 0.1 release and I've put many hours into the next release already. I have almost finished rewriting everything using C++ templates; might as well take advantage of C++ features since Eigen requires a C++ compiler anyway. Lines of code have been [...]]]></description>
			<content:encoded><![CDATA[<p>I just want to assure everyone that development of PyEigen didn't stop at the 0.1 release and I've put many hours into the next release already. I have almost finished rewriting everything using C++ templates; might as well take advantage of C++ features since Eigen requires a C++  compiler anyway. Lines of code have been cut almost in half and maintenance will be much easier in the future.  Here are some of the major upcoming features (subject to change, completed features will be in bold):</p>
<ul>
<li><strong>Python 3 support</strong></li>
<li><strong>Matrix iterators</strong></li>
<li><strong>Variable-size vectors and matrices</strong></li>
</ul>
<p>In other news, I just found about <a href="http://launchpad.net/pybindgen/">PyBindGen</a>, which looks very promising compared to other binding generators, and might be worth checking out for a future version of PyEigen. Can someone speak for or against it? I'm mostly worried about performance, since I want PyEigen to be as fast as possible; after all, that's the sole reason I started the whole project.</p>
<p><strong>Update (2010-03-30):</strong><br />
Matrix iterators done, slicing dropped (you can just convert to a list first).</p>
<p><strong>Update (2010-05-03):</strong><br />
Quaternions and transformations postponed to the next release, variable-size matrices done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/03/29/pyeigen-0-2-teaser/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PyEigen 0.1 released</title>
		<link>http://www.brainfold.org/blog/2010/03/24/pyeigen-0-1-released/</link>
		<comments>http://www.brainfold.org/blog/2010/03/24/pyeigen-0-1-released/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 08:09:38 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=261</guid>
		<description><![CDATA[PyEigen 0.1 has finally been released!  See the (still) very limited blog page, grab it at the Python Package Index and get involved at the Launchpad project page. Here's the announcement: I'm happy to announce PyEigen, a new linear algebra module for Python that's many times faster than existing solutions. Notably, PyEigen is about 10x [...]]]></description>
			<content:encoded><![CDATA[<p>PyEigen 0.1 has finally been released!  See the (still) very limited <a href="http://www.brainfold.org/blog/portfolio/pyeigen/">blog page</a>, grab it at the <a href="http://pypi.python.org/pypi/PyEigen/">Python Package Index</a> and get involved at the <a href="http://launchpad.net/pyeigen">Launchpad project page</a>.</p>
<p>Here's the announcement:</p>
<p>I'm happy to announce PyEigen, a new linear algebra module for Python that's many times faster than existing solutions. Notably, PyEigen is about 10x faster than NumPy for 4x4 matrix multiplication and 4x faster than cgkit 1.2.0, the fastest current solution.</p>
<p>Python Package Index:</p>
<p>http://pypi.python.org/pypi/PyEigen/</p>
<p>Launchpad project page:</p>
<p>http://launchpad.net/pyeigen</p>
<p>Development blog:</p>
<p>http://www.brainfold.org/blog</p>
<h3>About</h3>
<p>PyEigen is a Python wrapper for the C++ linear algebra library Eigen.</p>
<p>PyEigen is currently considered PRE-ALPHA quality software and has not been widely tested outside the unit tests. The API is not stable yet and might change between releases without warning. Testing and all kinds of feedback are welcome however! Compatibility reports with different operating systems, compilers and Python versions are especially welcome.</p>
<h3>Features</h3>
<p>The first release of PyEigen includes basic support for fixed-size vectors (2-4-dimensional) and matrices (2x2, 3x3 and 4x4).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/03/24/pyeigen-0-1-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PyEigen progress</title>
		<link>http://www.brainfold.org/blog/2010/03/20/pyeigen-progress/</link>
		<comments>http://www.brainfold.org/blog/2010/03/20/pyeigen-progress/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 10:05:55 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=226</guid>
		<description><![CDATA[Development of PyEigen is going really well. All the features I want for a 0.1 release are basically done and there's just testing and documentation left now. For version 0.1 documentation I'll just write some docstrings and a readme file, but I want full unit tests for the module. Vectors and matrices are really low-level [...]]]></description>
			<content:encoded><![CDATA[<p>Development of PyEigen is going really well. All the features I want for a 0.1 release are basically done and there's just testing and documentation left now. For version 0.1 documentation I'll just write some docstrings and a readme file, but I want full unit tests for the module. Vectors and matrices are really low-level stuff and writing C code is quite prone to errors, so I want to make sure everything works and it can't be crashed.</p>
<p>I'd say you can expect a first release in about a week. It's going to include support for fixed-size matrices (2x2, 3x3 and 4x4) and column and row vectors (2-, 3- and 4-dimensional). Major game development -related features missing include transformations and quaternions; they are probably coming in the 0.2 release along with coefficient-wise (aka element-wise) operations. I'll probably add support for variable-size matrices and vectors later. Compatibility with ctypes and NumPy would probably also be useful. Feature requests are welcome. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/03/20/pyeigen-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More types and results</title>
		<link>http://www.brainfold.org/blog/2010/03/18/more-types-and-results/</link>
		<comments>http://www.brainfold.org/blog/2010/03/18/more-types-and-results/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 22:38:43 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[benchmark]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=221</guid>
		<description><![CDATA[I implemented some new types for PyEigen, including a 4x4 matrix class and benchmarks for it. Same methods as last time, but quite different results. PyEigen is still fastest by far, which is promising. This time it was about 5-10x faster than cgkit1, which was again the second fastest. You might also notice that vectypes [...]]]></description>
			<content:encoded><![CDATA[<p>I implemented some new types for PyEigen, including a 4x4 matrix class and benchmarks for it. Same methods as last time, but quite different results.</p>
<div id="attachment_222" class="wp-caption alignnone" style="width: 531px"><a href="http://www.brainfold.org/blog/wp-content/uploads/2010/03/benchmark1.png"><img class="size-full wp-image-222 " title="Linear algebra library 4x4 matrix benchmark" src="http://www.brainfold.org/blog/wp-content/uploads/2010/03/benchmark1.png" alt="Benchmark results" width="521" height="464" /></a><p class="wp-caption-text">Benchmark results</p></div>
<p>PyEigen is still fastest by far, which is promising. This time it was about 5-10x faster than cgkit1, which was again the second fastest. You might also notice that vectypes is missing. For this test, it was so slow that I had to leave it out; other results would have been invisible if I had fitted the vectypes results in the graph. In the worst case, it was over <strong>1000x</strong> slower than PyEigen! Euclid is missing addition and scalar multiplication scores since it doesn't support those operations. NumPy performed much better. There has to be a faster way to do vector cross product in NumPy, since matrix multiplication was much faster than cross product. But it's not a big deal anymore since PyEiglet is so much faster than anything else. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/03/18/more-types-and-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Surprising results</title>
		<link>http://www.brainfold.org/blog/2010/03/17/surprising-results/</link>
		<comments>http://www.brainfold.org/blog/2010/03/17/surprising-results/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 23:13:50 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[benchmark]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=213</guid>
		<description><![CDATA[I did some preliminary benchmarking today and got very interesting results. I have only wrapped a 3D vector class so far, so I tested a couple of operations (add, multiply, dot &#38; cross product) against the libs I mentioned in the previous post: NumPy, euclid, vectypes and cgkit. For cgkit, I tested both 1.2.0 and [...]]]></description>
			<content:encoded><![CDATA[<p>I did some preliminary benchmarking today and got very interesting results. I have only wrapped a 3D vector class so far, so I tested a couple of operations (add, multiply, dot &amp; cross product) against the libs I mentioned in the previous post: <a href="http://numpy.scipy.org/">NumPy</a>, <a href="http://www.partiallydisassembled.net/euclid.html">euclid</a>, <a href="http://code.google.com/p/vectypes/">vectypes</a> and <a href="http://cgkit.sourceforge.net/">cgkit</a>. For cgkit, I tested both 1.2.0 and 2.0 alpha 9. All other libs were the latest version. I tested using the Python timeit module with 1,000,000 calls and 3 repeats per test and took the lowest number. Repeated test results generally differed only by milliseconds.</p>
<div id="attachment_214" class="wp-caption alignnone" style="width: 601px"><a href="http://www.brainfold.org/blog/wp-content/uploads/2010/03/benchmark.png"><img class="size-full wp-image-214 " title="Linear algebra library benchmark" src="http://www.brainfold.org/blog/wp-content/uploads/2010/03/benchmark.png" alt="Benchmark results" width="591" height="472" /></a><p class="wp-caption-text">Benchmark results</p></div>
<p>The immediately obvious surprise is the abysmal performance of NumPy especially in cross products. I don't think NumPy optimizes for fixed-size arrays; I would have been better off with the pure-Python euclid and vectypes modules.</p>
<p>The other surprises were euclid vs vectypes and cgkit1 vs cgkit2. Euclid and vectypes are both by Alex Holkner of <a href="http://pyglet.org/">Pyglet</a> fame. In both cases, the newer library (vectypes and cgkit2) was also slower.</p>
<p>Of course the most positive surprise for me was the performance of PyEigen. It's only a trivial wrapping, but was about 2-8x faster than the best alternative, cgkit1. I'm very happy with the results and definitely going to continue development of the library / wrapper. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update:</strong> <a href="http://bazaar.launchpad.net/~knarkles/pyeigen/trunk/annotate/head%3A/test/benchmark/vector3.py">Here's</a> the benchmark code. Also an interesting detail: PyEigen is <strong>136x</strong> faster than NumPy with cross products.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/03/17/surprising-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyEigen</title>
		<link>http://www.brainfold.org/blog/2010/03/16/pyeigen/</link>
		<comments>http://www.brainfold.org/blog/2010/03/16/pyeigen/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 08:06:29 +0000</pubDate>
		<dc:creator>Jussi Lepistö</dc:creator>
				<category><![CDATA[boost.python]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cython]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[linear algebra]]></category>
		<category><![CDATA[numpy]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[pyeigen]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[swig]]></category>

		<guid isPermaLink="false">http://www.brainfold.org/blog/?p=203</guid>
		<description><![CDATA[I have a new project called PyEigen, a wrapper for the C++ linear algebra library Eigen. I just submitted the first batch of code and progress is good, at least so far. I'm hoping for an initial release within a month or so. The whole thing started when I profiled my shooter project and found [...]]]></description>
			<content:encoded><![CDATA[<p>I have a new project called <a href="http://launchpad.net/pyeigen">PyEigen</a>, a wrapper for the C++ linear algebra library <a href="http://eigen.tuxfamily.org/">Eigen</a>. I just submitted the first batch of code and progress is good, at least so far. <img src='http://www.brainfold.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I'm hoping for an initial release within a month or so.</p>
<p>The whole thing started when I profiled my shooter project and found that matrix calculations take up a huge amount of time. Apparently <a href="http://numpy.scipy.org/">NumPy</a> isn't really fast enough for 3D games, and I couldn't find any replacements. While otherwise looking good, <a href="http://www.partiallydisassembled.net/euclid.html">euclid</a> and <a href="http://code.google.com/p/vectypes/">vectypes</a> are pure Python so they aren't going to make performance any better. <a href="http://cgkit.sourceforge.net/">cgkit </a>is C++ with a Python wrapper so looking better already, but... it's using <a href="http://www.boost.org/doc/libs/1_42_0/libs/python/doc/index.html">Boost.Python</a>, which <a href="http://chrischou.wordpress.com/2010/02/28/simple-benchmark-between-cython-and-boost-python/">apparently isn't very fast</a>. Also, it's lacking SSE instrumentation and other optimizations included in Eigen. So I decided to wrap Eigen.</p>
<p>As I already found out, Boost.Python is slow and looked too complex for such a simple library anyway. I tried <a href="http://cython.org/">Cython</a> next, but its C++ support is (still) very limited and the lack of support for C++ references destroyed any hope of wrapping Eigen, which relies heavily on them. My final option before resorting to manual wrapping using the Python C API was <a href="http://swig.org/">SWIG</a>, but I had problems getting even a simple wrapper to compile. Besides, I don't really like how SWIG generates function wrappers and a separate Python module that calls those wrappers instead of generating a Python C module directly.</p>
<p>So I was left with only the final option: Python C API. I feared it at first because I've never worked with it and it seemed really complex. It <em>is</em> complex, but not nearly as bad as I though, especially as Eigen has such a simple API. For <a href="http://bulletphysics.org/">Bullet</a>, I'm sure I'll use Cython or some other wrapper generator, but for Eigen the Python C API is just fine.</p>
<p>Anyway, since there doesn't seem to be anything like this out there, I decided to make it an open source project so hopefully other people in the same situation won't have to jump through the same hoops as I did. I'll post progress reports, releases and especially benchmarks against the other options as soon as I have them.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">http://launchpad.net/pyeigenI h</div>
]]></content:encoded>
			<wfw:commentRss>http://www.brainfold.org/blog/2010/03/16/pyeigen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
