Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 401
user2638923 Avatar asked Oct 03 '22 09:10

user2638923


1 Answers

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.

like image 143
Svaberg Avatar answered Oct 12 '22 12:10

Svaberg