how to convert UMFpack sparse matrix to Eigen sparse matrix? - visual-studio

I have a code that was written to use UMFpack sparse matrix solver but need to convert it to Eigen sparse matrix but I am running into memory problems.
I have Ai (row pointers), Ap (column pointers) and Ax (array). Trying to solve Ax=b. How can I pass these pointers and Ax or change them for Eigen?

Related

Tensorflow: Operations With Block-diagonal Matrices

I'm looking for a way to implement block-diagonal matrices in Tensorflow. Specifically, I have block-diagonal matrix A with N blocks of size S x S each. Further, I have a vector v of length N*S. I want to calculate A dot v. Is there any efficient way to do it in Tensorflow?
Also, I would prefer the implementation which supports a batch dimension of v (e.g. its real dimension is batch_size x (N*S)) and which is memory efficient, keeping in memory only block-diagonal parts of A.
Thanks for any help!
You can simply convert your tensor to a sparse tensor since a block-diagonal matrix is just a special case of it. Then, the operations are done in a efficient way. If you already have a dense representation of the tensor you can just cast it using sparse_tensor = tf.contrib.layers.dense_to_sparse(dense_tensor). Otherwise, you can construct it with the tf.SparseTensor(...) function. To get the indices, you might use tf.strided_slice, see this post for more information.

Eigen SVD with very large matrix

I need to calculate the SVD with a very large matrix of complex numbers.
The matrix dimensions are [260000][570].
By using the EIGEN libs I have defined:
MatrixXcf Lop_tmp
(even if MatrixXcd would be better).
However, I'm able to instantiate Lop_tmp but the SVD crashed (bad alloc) when invoked in this way:
Eigen::BDCSVD<Eigen::MatrixXcf> svd(Lop_tmp.transpose(), Eigen::ComputeThinU | Eigen::ComputeThinV);
Supposing not to partitiong the algoritm, is there a way to compute the Eigen SVD with this Lop_tmp?
Thank you!

How to manipulate Compressed Sparse Row Format (CSR) matrix

I have some NxN symmetric matrix A, and I want to extract the elements of this matrix and construct it with several matrices. For example,
A_1 = A(1:10,1:10), A_2 = A(11:N, 11:N), A_3 =(1:10,11:N).
In the case of MATLAB, the sparse matrix can also be written as above. However, in my Fortran code, it can not be written as above because matrix A is stored in CSR format. Moreover, all matrices have to be saved in CSR format. What should I do in this case?
Question: Is there any library like MATLAB sparse function that makes it easy to handle sparse matrices available in Fortran?
Thanks.

compute determinant of complex matrix fortran90

I need to compute the determinant of complex matrix which is symmetric. Size of matrix ranges from 500*500 to 2000*2000. Is there any subroutine for me to call? By the way, I use ifort to compile.
The easiest way would be to do an LU-decomposition as described here. I would suggest using LAPACK for this task...
This article has some code in C doing that for a real-valued symmetric matrix, so you need to exchange dspsv by zspsv to handle double-precision complex matrices.

Armadillo c++: Is there a specific way for creating efficiently triangular or symmetric matrix

I am using armadillo mostly for symmetric and triangular matrices. I wanted to be efficient in terms of memory storage. However, it seems there is no other way than to create a new mat and fill with zeros(for triangular) or with duplicates(for symmetric) the lower/upper part of the matrix.
Is there a more efficient way of using triangular/symmetric matrices using Armadillo?
Thanks,
Antoine
There is no specific support for triangular or banded matrices in Armadillo. However, since version 3.4 support for sparse matrices has gradually been added. Depending on what Armadillo functions you need, and the sparsity of your matrix, you might gain from using SpMat<type> which implements the compressed sparse column (CSC) format. For each nonzero value in your matrix the CSC format stores the row index along with the value so you would likely not save much memory for a triangular matrix. A banded diagonal matrix should however consume significantly less memory.
symmatu()/symmatl() and trimatu()/trimatl()
may be what you are looking for:
http://arma.sourceforge.net/docs.html

Resources