This forum has been archived. All content is frozen. Please use KDE Discuss instead.

SparseMatrix diagonal modification

Tags: None
(comma "," separated)
inspirit
Registered Member
Posts
15
Karma
0

SparseMatrix diagonal modification

Sat Jan 02, 2016 10:09 am
Hello,

I'm trying to modify diagonal values of Sparse Matrix:
Code: Select all
// AtA - Sparse Matrix

AtA.diagonal() += 100; // doesn't work

VectorXf diagonal = VectorXf::Ones(10000) * 100;
AtA += diagonal.asDiagonal(); // doesn't work as well


What is the way to add constant Scalar to all diagonal values?
If some diagonal values are missing it should be added and set to Scalar.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This should work:

AtA.diagonal().array() += constant;


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft