Pages

Tuesday, April 14, 2015

Have yaourt save compiled packages to /var/cache/pacman/pkg

   The title of this post might not mean much to most of you, but for those few lucky enough to use Arch Linux on a daily basis, this could be of use to you. By default, yaourt does not keep the package files it produces, it deletes them after installation. Since the AUR deals mostly with unsupported packages, making it imperative that you be able to roll back to older packages, this is not useful default behaviour.
   To have yaourt export your compiled packages to the standard location, /var/cache/pacman/pkg/, edit /etc/yaourtrc and change the line
#EXPORT=0
to
EXPORT=2
That is all. Have a nice day!

Tuesday, November 11, 2014

Google Calendar Material Design

   My Nexus 4 prompted me last night for permission to update Gmail and Google Calendar. I must say, while Gmail looks slightly better than it did, GCal has received a much needed revamp, especially the widget. I do not have a screenshot of the previous version, but the colour scheme was terrible and the layout was such that it was hard to determine the division between days. It was also very difficult to quickly glance at a calendar to get some information.

A screenshot of the new GCal widget
on my Nexus 4.
   The new version, released yesterday, has received the "Material Design" treatment; the colours are a little more tame, and the division between events and dates is much clearer. Worth the (free) update.

I guess I'm saying I like the new designs of Google.

Sunday, April 21, 2013

Dual basis and its applications

   In the physical sciences, the scientist mostly tries to put the problem in a form that is easily solvable. One such form is the eigenvector expansion where one solves a simpler problem and assumes that the more difficult problem can be decomposed in a sum of the simpler solutions.
   This kind of problem generally involves solving the eigenvalue problem of a particular matrix. Assuming that you know how to do that, this is all fine and well. However, it is also common to use orthogonality relations to simplify the solution. For a general matrix $A$, the resulting eigenvectors need not be orthogonal. That's a problem. Let's look for a solution.
   Adopting the braket notation and denoting an eigenvector by $|e_i\rangle$, we seek new vectors such that $$ \langle f^i|e_j\rangle = \delta^i_j.$$ To see how we can compute those vectors, consider the original eigenvalue problem $$ \label{eq:eigenvalue}A|e_i\rangle = \lambda_i|e_i\rangle .$$ We will use the fact that both sets of eigenvectors are complete so that there exists a closure relation $$ \sum_i |e_i\rangle\langle f^i| = 1.$$ Now, pre-multipling \eqref{eq:eigenvalue} by $\langle f^j|$ and post-multiplying by $\langle f^i|$ and summing over the index $i$, we get $$ \sum_i \langle f^j|A|e_i\rangle\langle f^i| = \sum_i \lambda_i \langle f^j|e_i\rangle\langle f^i|.$$ Using our orthogonality relations on the right-hand side of this last equation and the closure relation on the left-hand side, we get $$ \langle f^j| A = \sum_i \lambda_i \langle f^i| \delta^j_i. $$ The Dirac delta makes the sum disappear as usual and we have $$ \langle f^j| A = \lambda_j \langle f^j|. $$ In other words, the $\langle f^j|$ are the row eigenvectors of $A$ and have the same eigenvalues as the set $|e_i\rangle$!
   So we find that these new "contravariant" vectors are actually the left eigenvectors of the matrix $A$. Moreover, the decomposition of any vector in the original set of covariant vectors is given by the dot product with the vectors in the dual basis. Say we have a vector $|v\rangle$, its decomposition is given by $$ |v\rangle = \sum_i \langle f^i|v\rangle|e_i\rangle .$$
   This eigendecomposition is incredibly useful in solving differential equations, smoothing numerically unstable solutions...

Sunday, March 10, 2013

Interfacing Armadillo and FFTW

   FFTW, or the Fastest Fourier Transform in the West, is an awesome C library used to, well, perform FFTs. Armadillo, on the other hand, is an awesome C++ library that implements linear algebra operations. Both are renowned for their amazing speed and, especially the latter, ease of use.
   Now suppose you want to use Armadillo in concert with FFTW. By default, FFTW assumes that you are using fftw_complex* arrays which memory are allocated using fftw_malloc. Now, assuming that you want to transform elements of an Armadillo vector or matrix, copying the data from the matrix to a newly allocated array may not be desirable (or it might be, depending on the performance hit incurred by not using fftw_malloc). Then, your C++ code should be something like
   I'm by no means an expert, but this snippet works beautifully in my own code.
   Please feel free to point out any factual errors.
Update: Note that the operations in the Gist do not commute, i.e. the order in which they are done is important. If you put data in the samples matrix before creating the plan, your columns will be overwritten. Pay attention!

Thursday, January 24, 2013

Arrow in the Knee: the Genesis

    So my wife was re-reading the epic fantasy pentalogy The Belgariad by David Eddings [1]. It's a fantastic coming-of-age, prophecy-fulfilling, magic-filled story. Every character is fully developed and they are all thoroughly likable.

    But now to the important part. In the Queen of Sorcery book [2,p.222], originally published in 1982, it is revealed that Count Reldegen, an Asturian, is limping. This sparks the following conversation:
"What happened to your leg?" Wolf asked him.
"An arrow in the knee." The count shrugged.
Yes, that's right, an arrow in the knee!

   Now go read The Belgariad so you know why it matters that Reldegen is an Asturian.

[1] Amateurish introductory line, I know.
[2] D. Eddings. Queen of Sorcery in The Belgariad. 2002. New York: Ballantine.

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.