Registered Member
|
I tried the following to permute one matrix and vector:
The expected result is something similar to: Atilde = [ A(1, 1), A(1, 2), A(1,0), A(1, 3); A(2, 1), A(2, 2), A(2,0), A(2, 3); A(0, 1), A(0, 2), A(0,0), A(0, 3); A(3, 1), A(3, 2), A(3, 0), A(3, 3)]; and btilde = [b(1); b(2); b(0); b(3)]. But I got the wrong result, e.g. btilde = [b(0); b(2); b(1); b(3)], Atilde = [A(0, 0), A(0, 2), ......]. Do Eigen's permutation matrices work in the different way? How can I do the intended operations? Thanks in advance. |
Moderator
|
then you need to compute:
P.inverse()*A*P; P.inverse()*b; because P is the permutation:
(each number indicates for each column the row number containing '1') |
Registered Member
|
Thanks, ggael~
I did some experiments, and found out something worth commenting. When I tested the following code:
it seems that the result depends on the number of swaps of the permutation. When the permutation includes one swap (e.g. Z << 2, 1, 0, 3;), I have the following result which shows that everything works fine.
However, when the permutation includes two swap (e.g. Z << 1, 2, 0, 3;), I have the following result which shows that P*A*P.inverse() and P*b does not work fine.
|
Registered Member
|
Another comments:
When the permutation includes three swaps, e.g. Z << 1, 2, 3, 0, the result is as follows:
All these corroborates that you are correct. We have to use P*inverse()*A*P and P*inverse()*b always. Thanks.
|
Moderator
|
This is because in your special case "Z << 2, 1, 0, 3", the permutation is symmetric, and P = P^T = P^-1 .
|
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]