Before we start with the serious coding, we need to decide on the mathematics libraries to use. Two components are needed:
A library for matrix handling. Performance has a lower priority than ease of use. The library needs to be able to:
A library for doing the Fast Fourier Transform
Your task: Look for some libraries, read the documentation/play around with them, and post a summary to the mailing list. Preferably, assemble a small Hello World project that demonstrates the use of the libraries.
After just looking at freecode and filtering out projects without releases for years, I got for the matrix libraries:
Eigen
IT++
Seldon
Aramdillo
Last edit: Anonymous 2012-12-26
All the matrix libraries seem to deal only with matrices, which is bad; we would like to operate with tensors and would have to wrap the matrices up in some way, which is complicated.
TODO: another search for tensor libraries.
After another search for tensor libraries, I ended up with the following candidates:
Tensor C++ library; looks like a smaller library
ITensor; looks cute, not too big, and pretty much exactly what I was thinking about (also used for electronic structure problems), no idea how good an FFT conncetion could be done.
Portable science toolkit; looks like overkill, but maybe it is nice?
GSL tensor extensions; GSL is a pretty standard library, so maybe this is worth a try.
Sort summary after a bit more digging:
GSL looks bad. No documentation, clunky C interface and no releases for two years.
Portable science toolkit looks a bit like overkill. More on the side of massively parallel solvers that can also be run on a single machine. Many dependencies and such. On the other hand, there is an interface to MPI and GPU calculations... Will try it out if time and interest remains.
ITensor and Tensor C++ library look good. Clean interface, easy usage, even unit testing.
Now I need to develop some test cases...
Suggestion for the test case:
A two-dimensional problem, so that the wave function is a tensor of rank 2. Let us call the degrees of freedom "x" and "y".
Create some testing wave function X(x,y); random numbers are fine.
Typical use-case: Apply an operator A that acts only along x. Create a 2D tensor A(x,x') that corresponds to the operator, and apply it in a generic way to the wave function X'{ij} = sum_k A{ik} X_{kj}
Typical usage: Apply a potential energy operator B (element-wise multiplication). Create a tensor B(x,y) and create X'{ij} = B{ij} * X_{ij}
Typical usage: Calculate an expectation value. Needs a 1-D array x, assume a homogeneous weight h along y and a weight array w along x, and calculate <x> = sum_{ij} conj(X_{ij}) * x_i * X_{ij} * w_i * h.
Typical usage: Standard functions (exponentials). Take a tensor T and calculate exp(T), elementwise multiplication of two tensors, slicing (setting/getting a slice), tensor product (get a 2D-tensor as the dyadic product of two 1-D tensors).
Check connection to FFT algorithms.
Calculate eigenvalues of a Hamiltonian. Set up a Hamiltonian H(x,x') (use 1-D problem for simplicity), and calculate eigenvalues; how is connection to LAPACK?
Try out sparse tensors.
Last edit: Anonymous 2013-01-12
Issues with the Tensor C++ library:
Edit: A new checkout compiled and ran fine; no idea what was wrong. The last bug was in my testing script (never use nx and ny, they look too similar ...)
Last edit: Anonymous 2013-01-27
Next: Itensor.
Issues encountered so far:
To be continued...
Since I could not easily install ITensor, I decided to instead have a look at the code, especially at the tests........Do all C++ developers have to write such ugly code?
Looking at some headers, I can judge the following:
After finally compiling the library on a cluster at work and trying it out, two more things:
To say also something good: There are a couple of interesting functions, for example tieing indices together (taking a 3D-tensor A_ijk and making a 2D-Tensor A_xk from it; that is something that I was missing in Matlab once).
Final verdict: The library is probably ok for Density Matrix Renormalization Groups, where you create high-dimensional tensors with few entries in each direction (spins, i.e., 2 in the examples) and want to contract them here and there. But I am not quite sure how far it matches our use-case.
Selected Tensor C++ library.
This project has moved to github now:
https://github.com/juanjosegarciaripoll/tensor
The FFT part will also be done later. In principle, you can do a FT with a matrix multiplication; this is not fast, but it works. So the FFT part should be deferred in favor of getting ahead.