Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LRT_infinite_dimensional_systems
conI
Commits
609d63b1
Commit
609d63b1
authored
Oct 29, 2020
by
Jakob Gabriel
Browse files
misc.permute2blockTriangle: new output argument for permutation indices
parent
a4537ba8
Changes
1
Hide whitespace changes
Inline
Side-by-side
+misc/permute2blockTriangle.m
View file @
609d63b1
function
[
triangularMatrix
,
permutationMatrix
]
=
permute2blockTriangle
(
A
)
function
[
triangularMatrix
,
permutationMatrix
,
permutationIdx
]
=
permute2blockTriangle
(
A
)
% MISC.PERMUTE2BLOCKTRIANGLE permutes the matrix A, if possible, to a lower block triangular matrix.
% The implementation is based on using methods for digraphs, see matlab documentation for digraph.
%
...
...
@@ -8,6 +8,10 @@ function [triangularMatrix, permutationMatrix] = permute2blockTriangle(A)
% permutation matrix such that
% triangularMatrix = permutationMatrix * A * permutationMatrix.'
%
% [triangularMatrix, permutationMatrix, permutationIdx] = misc.permute2blockTriangle(A) also
% returns the double array permutationIdx, which contains the indexes for the permutation of
% columns of A.
%
% Note that inv(permutationMatrix) = permutationMatrix.' (which holds for all so-called
% permutation matrices).
...
...
@@ -19,13 +23,13 @@ myDiagraph = digraph(A);
% As agentsBlockNumber defines which agent belongs to which group, the following for loop defines
% how they will be sorted.
sort
Idx
=
zeros
(
size
(
A
,
1
),
1
);
permutation
Idx
=
zeros
(
size
(
A
,
1
),
1
);
for
blockIdx
=
numel
(
blockSize
)
:
-
1
:
1
sort
Idx
(
sum
(
blockSize
(
numel
(
blockSize
):
-
1
:(
blockIdx
+
1
)))
+
(
1
:
blockSize
(
blockIdx
)),
1
)
...
permutation
Idx
(
sum
(
blockSize
(
numel
(
blockSize
):
-
1
:(
blockIdx
+
1
)))
+
(
1
:
blockSize
(
blockIdx
)),
1
)
...
=
find
(
agentsBlockNumber
-
blockIdx
==
0
);
end
permutationMatrix
=
full
(
sparse
(
1
:
1
:
size
(
A
,
1
),
sort
Idx
,
1
));
permutationMatrix
=
full
(
sparse
(
1
:
1
:
size
(
A
,
1
),
permutation
Idx
,
1
));
triangularMatrix
=
permutationMatrix
*
A
*
permutationMatrix
.'
;
end
% permute2blockTriangle()
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment