<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2970661570838560548</id><updated>2012-02-18T16:01:30.571+01:00</updated><category term='VTK structured points multuple scalars'/><category term='Qwt'/><category term='path'/><category term='boot'/><category term='Python Cython'/><category term='cython'/><category term='cygwin'/><category term='matplotlib python fontsize ticks'/><category term='mount'/><category term='QtCreator compiler options'/><category term='example'/><category term='samba'/><category term='Qt'/><category term='gcc'/><category term='odeint'/><category term='vectorization'/><category term='ubuntu'/><category term='openmp'/><category term='Qwt; legend; dash'/><category term='gcc march i7'/><category term='Cython odeint'/><title type='text'>Programming log</title><subtitle type='html'>A blog that serves as a log of mainly programming related issues that might also be useful for others.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-1765527512152328981</id><published>2012-02-05T12:23:00.001+01:00</published><updated>2012-02-05T12:23:53.685+01:00</updated><title type='text'>SPE versions</title><content type='html'>If you use SPE version 0.8.4 instead of version 0.8.3 none of the earlier mentioned problems occur. It is a bit strange that if you go to the sourceforge download site for SPE you get 0.8.3 as the recommended version. If you download from the &lt;a href="http://developer.berlios.de/project/showfiles.php?group_id=4161"&gt;archive link&lt;/a&gt; on the &lt;a href="http://pythonide.blogspot.com/"&gt;SPE blog&lt;/a&gt; you can download version 0.8.4.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-1765527512152328981?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/1765527512152328981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2012/02/spe-versions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/1765527512152328981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/1765527512152328981'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2012/02/spe-versions.html' title='SPE versions'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-6196184681873636602</id><published>2012-02-04T23:00:00.000+01:00</published><updated>2012-02-04T23:00:53.558+01:00</updated><title type='text'>more SPE problems</title><content type='html'>After posting how to get SPE running on python(x,y) and openSUSE I wanted to continue working on the python script I was until now editing with SciTE. When I actually wanted to edit my python file in SPE it did not accept any keyboard input in the main editor window (it gives errors in _spe\sm\wxp\stc.py). Rather inconvenient for an editor. On the internet I found one &lt;a href="http://blog.gmane.org/gmane.comp.python.spe.user/month=20080201"&gt;posting&lt;/a&gt; of the same problem. Unfortunately this time without a solution. By chance I found &lt;a href="http://www.blog.pythonlibrary.org/2009/08/29/wxpython-catching-key-and-char-events/"&gt;this website&lt;/a&gt; which gave me the idea to simply replace the two calls to &lt;FONT COLOR="green"&gt;event.KeyCode()&lt;/FONT&gt; in the stc.py file with &lt;FONT COLOR="green"&gt; event.GetKeyCode()&lt;/FONT&gt;. Now everything seems to work (both on openSUSE and python(x,y)).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-6196184681873636602?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/6196184681873636602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2012/02/more-spe-problems.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/6196184681873636602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/6196184681873636602'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2012/02/more-spe-problems.html' title='more SPE problems'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-7668202813183375070</id><published>2012-02-04T22:32:00.000+01:00</published><updated>2012-02-04T23:05:12.782+01:00</updated><title type='text'>spe python(x,y) wxPython2.8 problems</title><content type='html'>On Ubuntu the nice python editor from Stani (&lt;a href="http://pythonide.blogspot.com/search/label/spe"&gt;SPE&lt;/a&gt;) has started to behave strange since a recent Ubuntu upgrade. When scrolling with the wheel on the mouse lines get stuck. Moves with the cursor keys correct this but it is really annoying. Therefore I now wanted to run SPE on windows with python(x,y). This proved to be a bit more troublesome than expected. After putting the _spe directory obtained from the SPE &lt;a href="http://sourceforge.net/projects/spe/files/spe/0.8.2/"&gt;download on sourcefourge&lt;/a&gt; in the site-packages directory of python (\Python27\Lib\site-packages) simply running the SPE.py script did not work. After running as python SPE.py --debug from a command prompt I had the same problem as reported &lt;a href="http://developer.berlios.de/bugs/?func=detailbug&amp;bug_id=9244&amp;group_id=1"&gt;here&lt;/a&gt; (an error in Throbber.__init__). Luckily the solution reported on that same site also fixed the problem:&lt;br /&gt;&lt;br /&gt;Moving initialization of _filename, _running, and _position to before the call to GIFAnimationCtrl.__init__ resolves the problem.&lt;br /&gt;&lt;br /&gt;Interestingly on openSUSE I experienced the same problems. But there I also had to edit smdi.py (_spe\sm\wxp\smdi.py). In the function setTitle of the class Child(Framework) I commented the calls to self.SetTitle (lines 988-991). Calling self.setTitle instead of self.SetTitle (mark the capital) does not fix the problem (you get a maximum recursion limit error instead). The commenting of the code does not seem to affect the execution of SPE. The only remaining problem on openSUSE with SPE is now that I can only run it as root. &lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-7668202813183375070?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/7668202813183375070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2012/02/spe-pythonxy-wxpython28-problems.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7668202813183375070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7668202813183375070'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2012/02/spe-pythonxy-wxpython28-problems.html' title='spe python(x,y) wxPython2.8 problems'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-7388672607583867811</id><published>2011-12-10T14:18:00.001+01:00</published><updated>2011-12-10T14:32:36.910+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='example'/><category scheme='http://www.blogger.com/atom/ns#' term='odeint'/><category scheme='http://www.blogger.com/atom/ns#' term='cython'/><title type='text'>cython odeint example</title><content type='html'>In response to the &lt;a href="http://korbinin.blogspot.com/2011/07/using-cython.html"&gt;request by Ryan&lt;/a&gt; I now post a full example of using cython and odeint together. This is a specially written example because the original work contains too much code from my work that I do not want to post on the web. The equations used in the example have been chosen rather randomly. &lt;br /&gt;&lt;br /&gt;In this example I have created a sample Model class which is a callable class (you can use an instance of the class as the function parameter for odeint). The Model class is defined in model_cython.pyx and contains all the Cython code. In ode_script.py the model function is integrated with odeint and thus shows how to call the Cython class from a normal python script. Setup.py is needed to compile model_cython.pyx (see &lt;a href="http://korbinin.blogspot.com/2011/07/first-steps-with-cython-and-pythonxy.html"&gt;this&lt;/a&gt; post).&lt;br /&gt;&lt;br /&gt;model_cython.pyx:&lt;br /&gt;&lt;pre class="brush: py"&gt;import sys&lt;br /&gt;&lt;br /&gt;#define some constants a c floats but still callable from python scripts&lt;br /&gt;#not really used here but left in here as an example&lt;br /&gt;cpdef float R_GAS,K_B&lt;br /&gt;R_GAS=8.31      #Gas constant J/molK&lt;br /&gt;K_B=1.38066e-23 #Boltzmann constant J/K&lt;br /&gt;&lt;br /&gt;#import some often used math functions from the c math library&lt;br /&gt;cdef extern from &amp;quot;math.h&amp;quot;:&lt;br /&gt;    double sin(double)&lt;br /&gt;&lt;br /&gt;cdef extern from &amp;quot;math.h&amp;quot;:&lt;br /&gt;    double fabs(double)&lt;br /&gt;&lt;br /&gt;cdef extern from &amp;quot;math.h&amp;quot;:&lt;br /&gt;    double exp(double)&lt;br /&gt;&lt;br /&gt;#define a function callable from c and python&lt;br /&gt;cpdef float Velocity(float t,float amplitude=1.0,float period=4.):&lt;br /&gt;    cdef f1&lt;br /&gt;    f1=fabs(sin(t*period))*amplitude&lt;br /&gt;    return(f1)&lt;br /&gt;&lt;br /&gt;class Model:&lt;br /&gt;    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;    This class can be used to integrate a differential equation&lt;br /&gt;    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;    def __init__(self,float a,float p):&lt;br /&gt;        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;        -a is the amplitude of the sine function that describes the &lt;br /&gt;            speed oscillation as a function time&lt;br /&gt;        -p controls the period of the sine function&lt;br /&gt;        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;        self.a=a&lt;br /&gt;        self.p=p&lt;br /&gt;        &lt;br /&gt;    &lt;br /&gt;    def __call__(self,float y,float t):&lt;br /&gt;        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;        y is the current state of the initial value problem:&lt;br /&gt;        y: position&lt;br /&gt;        t: time&lt;br /&gt;        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;        cdef float pos&lt;br /&gt;        pos=y&lt;br /&gt;        #Workhardening&lt;br /&gt;        v=Velocity(t,amplitude=self.a,period=self.p)*exp(-pos)&lt;br /&gt;        return(v)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;ode_script.py:&lt;br /&gt;&lt;pre class="brush: py"&gt;#!/bin/env/python&lt;br /&gt;&lt;br /&gt;from numpy import r_&lt;br /&gt;import pylab,scipy.integrate,sys&lt;br /&gt;sys.path.append(&amp;quot;.&amp;quot;)&lt;br /&gt;from model_cython import *&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#ampltiude and period&lt;br /&gt;amp=1.0&lt;br /&gt;period=4.0&lt;br /&gt;#set initial position&lt;br /&gt;pos0=0.0&lt;br /&gt;#create instance of Model object with speed amplitude of 1&lt;br /&gt;myModel=Model(amp,period)&lt;br /&gt;#create time vector (4 seconds in 500 steps)&lt;br /&gt;tvec=r_[0.0:4.0:500j]&lt;br /&gt;#integrate ov&lt;br /&gt;y=(scipy.integrate.odeint(myModel,pos0,tvec))&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;#plot results&lt;br /&gt;pylab.figure(1)&lt;br /&gt;pylab.clf()&lt;br /&gt;pylab.subplot(211)&lt;br /&gt;pylab.plot(tvec,y)&lt;br /&gt;pylab.xlabel(&amp;quot;Time (s)&amp;quot;)&lt;br /&gt;pylab.ylabel(&amp;quot;Position (m)&amp;quot;)&lt;br /&gt;pylab.grid(b=True)&lt;br /&gt;pylab.subplot(212)&lt;br /&gt;v_list=[]&lt;br /&gt;for t in tvec:&lt;br /&gt;    v_list.append(Velocity(t,amplitude=amp,period=period))&lt;br /&gt;pylab.plot(tvec,v_list)&lt;br /&gt;pylab.xlabel(&amp;quot;Time (s)&amp;quot;)&lt;br /&gt;pylab.ylabel(&amp;quot;Undamped velocity (m/s)&amp;quot;)&lt;br /&gt;&lt;br /&gt;pylab.grid(b=True)&lt;br /&gt;pylab.show()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;setup.py:&lt;br /&gt;&lt;pre class="brush: py"&gt;from distutils.core import setup&lt;br /&gt;from distutils.extension import Extension&lt;br /&gt;from Cython.Distutils import build_ext&lt;br /&gt;&lt;br /&gt;ext_modules = [Extension(&amp;quot;model_cython&amp;quot;,[&amp;quot;model_cython.pyx&amp;quot;],\&lt;br /&gt;    libraries=[&amp;quot;m&amp;quot;])]&lt;br /&gt;&lt;br /&gt;setup(&lt;br /&gt;    name= 'Generic model class',&lt;br /&gt;    cmdclass = {'build_ext': build_ext},&lt;br /&gt;    ext_modules = ext_modules&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Hope this helps.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-7388672607583867811?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/7388672607583867811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2011/12/cython-odeint-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7388672607583867811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7388672607583867811'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2011/12/cython-odeint-example.html' title='cython odeint example'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-4461948003012819643</id><published>2011-11-13T15:42:00.001+01:00</published><updated>2011-11-13T15:58:46.574+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='samba'/><category scheme='http://www.blogger.com/atom/ns#' term='mount'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='boot'/><title type='text'>Ubuntu 11 samba mounting problems during booting</title><content type='html'>After upgrading to Ubuntu 11 I started to receive errors during booting mentioning CIFS-VFS. A quick search on the internet did not reveal a simple solution. Now I had a more thorough look. The CIFS-VFS error apparently has something to do with the automatic mounting of a samba share on a server in my network. I now know why the error pops up twice. From &lt;a href="http://ubuntuforums.org/showthread.php?t=1475237"&gt;posts on the web&lt;/a&gt; I found that the most likely reason that I get this error is because the network is not up before the mounting is tried. Which makes sense when you get the error &lt;br /&gt;&lt;br /&gt;mount error(101): Network is unreachable&lt;br /&gt;&lt;br /&gt;(look in /var/log/boot.log)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ubuntu runs the boot scripts in /etc/init. Here I found mountall.conf and mountall-net.conf. &lt;a href="https://help.ubuntu.com/community/UpstartHowto?highlight=%28%28UbuntuBootupHowto%29%29"&gt;Here&lt;/a&gt; I found that the order of the scripts is determined by a line in the scripts in the form&lt;br /&gt;&lt;br /&gt;start on runlevel [2345] stop on runlevel [!2345]&lt;br /&gt;&lt;br /&gt;When I looked in /etc/init/mountall-net I found the line:&lt;br /&gt;&lt;br /&gt;start on net-device-up&lt;br /&gt;&lt;br /&gt;which suggests that the script waits for the network to be up before the script is run. The other script mountall.conf has the line "start on startup" in it which I think means that this script is called more or less at the beginning when the network indeed may not yet be up. When the network is up (or supposed to be up) mountall-net is called. This explains why I get the mount error twice during booting. While searching the web for "start on net-device-up" I somewhere found the variant&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;start on (net-device-up IFACE=eth0):&lt;br /&gt;&lt;br /&gt;And this appears to make the problem go away (so now I only have one mnt error left during booting (from mountall.conf) but my samba share does get mounted automatically during booting).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-4461948003012819643?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/4461948003012819643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2011/11/ubuntu-11-samba-mounting-problems.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/4461948003012819643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/4461948003012819643'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2011/11/ubuntu-11-samba-mounting-problems.html' title='Ubuntu 11 samba mounting problems during booting'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-1392481749369038807</id><published>2011-10-14T21:47:00.001+02:00</published><updated>2011-10-14T21:47:13.630+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='openmp'/><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><category scheme='http://www.blogger.com/atom/ns#' term='vectorization'/><title type='text'>working with openmp and gcc vectorization output</title><content type='html'>When working with openmp for parallelisation you can set the number of threads in a bash shell (cygwin) by&lt;br /&gt;&lt;br /&gt;export OMP_NUM_THREADS=4&lt;br /&gt;&lt;br /&gt;this can be good to do if you do not want to use all "cores" detected automatically on a cpu with hyperthreading.&lt;br /&gt;&lt;br /&gt;To see which loops have been automatically vectorized by gcc you have to add the compiler switch&lt;br /&gt;&lt;br /&gt;-ftree-vectorizer-verbose=5&lt;br /&gt;&lt;br /&gt;Other verbose levels can also be used but for me level 5 seems to give the most relevant information.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-1392481749369038807?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/1392481749369038807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2011/10/working-with-openmp-and-gcc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/1392481749369038807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/1392481749369038807'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2011/10/working-with-openmp-and-gcc.html' title='working with openmp and gcc vectorization output'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-7571087967575102481</id><published>2011-09-18T10:57:00.000+02:00</published><updated>2011-09-18T10:57:27.721+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gcc march i7'/><title type='text'>march=native</title><content type='html'>On the web I found an easy way to find what the gcc compiler option -march=native translates into (can't remember where I found this, it was somewhere on a gentoo forum):&lt;br&gt;&lt;br&gt;echo "" | gcc -march=native -v -E - 2&gt;&amp;1 | grep cc1&lt;br&gt;&lt;br&gt;On my Q6600 with gcc 4.4.3 this results in: &lt;br&gt;&lt;br&gt;/usr/lib/gcc/i486-linux-gnu/4.4.3/cc1 -E -quiet -v - -D_FORTIFY_SOURCE=2 -march=core2 -mcx16 -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=core2 -fstack-protector&lt;br&gt;&lt;br&gt;Surprisingly on my laptop with an i7-2630QM and (cygwin) gcc 4.5.3 I get:&lt;br&gt;&lt;br&gt; /usr/lib/gcc/i686-pc-cygwin/4.5.3/cc1.exe -E -quiet -v -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api -idirafter /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/lib/../../include/w32api - -march=core2 -mcx16 -msahf -mpclmul -mpopcnt -mavx --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=generic&lt;br&gt;&lt;br&gt;I was expecting a -march=corei7-avx but I guess that is only from gcc 4.6?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-7571087967575102481?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/7571087967575102481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2011/09/marchnative.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7571087967575102481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7571087967575102481'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2011/09/marchnative.html' title='march=native'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-6338112933017634748</id><published>2011-07-24T18:33:00.000+02:00</published><updated>2011-07-24T18:33:53.254+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Cython odeint'/><title type='text'>Using Cython</title><content type='html'>The easiest way to convert old python code for use with cython is to rename your python file into something with the extension .pyx. This .pyx file can then be compiled with the setup.py (for distutils)script.&lt;br /&gt;&lt;br /&gt;Here is an example setup.py which also shows how to include the math libray (-lm for gcc)&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: py"&gt;from distutils.core import setup&lt;br /&gt;from distutils.extension import Extension&lt;br /&gt;from Cython.Distutils import build_ext&lt;br /&gt;&lt;br /&gt;ext_modules = [Extension(&amp;quot;BvL_cython&amp;quot;,[&amp;quot;BvL_cython.pyx&amp;quot;],\&lt;br /&gt;    libraries=[&amp;quot;m&amp;quot;])]&lt;br /&gt;&lt;br /&gt;setup(&lt;br /&gt;    name= 'BvL model class',&lt;br /&gt;    cmdclass = {'build_ext': build_ext},&lt;br /&gt;    ext_modules = ext_modules&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The reason that I was interested in Cython was the long calculation times I encountered while doing a multi-variable optimization with a function evaluation that involved solving a differential equation with scipy.integrate.odeint. By simply replacing the class that contained the differential equation with a Cython version the calculation time dropped by a factor 5. Not bad for half a Sunday afternoons work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-6338112933017634748?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/6338112933017634748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2011/07/using-cython.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/6338112933017634748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/6338112933017634748'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2011/07/using-cython.html' title='Using Cython'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-3373153325668181861</id><published>2011-07-24T16:38:00.000+02:00</published><updated>2011-07-24T16:38:19.067+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python Cython'/><title type='text'>First steps with Cython and Python(x,y)</title><content type='html'>Started today experimenting with Cython. With Cython you can write normal python code and compile it to C code. When you start to insert type information the speed up you get compared to normal python can be quite dramatic. The compiled c-code can be called from python (seemingly as if it was normal python code your calling). It is all nicely introduced here: &lt;a href="http://conference.scipy.org/proceedings/SciPy2009/paper_1/full_text.pdf"&gt;Cython tutorial&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;On windows I am using &lt;a href="http://www.pythonxy.com/"&gt;Python(x,y)&lt;/a&gt;. When you install it you have to tell the installer to include Cython. As c-compiler the Python (x,y) package includes mingw. Unfortunately Cython by default seems to expect a Visual C compiler. So the only way (so far) I found to use Cython is to run python from a normal command prompt when using the setup.py method (distutils) as described in the Cython Tutorial as follows:&lt;br /&gt;&lt;br /&gt;python setup.py build_ext --inplace --compiler=mingw32&lt;br /&gt;&lt;br /&gt;otherwise you get this error message:&lt;br /&gt;&lt;br /&gt;error: Unable to find vcvarsall.bat&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-3373153325668181861?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/3373153325668181861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2011/07/first-steps-with-cython-and-pythonxy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3373153325668181861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3373153325668181861'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2011/07/first-steps-with-cython-and-pythonxy.html' title='First steps with Cython and Python(x,y)'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-4051671863412602335</id><published>2010-11-22T21:10:00.000+01:00</published><updated>2010-11-22T21:10:02.856+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QtCreator compiler options'/><title type='text'>compiler options in QtCreator</title><content type='html'>Selecting the release build over the default debug build will enable the -O2 compiler option but under Projects settings you can only add make options. To add more compiler options such as -march=core2 you can add a line to your project file:&lt;br /&gt;&lt;br /&gt;QMAKE_CXXFLAGS += -march=core2&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-4051671863412602335?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/4051671863412602335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2010/11/compiler-options-in-qtcreator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/4051671863412602335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/4051671863412602335'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2010/11/compiler-options-in-qtcreator.html' title='compiler options in QtCreator'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-2321714840402240276</id><published>2010-11-10T21:57:00.002+01:00</published><updated>2010-11-10T22:07:23.259+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='matplotlib python fontsize ticks'/><title type='text'>Working with a second y-axis in matplotlib</title><content type='html'>Recently I had to create a plot with data on a second y-axis in matplotlib (python). This is actually more involved than I expected. After googling around I put this together&lt;br /&gt;&lt;br /&gt;First you store the axes object returned from a subplot(111) command&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: py"&gt;ax1=subplot(111)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;then you plot as usual your data which has to go to the first y-axis. Labels you have to set for the ax1 object:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: py"&gt;ax1.set_xlabel(r"Position ($\mu$m)",fontsize=20)&lt;br /&gt;ax1.set_ylabel("Concentration (wt %)",fontsize=20)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The second y-axis is created by creating a twin of your current axes object. The twin is actually not identical but has a mirrored y-axis (i.e. your second y-axis).&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: py"&gt;ax2=twinx()&lt;br /&gt;plot(....)&lt;br /&gt;ax2.set_label("Other conc (wt%)",fontsize=20)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So far so good. Normally I use the follow function to change the size of text of the ticks&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: py"&gt;def setTickSize(size=None):&lt;br /&gt; &amp;quot;&amp;quot;&amp;quot;Set the tick label size (both x and y axis) to the specified value or &lt;br /&gt; default to 'large'&lt;br /&gt; possible values are 'small', 'medium', 'larger', 'x-large', 'xx-large'&lt;br /&gt; 'x-small', 'xx-small' or integer values&lt;br /&gt; !!!!!!!!Warning!!!!!!!!!&lt;br /&gt; Use this function only when you are finished adding curves. If curves&lt;br /&gt; change the axes ranges the ticks get screwed up (sorry)&lt;br /&gt; &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt; if size is None:  #default large&lt;br /&gt;  size='large'&lt;br /&gt; elif type(size) == str:&lt;br /&gt;  if size not in ['small', 'medium', 'larger', 'x-large', 'xx-large','x-small', 'xx-small']:&lt;br /&gt;   print &amp;quot;Wrong fontsize specifier given, use:&amp;quot;&lt;br /&gt;   print 'small', 'medium', 'larger', 'x-large', 'xx-large', 'x-small', 'xx-small'&lt;br /&gt;   print 'defaulting to large'&lt;br /&gt;   size='large'&lt;br /&gt; elif type(size) != int:&lt;br /&gt;  print &amp;quot;Wrong fontsize specifier given, use:&amp;quot;&lt;br /&gt;  print 'small', 'medium', 'larger', 'x-large', 'xx-large', 'x-small', 'xx-small'&lt;br /&gt;  print 'or an integer value'&lt;br /&gt;  print 'defaulting to large '&lt;br /&gt;  size='large'&lt;br /&gt; &lt;br /&gt; tmp=pylab.xticks()&lt;br /&gt; pylab.xticks(tmp[0],[str(int(x)) for x in tmp[0]], size=size)&lt;br /&gt; tmp=pylab.yticks()&lt;br /&gt; pylab.yticks(tmp[0],[str(int(x)) for x in tmp[0]], size=size)&lt;br /&gt;&lt;/pre&gt;You have to change the type cast int(x) into something else if you want floating point values on your axes. However, it turns out that it is near impossible to do this for the ticks on the second y-axis. After some more googling I found a much easier alternative. Matplotlib can read settings from a user-preferences file somewhere in the user-home directory. Somehow I can never find this file (I use a lot of different windows/linux/python combinations). But from a script you can also set these preferences! Which of course then only apply to the remainder of the script:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: py"&gt;import matplotlib as mpl&lt;br /&gt;mpl.rcParams['xtick.labelsize']=20&lt;br /&gt;mpl.rcParams['ytick.labelsize']=20&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The nice part is that the labelsize applies to both your first and second y-axis. You can find more info on the matplotlibrc file on the &lt;a href="http://matplotlib.sourceforge.net/users/customizing.html"&gt; sourceforge matplotlib site&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The only issue I could not solve is to create one legend for the curves on both axes. If you legend() you only get the legend for the current active axes. On windows calling it again just replaced the other legend on linux they were both displayed on top of eachother (which gives you the option to use e.g. legend(loc=2) for the left y-axis and legend(loc=1) for right y-axis).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-2321714840402240276?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/2321714840402240276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2010/11/working-with-second-y-axis-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/2321714840402240276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/2321714840402240276'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2010/11/working-with-second-y-axis-in.html' title='Working with a second y-axis in matplotlib'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-3032921939942206424</id><published>2010-09-26T13:39:00.004+02:00</published><updated>2010-09-26T13:57:00.220+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Qwt; legend; dash'/><title type='text'>Change legend line width in Qwt</title><content type='html'>In the past I made a small program that basically just plots a number of columns from a text file. This program is written using the Qwt plotting library. The program can simultaneously plot the columns from multiple text files. The different columns in a file are given different colours and for columns from different files a different line style is used (normal, dashed, dotted or dash-dot). A legend showing which line is which is also displayed. Here I had the problem that with the default legend properties the width of the line shown in the legend is so small that you can not distinguish between a normal and a dashed or dashed dotted line. After some searching on the web I found a &lt;a href="http://www.qtcentre.org/threads/33761-Increase-legend-icon-size?highlight=qwt+legend"&gt;good description&lt;/a&gt; of how to change the width of the line in the legend. If you follow the link you find that they call the line section displayed the legend icon (that is why it took me some time to find that website). In the end I modified their code a little bit. My program was using plain QwtPlotCurve variables. So I made a derived class FractionCurve which implements the updateLegend function. The total code of this very simple custom Curve class is given below. Because my program uses the QwtPlotCurve constructor that takes a QString as an argument I also had to implement that constructor for the derived FractionCurve class.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp"&gt;#include &amp;lt;qwt_legend.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;qwt_legend_item.h&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;class FractionCurve : public QwtPlotCurve&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;&lt;br /&gt;void updateLegend(QwtLegend *legend) const;&lt;br /&gt;&lt;br /&gt;FractionCurve(const QString);&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;FractionCurve::FractionCurve(const QString s) : QwtPlotCurve(s)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void FractionCurve::updateLegend(QwtLegend *legend) const&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;QwtPlotCurve::updateLegend(legend);&lt;br /&gt;&lt;br /&gt;QwtLegendItem *lgdItem =&lt;br /&gt;&lt;br /&gt;dynamic_cast&amp;lt;QwtLegendItem*&amp;gt;(legend-&amp;gt;find( this ));&lt;br /&gt;&lt;br /&gt;if ( lgdItem )&lt;br /&gt;&lt;br /&gt;lgdItem-&amp;gt;setIdentfierWidth(24);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And an example of a plot with the new legend:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_5o4j7O7TIDA/TJ805Xj8zPI/AAAAAAAABbg/iOSawfM_bu8/s1600/fractions.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/_5o4j7O7TIDA/TJ805Xj8zPI/AAAAAAAABbg/iOSawfM_bu8/s320/fractions.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-3032921939942206424?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/3032921939942206424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2010/09/change-legend-line-width-in-qwt.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3032921939942206424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3032921939942206424'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2010/09/change-legend-line-width-in-qwt.html' title='Change legend line width in Qwt'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_5o4j7O7TIDA/TJ805Xj8zPI/AAAAAAAABbg/iOSawfM_bu8/s72-c/fractions.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-3862463408620201121</id><published>2010-08-14T12:53:00.000+02:00</published><updated>2010-08-14T12:53:33.921+02:00</updated><title type='text'>Nice syntax highlighting in Blogger</title><content type='html'>There is an easy way to make source code snippets look great on your blog. You have to change your template once and after that you can just surround your code with a simple tag. One thing you must not forget to do is to "escape" your source code so it only contains valid html code. Manually this means replacing any less than sign with appropriate html code. &lt;br /&gt;&lt;br /&gt;Everything is nicely explained here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.cartercole.com/2009/10/awesome-syntax-highlighting-made-easy.html" title="code to do quick syntax highlighting"&gt;syntax highlighting tutorial&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and here is a direct link to a site to escape your html&lt;br /&gt;&lt;br /&gt;&lt;a href="http://accessify.com/tools-and-wizards/developer-tools/quick-escape/default.php"title="Quick escape"&gt; quick escape &lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-3862463408620201121?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/3862463408620201121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2010/08/nice-syntax-highlighting-in-blogger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3862463408620201121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3862463408620201121'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2010/08/nice-syntax-highlighting-in-blogger.html' title='Nice syntax highlighting in Blogger'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-5856389655229165642</id><published>2010-08-08T18:43:00.004+02:00</published><updated>2010-08-14T12:43:14.609+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VTK structured points multuple scalars'/><title type='text'>Reading a vtk file with multiple scalar fields</title><content type='html'>The Micress phase simulation package can store data files in .vtk format. It stores multiple scalar values in a single file, where the scalar are stored as structured points. For example I received I file containing concC, phas and rex. I would like to read in these files and convert them to something else. So the main goal was to obtain arrays with the 3 scalar fields. The code is not yet complete but the reading is quite involved and it took me a lot of time to patch the required information together from all different examples and the DOxygen online manual of VTK (which I have come to dislike to a great extend). Perhaps the VTK books would have helped me out here but I am not willing to buy them just for this single application of VTK.&lt;br /&gt;&lt;br /&gt;Okay here we go:&lt;br /&gt;&lt;pre class="brush: cpp"&gt;//First you have to create a reader object:&lt;br /&gt;vtkSmartPointer &amp;lt vtkstructuredpointsreader&gt; reader = vtkSmartPointer &amp;lt vtkstructuredpointsreader&gt;::New();&lt;br /&gt;reader-&gt;SetFileName(inputFilename.c_str());&lt;br /&gt;//Now we can get the number of scalars in the file&lt;br /&gt;vtkIdType numScal=reader-&gt;GetNumberOfScalarsInFile();&lt;br /&gt;std::cout &amp;lt&amp;lt "number of scalars in file: " &amp;lt&amp;lt numScal &amp;lt&amp;lt std::endl;&lt;br /&gt;//Show which scalars we have&lt;br /&gt;int i;&lt;br /&gt;for(i=0;i&amp;lt numScalComp;i++)&amp;#123&lt;br /&gt;  std::cout &amp;lt&amp;lt "Scalar "&amp;lt&amp;lt i &amp;lt&amp;lt": " &amp;lt&amp;lt reader-&gt;GetScalarsNameInFile(i)&amp;lt&amp;lt std::endl;&lt;br /&gt;&amp;#125;&lt;br /&gt;//To read a certain scalar field we have to tell the reader which one we want&lt;br /&gt;//we do that by name in this example we take the third one&lt;br /&gt;reader-&gt;SetScalarsName(reader-&gt;GetScalarsNameInFile(2));&lt;br /&gt;reader-&gt;Update();  //I think this actually makes the reader do something&lt;br /&gt;//the rest is what vtk people call setting up the pipeline&lt;br /&gt;//To get to the point data we need a few intermediate steps and objects&lt;br /&gt;vtkStructuredPoints* structuredPoints = reader-&gt;GetOutput();&lt;br /&gt;vtkPointData *pd=structuredPoints-&gt;GetPointData();&lt;br /&gt;pd-&gt;Update();&lt;br /&gt;vtkDataArray *scalars ;&lt;br /&gt;scalars=pd-&gt;GetScalars(reader-&gt;GetScalarsNameInFile(2));&lt;br /&gt;//here the same name as selected in the reader must be used!!&lt;br /&gt;//I tried this line with the SetScalarsName call to the reader and&lt;br /&gt;//that doesn't work.&lt;br /&gt;//Now we can access the points for example as&lt;br /&gt;vtkIdType numPoints = structuredPoints-&gt;GetNumberOfPoints();&lt;br /&gt;for(i=0;i&amp;lt numPoints;i++)&amp;#123&lt;br /&gt;   std::cout&amp;lt&amp;lt i&amp;lt&amp;lt ": " &amp;lt&amp;lt scalars-&gt;GetComponent(i,0)&amp;lt&amp;lt std::endl;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;/pre&gt;The next step is to write a .vtk file from my own data. The mayavi2 and ParaView programs look quite nice for imaging of 3d data.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-5856389655229165642?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/5856389655229165642/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2010/08/reading-vtk-file-with-multiple-scalar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/5856389655229165642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/5856389655229165642'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2010/08/reading-vtk-file-with-multiple-scalar.html' title='Reading a vtk file with multiple scalar fields'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-8133050594564527563</id><published>2010-03-28T14:10:00.000+02:00</published><updated>2010-03-28T14:13:37.254+02:00</updated><title type='text'>Weird experience with Gmail</title><content type='html'>Today I tried to login to my gmail account using chrome under Ubuntu (I always use https). After trying for a period of 15 minutes during which it kept telling me that the website was unavailable I was about to ask my wife if she alaso had problems reaching her gmail. Then I tried firefox and I could login immediately. I tried Chrome once more and still could not login. Now I can use chrome to login to gmail as well.&lt;br /&gt;&lt;br /&gt;Weird&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-8133050594564527563?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/8133050594564527563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2010/03/weird-experience-with-gmail.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/8133050594564527563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/8133050594564527563'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2010/03/weird-experience-with-gmail.html' title='Weird experience with Gmail'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-5425756017899511257</id><published>2009-12-28T09:50:00.000+01:00</published><updated>2009-12-28T09:54:40.787+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Qt'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='path'/><title type='text'>Problems with Qt and Path environment variable</title><content type='html'>Qt Creator kept giving strange error messages. Message such as "mingw32-make" not found in the path. Only after removing all references to my cygwin installation in the windows (XP) PATH environment settings does Qt Creator work again.&lt;br /&gt;&lt;br /&gt;Cygwin (from a bash shell) still seems to work after removing these path entries.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-5425756017899511257?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/5425756017899511257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2009/12/problems-with-qt-and-path-environment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/5425756017899511257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/5425756017899511257'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2009/12/problems-with-qt-and-path-environment.html' title='Problems with Qt and Path environment variable'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-6398516512135375021</id><published>2009-12-22T16:43:00.000+01:00</published><updated>2009-12-22T16:49:00.953+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Qwt'/><category scheme='http://www.blogger.com/atom/ns#' term='Qt'/><title type='text'>Path for qt</title><content type='html'>It turned out that my cygwin installation also contains some qt elements. They interfered with the Qwt examples. After moving &lt;br /&gt;&lt;br /&gt;D:\Qt\2009.05\Qt\bin&lt;br /&gt;&lt;br /&gt;to the front of the path I can now directly run the Qwt examples by double clicking in an explorer window.&lt;br /&gt;&lt;br /&gt;By the way in &lt;br /&gt;&lt;br /&gt;D:\Qt\2009.05\bin&lt;br /&gt;&lt;br /&gt;the dll's needed to run Qt Creator are stored and not the dll's you build your own software against. With Qwt it is possible to build an plugin for Qt designer. However this plugin when build with the free Qt package does not work because Qt Designer was build against these other dll's. Not nice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-6398516512135375021?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/6398516512135375021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2009/12/path-for-qt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/6398516512135375021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/6398516512135375021'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2009/12/path-for-qt.html' title='Path for qt'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-3454012552516979860</id><published>2009-12-22T09:35:00.000+01:00</published><updated>2009-12-22T09:41:47.105+01:00</updated><title type='text'>Python script for lame mp3 encoding</title><content type='html'>For some reason EAC refused to encode a CD to mp3. Therefore I copied the .wav files and downloaded the lame package from sourceforge. Lame was then compiled and installed under cygwin (1. ./configure 2. make 3. make install). Then with this small python script all tracks could be compressed to mp3:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;import os&lt;br /&gt;&lt;br /&gt;for i in range(1,28):&lt;br /&gt; call_text="lame -V2 Track%02d.wav Track%02d.mp3"%(i,i)&lt;br /&gt; print call_text&lt;br /&gt; os.system(call_text)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(on the web I had to look up how to do the os.system call and how to pad with zeros to the numbering of the tracks right 01, 02 ,03&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-3454012552516979860?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/3454012552516979860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2009/12/python-script-for-lame-mp3-encoding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3454012552516979860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3454012552516979860'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2009/12/python-script-for-lame-mp3-encoding.html' title='Python script for lame mp3 encoding'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-3484269506123164698</id><published>2009-12-21T22:48:00.001+01:00</published><updated>2009-12-22T09:43:48.719+01:00</updated><title type='text'>qHash problem</title><content type='html'>The qHash problem was also found by other people&lt;br /&gt;&lt;br /&gt;according to&lt;br /&gt;&lt;a href="http://www.qtcentre.org/forum/f-qwt-23/t-qhashdouble-problem-with-qt-46-tp1-24721-post125933.html"&gt; this &lt;/a&gt; forum entry&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;you can just remove the QWT_TEMPLATEDLL section (I did this by changing the line&lt;br /&gt;&lt;span style="font-style:italic;"&gt;#if defined(QWT_TEMPLATEDLL)&lt;/span&gt;&lt;br /&gt;near the &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;template class QWT_EXPORT QList&lt;double&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;line&lt;br /&gt;into &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;#if defined(QWT_TEMPLATEDLLxx)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;after this the compile runs fine and I have a fresh qwt5.dll file.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By opening the example.pro file in the Qt Creator and running qmake from the build menu followed by a run I also managed to compile the examples. The examples don't run because qwt5.dll cannot be found. Copying the dll into the examples/bin folder lets you run the examples from Qt Creator. You still cannot run the examples directly from windows because then the qt dll's cannot be found. Running the examples from the command prompt that comes with the nokia Qt installation package works though. &lt;br /&gt;&lt;br /&gt;Better option is of course to just add the folders with the qt dll's to the windows environment. I choose to copy the qwt dll into the same folder as the other qt dll's (safes an entry into the path environment setting)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-3484269506123164698?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/3484269506123164698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2009/12/qhash-problem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3484269506123164698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/3484269506123164698'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2009/12/qhash-problem.html' title='qHash problem'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-1406513849012406291</id><published>2009-12-21T22:18:00.000+01:00</published><updated>2009-12-21T22:38:09.087+01:00</updated><title type='text'>Qwt and Qt (mingw version) next step</title><content type='html'>When you search on google for qwt one of the first hits is a download link on sourceforge for version 4.2.0. The most recent version at the moment however is 5.2.0. Which was made for Qt 4.5. The Qt package from Nokia now seems to come with Qt 4.6.&lt;br /&gt;&lt;br /&gt;When compiling the Qwt package from the Qt Creator it now comes much further but it runs into an error compiling qwt_valuelist.h:&lt;br /&gt;&lt;br /&gt;2009.05/qt/include/QtCore/../../src/corelib/tools/qhash.h:875: error: call of overloaded 'qHash(const double&amp;)' is ambiguous&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-1406513849012406291?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/1406513849012406291/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2009/12/qwt-and-qt-mingw-version-next-step.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/1406513849012406291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/1406513849012406291'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2009/12/qwt-and-qt-mingw-version-next-step.html' title='Qwt and Qt (mingw version) next step'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2970661570838560548.post-7694511159839699790</id><published>2009-12-21T21:49:00.000+01:00</published><updated>2009-12-21T21:55:03.595+01:00</updated><title type='text'>Starting with Qt and Qtw</title><content type='html'>Today I downloaded Qt free version (4.6.0) and installed it on my labtop (windows XP). I also downloaded the Qwt plotting library (4.2.0). After installation Qwt does not compile when I open the qwt project in the Qt Creator. The binary examples also do not run because a dll is missing. I already had this problem once when I installed Qt and Qwt on my desktop machine (running Vista). Of course now I cannot remember what I did then to make it run that time. And that is why I decided to start this blog. Just to make my own notes to help me remember these kind of things. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Maybe it will help someone else too.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2970661570838560548-7694511159839699790?l=korbinin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://korbinin.blogspot.com/feeds/7694511159839699790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://korbinin.blogspot.com/2009/12/starting-with-qt-and-qtw.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7694511159839699790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2970661570838560548/posts/default/7694511159839699790'/><link rel='alternate' type='text/html' href='http://korbinin.blogspot.com/2009/12/starting-with-qt-and-qtw.html' title='Starting with Qt and Qtw'/><author><name>Korbinin</name><uri>http://www.blogger.com/profile/00742811285841484666</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
