Saturday, September 8, 2012

(Literary) Ramblings about the Universe

   While sipping away at my alcoholic drink, I had, as men usually have, philosophical matters spring to my mind. Wrought body and soul in the shadow of the night, my first instinct was to share my thoughts with the world.

   In Siddhartha, by Hermann Hesse, a young prodigy of his tribe leaves his home and undertakes a long journey to gain spiritual enlightenment. In the process of knowing himself and the world, he loses himself. He goes against all the teachings of the elders of his tribe and everything he has always known. However, in the end, while not returning to his home, he returns in a state resembling his old state, but with hard-gained knowledge and wisdom. 

   This very idea of movie through space and time but coming back to a similar place, the notion of the cycles in life, of the cycles in Nature, is interesting to me. For a reason I can't explain, this is appealing to me. The idea that, through human history, through the succession of generations, I get to live forever. "At the still point of the turning world", through the center that must hold, where everyone is one and nothing, where the lonely streams become a river, the river of life, I can identify with everything. My "soul is the whole world". 

   This is indeed very hard to explain. Even T.S. Eliot had problems expressing this idea:
         That was a way of putting it - not very satisfactory:
A periphrastic study in a worn-out poetical fashion,
Leaving one still with the intolerable wrestle
With words and meanings. The poetry does not matter.
although the idea is, verily, quite simple. In a place, where there exists no time and no space, we are one. But not really.

    This still point, being defined by the Universe, must be of the Universe. Imagine a rolling wheel. Its center does not move, being the center, but it must rotate as to accompany the wheel. We do not see it turning, but it must. We can relate this analogy to the conclusion of Siddhartha. Carpe Diem. Everything that is the world is beautiful; it must be appreciated and loved and such. Everything has sin and virtue in it.

   But this isn't true. It is true only at the still point. What shall we do? Locally, then, an ethics system must be enforced. This ethical system, built by the people inhabiting the region of space and time by the means of logic and reason, must fulfill the requirements and principles of the people. 

   Globally, this is my interpretation of this. Although I do not think the world completely deterministic, I believe that the entirety of possibilities is contained in the world. At the still point, then, the singularity of the Big Bang, every possible outcome exists and is as one; the future of the Universe is written as the wavefunction fo the Universe. At that time, the river breaks into a million pieces.

   What did I just say? I am confused.  The poetry does not matter, but its equivocacy a way to expose without explaining, a way to confuse and inform. 

   This is it for now, but I shall return. 

Bessel functions of complex argument

   Our research group, Dynamica, has openly published a shared object C++ library to compute Bessel functions of complex argument. It is available ready to compile as a tar archive or, for the initiated, as C++ and Fortran source code on Google Code.

   The Fortran code comes from D.E. Amos and his 1986 article. The article clearly details the limits, accuracy and speed of the subroutines. Being tested and proven against the test of time, we use them without modification. A C++ wrapper is defined in a header.

   More documentation is available on the Google Code repository. To thank you for reading this, here's a pretty picture!

"Proof" that the algorithms work.

Friday, August 24, 2012

Fortran, C++ and qmake

Qt Creator Logo
   Call me a noob, but I love using Qt Creator even when I'm not programming a GUI. The UI greatly facilitates code writing: the syntax highlighting is very customizable, it shows you the methods of a class when you use the . or -> operators, it makes the build process faster and easier to configure (sometimes), etc.

   Now, I didn't want to make this a post about Qt Creator, so here comes the meat. I've been trying to add Fortran code to my numerical library, something I think is pretty common in scientific circles. Of course, that's been done before, but my research has yielded one link for Fortran and Qt. 

   I'm using D.E. Amos' Fortran code to compute Bessel and Hankel functions of complex arguments and all (real) orders (we use identities to convert the negative order computations to positive order ones). Complex orders are not supported. Work by Temme could be used for this, but maybe a later time. 

   I have two Fortran source files that must be incorporated into a C++ numerical library. Using qmake, this is child's play. 

  • First, add the Fortran source files as sources in your .pro file. 
  • SOURCES += machine.for zbesh.for

    Those are the names of the Fortran sources files used by Amos.  
  • Second, create a C++ header file that links to the Fortran subroutines inside the source files. 

    A couple things about this linkage. Notice that I appended a _ to the Fortran subroutine names. The extern keyword tells the compiler that a separately compiled object will be used. By default, g++ will append _ to Fortran subroutines when creating an object file. This means that if you change this compiler setting, be sure to remember to change your function declarations in your C++ header file.
    Also, the functions take pointers to variables. In Fortran, all functions take their arguments by reference. It is thus necessary to use pointers when using Fortran subroutines in C++. 
  • You're done! You can now use your Fortran subroutines in your C++ program! Just don't forget to add the
    when compiling either the program you are writing or a program that uses a library that uses Fortran subroutines.

Wow, that last sentence was terrible.

   Anyway, have fun programming!

Monday, July 23, 2012

Issues with Linux and HP printers

   Since I have access to a new printer, I (of course) had issues with it. As I tried different kinds of connection with CUPS (ipp://, ipps://, http://, socket://) and different drivers (hpijs, hpcups), the page would sometimes render blank lines as black strips of ink or print with some weird margins. 

   But, I have found the solution! 

   It turns out that the hplip package comes with a command called hp-setup, which can be used to configure your network printer. The tool setup the printer with the hpijs driver, but with an hp:// connection. The hp:// connection string I could not have guessed. It seems to be a combination of the printer model and other things, but it isn't explicited anywhere (that I know of). 

   Anyhow, now everything works fine. I hope this short post helps you. 

Thursday, May 17, 2012

Lattice Gauge Theory

   During the Winter 2012 semester at U. Laval, I took a Particle Physics course. I'm not sure of the exact appelation in English, but it was given as directed reading (lectures dirigées). I didn't have classes: only the reference book.

   None of that really matters anyway. The course culminated into an exploration of Lattice Gauge Theory by us two undergrad students. The resulting text is more a collection of interesting results or, in other words, an elementary review of the basics of the theory. 

   The PDF document is available on the website we made for the project. Again, French only. 

Thursday, March 29, 2012

Printer margins issues with Samsung CLP-310N

   Although this is a rather specific issue concerning the Samsung CLP-310N, I thought it could be a good idea to share the solution to a longstanding problem I was having. 

   For some reason, when I upgraded CUPS some time ago (I don't recall specifically when this began), printing PDFs and other documents from my Arch Linux box was difficult. The documents were not properly centered on the page (the top margin was way too low). So, I googled for something interesting. I came up with someone saying that the SPL-C driver seemed to be the cause and that switching to foo2qpdl solved the problem.

   I immediately tried to change my printer's driver to this one with CUPS (on my machine, I just go to http://localhost:631), but the driver was not in the list, even though the foo2qpdl XML file comes with foomatic-db, which I had installed a while back. 

   Okay, the quick solution is:
yaourt -S foo2zjs
then you will be able to select the Foomatic/foo2qpdl from the drop-down menu in CUPS. This is an AUR package, which seems to be well maintained. 

Anyway, hope this helps. Certainly helped me! 

Thursday, March 1, 2012

Equations in Blogger (part 2)

  A while ago, I fumbled into a method to typeset equations on any web page. However, the JavaScript needed to do the work suddently disappeared (I didn't research that) and anyhow, the equations stopped displaying properly. 

Now I just found out that MathJax is available as CDN service. This makes my life way easier. You have to add a HTML/JavaScript gadget to Blogger and paste some code. The simple procedure is explained in their good documentation

So... want a taste of it? Let $\rho(\mathbb{x})$ be the probability density function of $n$ statistically independant variables distributed according to some distribution function. The normalization condition is:

\[ \int\cdots\int_{-\infty}^{\infty} \rho(\mathbb{x})d^n\mathbb{x} = 1. \]

Oh hell, I like this too much! Another one!

\[ \mathcal{H} = \frac{1}{2}\frac{p_{\theta}^2}{mL^2}-mgL\cos\theta.\]

Thursday, February 2, 2012

Corrrupted SVN repo and the solution

   I'm currently taking a Numerical Physics course at U. Laval. So far, it has been a really enjoyable experience. However, I would like to share some technical know-how I acquired while working on one of the projects.
   We are mostly using MATLAB (I personally use Octave, which is the open-source counterpart) to do the projects. As of the fourth project, I am working with a partner, which immediately lead to the classic problem: how do we share the code?
    Of course, this problem has been solved in thousands of ways. I chose to create an account on SourceForge (I don't have my own server, so it was the easiest way) and start a project where I could dump the all the code in an SVN repository. (By the way, all the code we write, for what it's worth, is Creative Commons.)
   Everything went well; up till yesterday. For some obscure reason, when I tried to svn up in the morning, svn returned the error 
Reading one svndiff window read beyond the end of the representation.
which I didn't know about. Some Googling informed me that the repository was corrupted.  Some more Googling revealed a SourceForge support page that gave a solution to the problem.
   Okay, so here's the complete solution. You log on to the Shell SourceForge provide and run the following commands:

adminrepo --checkout svn
svnadmin dump -r 0:92 /svnroot/projectName/ > ~/repo.dump
The adminrepo checks out the SVN repo of your project in a folder that you can modify. You then dump the repo (I used -r 0:92 because I knew the repo was sane at rev 92 and because I had manually merged the diffs of -r 93:95 in my working directory).
   Now, if you're sure you have a good backup, you can delete the repo. We will then create a new one and load the dump file into this new repo.

rm -rf /svnroot/projectName/
svnadmin create /svnroot/projectName
adminrepo --save svn
Now half the fun is done. The repo is back in the main folder (which you can't modify directly) and your DB should be un-corrupted (or whatever).
   If you're using the new SourceForge bashboard, you can't stop here. You have to tell the dashboard that you've made some drastic changes to the repo. In the SourceForge web interface, navigate to Admin → Tools. Under the SVN tool, click on Import Repo. Enter the following URL:

click Import and you're done! 

Please inform me in the comments is something is unclear or just plain wrong. Thanks!