[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] add SparseView
- From: Daniel Lowengrub <lowdanie@xxxxxxxxx>
- Date: Mon, 14 Jun 2010 14:38:06 +0300
- Cc: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=i72YAuPbSBFmFKoCtP9ck9vxaWU09jtDLoH8h6ji7/Y=; b=WTB+uzgbtR/5SLC3WdBwaLy69cqG+8xJYhwUGQLAa6iOhgbs8ZntB3Ke5znlKh91V7 0ZkWQnwCcHbLkn3RVCjJndpa4VX6c+KFSPfkGxkQf8Lawe8UCe2EKmlP9w1mRE8aknhd JmORPWI7c4HUq9yoQWpsB//f4Zt2X00Dm4SvY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=jA7NTr4MZXbIwxSOdInozMhGyvVyPW82SssFWOldZH0Lv8rzaRJiRbH59aHAn4RemV e0UYiXyvYCzerJ+W3oMGAy5AifuaQpzsn1Y8cN0hjc8tZkByWfIiNNQSKis5K3SZQPmF U3iNbzM0BuHS1nX6JJ08H5/SZ2Wj5pLB13CEA=
Hi,
I just added a SparseView class to the Sparse module.
Usage:
If d_mat is a DenseStorage matrix or expression then the sparseView
method makes it compatible with Sparse types. For example:
Matrix3d m3,m4;
Eigen::SparseMatrix<double> smat(3,3);
m3 << 1, 0, 0, 2, 0, 0, 7, 2, 0;
m4 << 0, 6, 0, 0, 0, 5, 0, 0, 4;
smat = (m3*m4 + m3).sparseView();
std::cout << smat;
outputs:
Nonzero entries:
(1,0) (2,1) (7,2) (6,0) (12,1) (44,2) (10,2)
Column pointers:
0 3 6 $
[and other sparse info]
In addition, a reference variable and an epsilon variable may be
passed which determine the threshold for which values will be ignored
by the sparse matrix:
smat = (m3*m4 + m3).sparseView(reference);
and:
smat = (m3*m4 + m3).sparseView(reference, epsilon);