Re: [eigen] row and col setZero in sparse matrices |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] row and col setZero in sparse matrices*From*: Daniel Alves Paladim <daalpa@xxxxxxxxx>*Date*: Tue, 22 Apr 2014 16:05:10 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=j6JuTQ7jFcnpNExWEwnoB6Cpqus+VvpGDig3/iJz2qA=; b=Ib3hc2Td4C2QdRu2YI8beEA+FC5IMM9UlHYR3zISpSPfm3jNKzlUnjjCqgAAW0SgQi 8L0he2URL8kQk/Jx9phzIaZeAH0P50xkYGbaKE8HBfpk+GCM1azdr4+K96urehnCGlwv aVDsk41FsPgdmtSVoQYjpJb+x4VsfDJMr88ihzuyyEnRQN9tV8oQTUeCCqp3sxfNJm4q yYwA201Agcx3odbaCUHx0/tGIQ8kVTArGi+A17KBhzk8e7aUMesHSQqEyTONWoqn2fut mEykPOW1ikD9dZa55JLCW0ABg74ZSHINblmR5FdszkIkC+qbhoOu0R58q4tAmZyqmCzu +NGQ==

Thanks Gael, I understand. I was not aware of the permutation matrices in Eigen. That's a good idea. Since, I am doing finite elements, I have switched to applying the boundary conditions for every element matrix.

2014-04-22 15:55 GMT+01:00 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:

Hi,sorry for late reply. I agree this would be convenient, but this would also be pretty slow, especially if you fix several values this ways. If A is column major:b-=value*A.col(dof);-> fineA.col(dof).setZero();

-> fine if we keep the memory allocated for col(dof), otherwise all remaining columns have to be copied to keep a compact storage.A.row(dof).setZero();This is basically a O(nnz) operation, so pretty costly if you do it multiple times.A.coeffRef(dof,dof)=1.0;-> fine if we kept a non-compact storageSince in most cases you want to fix several unkowns, I usually build a permutation matrix P, permute A in a symmetric fashion (A1 = A.twistedBy(P)), and then pick sub matrices to solve:A1.topLeftCorner(....) * x1.head(...) = b.head(...) - A1.topRightCorner(...) * valuesand then apply P.inverse() on x1 to get x.gael

**References**:**[eigen] row and col setZero in sparse matrices***From:*Daniel Alves Paladim

**Re: [eigen] row and col setZero in sparse matrices***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] row and col setZero in sparse matrices** - Next by Date:
**[eigen] AVX support and matrix product updates** - Previous by thread:
**Re: [eigen] row and col setZero in sparse matrices** - Next by thread:
**[eigen] is there a policy on committing bugfixes to a release branch?**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |