Diagonalization of a complex hermitian matrix in c++ - c++

I need to find a piece of code that will diagonalize a complex hermitian matrix. The size I'm looking at will be ranging from 3x3 to 30x30. Any help would be great, I'm a little new to c++. Please could you post links to the code rather than a description of where to find it if possible. Thanks!

A simple google search would have given the answer. Nonetheless you can start with
http://www.netlib.org/lapack++/
http://www.gnu.org/software/gsl/
http://www.mpi-hd.mpg.de/personalhomes/globes/3x3/
http://www.nrbook.com/empanel/

Related

Is there a BLAS/LAPACK function for calculating Cholesky factor updates?

Let A be a positive definite matrix, and let A=L*L' be its cholesky factorization, where L is lower triangular.
Let A2 = A + alpha*x*x' be a rank-1 update of matrix A, where x is a vector of appropriate dimension and alpha is a scalar.
The Cholesky factor update is a procedure for obtaining the factorization A2=L2*L2' without calculating A2 first, which is useful to speed up computations in the case of such low-rank matrix updates.
I am using BLAS/LAPACK libraries for elementary algebra manipulations. I can calculate the Cholesky factorization of a positive definite matrix with the routine spptrf. However, I have been looking around and I have not been able to find a BLAS/LAPACK function which performs Cholesky factor updates. May it be that there is not function doing so?
Additionally: In this old post, the addition of such routine was discussed. However, it is a very old post (2013) and I have not been able of finding anything more recent.
There is no such function. You can look at this discussion we had on SciPy. I've made up a Python script that does the update with the relevant paper. You can make use of those information.
https://github.com/scipy/scipy/issues/8188
If you feel competitive and actually write the Fortran code for this, I would really appreciate if you can submit it to LAPACK repo as a PR https://github.com/Reference-LAPACK/lapack
The BLAS libraries on Netlib as you pointed out however I doubt it is on the site. If you are looking for code simply there is code here.
If you want it fast I'd just turn that code into Julia. There is a book I've never checked out which may have these in it. Also, note you cited a paper that the author wrote the code for. You could have simply contacted the author of the paper. His website appears to be here. There is a problem with that link though.

reproducing a tensor matrix with eigen library

I'm facing a little problem. I'm translating a program from matlab/octave to C++. This progam is dealing with some matrix manipulation. I want to reproduce this : in matlab/octave we can define a matrix like :
matrix = zeros(10,25,360);
and I get a matrix with 10 rows, 25 columns and a "depth" of 360. I want to reproduce the same thing in C++ using Eigen.
Thank you in advance for your help.
There are unsupported Modules for Eigen which let you define tensors. With those modules you can translate your problem into C++.
The current Eigen tensor module is extremely limited feature wise. You can't even add the coefficients of 2 tensors together! I have been using the tensor code in this fork of Eigen instead. It adds support for coefficient wise operations, convolutions, contractions, and recently morphing primitives such as slicing. Moreover it can take advantage of GPUs to speed things up which was the big selling point for me.
There is a pending pull request so hopefully it will make its way into the main Eigen code base soon.

What is a fast simple solver for a large Laplacian matrix?

I need to solve some large (N~1e6) Laplacian matrices that arise in the study of resistor networks. The rest of the network analysis is being handled with boost graph and I would like to stay in C++ if possible. I know there are lots and lots of C++ matrix libraries but no one seems to be a clear leader in speed or usability. Also, the many questions on the subject, here and elsewhere seem to rapidly devolve into laundry lists which are of limited utility. In an attempt to help myself and others, I will try to keep the question concise and answerable:
What is the best library that can effectively handle the following requirements?
Matrix type: Symmetric Diagonal Dominant/Laplacian
Size: Very large (N~1e6), no dynamic resizing needed
Sparsity: Extreme (maximum 5 nonzero terms per row/column)
Operations needed: Solve for x in A*x=b and mat/vec multiply
Language: C++ (C ok)
Priority: Speed and simplicity to code. I would really rather avoid having to learn a whole new framework for this one problem or have to manually write too much helper code.
Extra love to answers with a minimal working example...
If you want to write your own solver, in terms of simplicity, it's hard to beat Gauss-Seidel iteration. The update step is one line, and it can be parallelized easily. Successive over-relaxation (SOR) is only slightly more complicated and converges much faster.
Conjugate gradient is also straightforward to code, and should converge much faster than the other iterative methods. The important thing to note is that you don't need to form the full matrix A, just compute matrix-vector products A*b. Once that's working, you can improve the convergance rate again by adding a preconditioner like SSOR (Symmetric SOR).
Probably the fastest solution method that's reasonable to write yourself is a Fourier-based solver. It essentially involves taking an FFT of the right-hand side, multiplying each value by a function of its coordinate, and taking the inverse FFT. You can use an FFT library like FFTW, or roll your own.
A good reference for all of these is A First Course in the Numerical Analysis of Differential Equations by Arieh Iserles.
Eigen is quite nice to use and one of the fastest libraries I know:
http://eigen.tuxfamily.org/dox/group__TutorialSparse.html
There is a lot of related post, you could have look.
I would recommend C++ and Boost::ublas as used in UMFPACK and BOOST's uBLAS Sparse Matrix

Working with Matlab functions in C++ (for matrix searching)

What I want to do is searching a 2d matrix inside a bigger 2d matrix. For that, I have found a 2d version of Boyer-Moore algorithm.
But working with matrices in matlab is always easier, so I was wondering if I can call matlab functions in a C++ compiler.
i think people here know how to do it in matlab.
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247971
Is there a library or something that exists for this purpose? which contains at least the functions used by the programs given in the link above.
PS: if anybody can provide the solution for this searching problem, please do it.
Here's what you are looking for in the Matlab documentation
I don't know of any libraries for this, you might have more luck checking the matlab website to see if they sell development libraries.
As for a solution, this problem seems conceptually very similar to that of finding substrings in strings. I found this while searching briefly, I'm sure it could help.
As for a basic solution, one could go something like this:
You want to find an p x q submatrix inside an n x m matrix.
for each row (up to row n - p):
search each column (up to column m - q)
if value in matrix equals first value check the rest of the submatrix
if submatrix found, exit or store solution and keep looking for more

c++ petsc matrix inversion

can any one share with me a few different example of dense matrix inversion's with Petsc. I searched the web and could only find algorithm's and no solid examples with code. Thank you
In their documentation. They seems to say which function to call when.
You can find it here.
Also, I found a manual that provides multiples code example that you might want to look at.
Hope it helps!