Extract the symetric matrix built-in another matrix
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Suppose that I have a matrix M
:
M=
0,1,1,0,1,0,
1,0,0,1,1,1,
1,1,0,0,1,0,
0,1,1,0,0,0,
1,0,0,1,0,1,
1,1,1,1,0,0
;
I like to extract from M
the symmetric matrix symM
:
symM=
0, 1, 1, 0, 1, 0,
1, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0
;
I do not want to use Do
or If
commands. I like to implement matrix operations to extract the symmetric part of M
.
matrix
add a comment |Â
up vote
1
down vote
favorite
Suppose that I have a matrix M
:
M=
0,1,1,0,1,0,
1,0,0,1,1,1,
1,1,0,0,1,0,
0,1,1,0,0,0,
1,0,0,1,0,1,
1,1,1,1,0,0
;
I like to extract from M
the symmetric matrix symM
:
symM=
0, 1, 1, 0, 1, 0,
1, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0
;
I do not want to use Do
or If
commands. I like to implement matrix operations to extract the symmetric part of M
.
matrix
Do you have a particular algorithm in mind?
– corey979
1 hour ago
@corey979: I do not have any algorithm in mind but maybeScan
can be used to collect the non-negative symmetric positions inM
.
– Tugrul Temel
1 hour ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Suppose that I have a matrix M
:
M=
0,1,1,0,1,0,
1,0,0,1,1,1,
1,1,0,0,1,0,
0,1,1,0,0,0,
1,0,0,1,0,1,
1,1,1,1,0,0
;
I like to extract from M
the symmetric matrix symM
:
symM=
0, 1, 1, 0, 1, 0,
1, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0
;
I do not want to use Do
or If
commands. I like to implement matrix operations to extract the symmetric part of M
.
matrix
Suppose that I have a matrix M
:
M=
0,1,1,0,1,0,
1,0,0,1,1,1,
1,1,0,0,1,0,
0,1,1,0,0,0,
1,0,0,1,0,1,
1,1,1,1,0,0
;
I like to extract from M
the symmetric matrix symM
:
symM=
0, 1, 1, 0, 1, 0,
1, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0
;
I do not want to use Do
or If
commands. I like to implement matrix operations to extract the symmetric part of M
.
matrix
matrix
asked 1 hour ago


Tugrul Temel
582113
582113
Do you have a particular algorithm in mind?
– corey979
1 hour ago
@corey979: I do not have any algorithm in mind but maybeScan
can be used to collect the non-negative symmetric positions inM
.
– Tugrul Temel
1 hour ago
add a comment |Â
Do you have a particular algorithm in mind?
– corey979
1 hour ago
@corey979: I do not have any algorithm in mind but maybeScan
can be used to collect the non-negative symmetric positions inM
.
– Tugrul Temel
1 hour ago
Do you have a particular algorithm in mind?
– corey979
1 hour ago
Do you have a particular algorithm in mind?
– corey979
1 hour ago
@corey979: I do not have any algorithm in mind but maybe
Scan
can be used to collect the non-negative symmetric positions in M
.– Tugrul Temel
1 hour ago
@corey979: I do not have any algorithm in mind but maybe
Scan
can be used to collect the non-negative symmetric positions in M
.– Tugrul Temel
1 hour ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Maybe this is what you are looking for:
A = M Subtract[1, Unitize[Subtract[Transpose[M], M]]];
Yes...That is what I wanted to have. Perfect...
– Tugrul Temel
1 hour ago
1
@HenrikSchumacher For the symmetric part of M I would have expected something like(M+Transpose[M])/2
...Interestingly your result fullfillsA==Floor[(M+Transpose[M])/2]
!
– Ulrich Neumann
1 hour ago
1
@UlrichNeumann(M+Transpose[M])/2
is the symmetrized part, and in particular the orthogonal projection onto the linear space of symmetric matrices (orthogonal with respect to the Frobenius metric). But as by OP's examples, this was not what the OP asked for.
– Henrik Schumacher
1 hour ago
@Henrik: Referring to your last point, you are right that yourcode
gives me what I wanted. I checked it with other examples and it works.
– Tugrul Temel
53 mins ago
add a comment |Â
up vote
2
down vote
Maybe a bit simpler:
M Transpose[M]
Comparing with Henrik's answer:
M Subtract[1, Unitize[Subtract[Transpose[M], M]]] == M Transpose[M]
True
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Maybe this is what you are looking for:
A = M Subtract[1, Unitize[Subtract[Transpose[M], M]]];
Yes...That is what I wanted to have. Perfect...
– Tugrul Temel
1 hour ago
1
@HenrikSchumacher For the symmetric part of M I would have expected something like(M+Transpose[M])/2
...Interestingly your result fullfillsA==Floor[(M+Transpose[M])/2]
!
– Ulrich Neumann
1 hour ago
1
@UlrichNeumann(M+Transpose[M])/2
is the symmetrized part, and in particular the orthogonal projection onto the linear space of symmetric matrices (orthogonal with respect to the Frobenius metric). But as by OP's examples, this was not what the OP asked for.
– Henrik Schumacher
1 hour ago
@Henrik: Referring to your last point, you are right that yourcode
gives me what I wanted. I checked it with other examples and it works.
– Tugrul Temel
53 mins ago
add a comment |Â
up vote
1
down vote
accepted
Maybe this is what you are looking for:
A = M Subtract[1, Unitize[Subtract[Transpose[M], M]]];
Yes...That is what I wanted to have. Perfect...
– Tugrul Temel
1 hour ago
1
@HenrikSchumacher For the symmetric part of M I would have expected something like(M+Transpose[M])/2
...Interestingly your result fullfillsA==Floor[(M+Transpose[M])/2]
!
– Ulrich Neumann
1 hour ago
1
@UlrichNeumann(M+Transpose[M])/2
is the symmetrized part, and in particular the orthogonal projection onto the linear space of symmetric matrices (orthogonal with respect to the Frobenius metric). But as by OP's examples, this was not what the OP asked for.
– Henrik Schumacher
1 hour ago
@Henrik: Referring to your last point, you are right that yourcode
gives me what I wanted. I checked it with other examples and it works.
– Tugrul Temel
53 mins ago
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Maybe this is what you are looking for:
A = M Subtract[1, Unitize[Subtract[Transpose[M], M]]];
Maybe this is what you are looking for:
A = M Subtract[1, Unitize[Subtract[Transpose[M], M]]];
answered 1 hour ago


Henrik Schumacher
43.2k262127
43.2k262127
Yes...That is what I wanted to have. Perfect...
– Tugrul Temel
1 hour ago
1
@HenrikSchumacher For the symmetric part of M I would have expected something like(M+Transpose[M])/2
...Interestingly your result fullfillsA==Floor[(M+Transpose[M])/2]
!
– Ulrich Neumann
1 hour ago
1
@UlrichNeumann(M+Transpose[M])/2
is the symmetrized part, and in particular the orthogonal projection onto the linear space of symmetric matrices (orthogonal with respect to the Frobenius metric). But as by OP's examples, this was not what the OP asked for.
– Henrik Schumacher
1 hour ago
@Henrik: Referring to your last point, you are right that yourcode
gives me what I wanted. I checked it with other examples and it works.
– Tugrul Temel
53 mins ago
add a comment |Â
Yes...That is what I wanted to have. Perfect...
– Tugrul Temel
1 hour ago
1
@HenrikSchumacher For the symmetric part of M I would have expected something like(M+Transpose[M])/2
...Interestingly your result fullfillsA==Floor[(M+Transpose[M])/2]
!
– Ulrich Neumann
1 hour ago
1
@UlrichNeumann(M+Transpose[M])/2
is the symmetrized part, and in particular the orthogonal projection onto the linear space of symmetric matrices (orthogonal with respect to the Frobenius metric). But as by OP's examples, this was not what the OP asked for.
– Henrik Schumacher
1 hour ago
@Henrik: Referring to your last point, you are right that yourcode
gives me what I wanted. I checked it with other examples and it works.
– Tugrul Temel
53 mins ago
Yes...That is what I wanted to have. Perfect...
– Tugrul Temel
1 hour ago
Yes...That is what I wanted to have. Perfect...
– Tugrul Temel
1 hour ago
1
1
@HenrikSchumacher For the symmetric part of M I would have expected something like
(M+Transpose[M])/2
...Interestingly your result fullfills A==Floor[(M+Transpose[M])/2]
!– Ulrich Neumann
1 hour ago
@HenrikSchumacher For the symmetric part of M I would have expected something like
(M+Transpose[M])/2
...Interestingly your result fullfills A==Floor[(M+Transpose[M])/2]
!– Ulrich Neumann
1 hour ago
1
1
@UlrichNeumann
(M+Transpose[M])/2
is the symmetrized part, and in particular the orthogonal projection onto the linear space of symmetric matrices (orthogonal with respect to the Frobenius metric). But as by OP's examples, this was not what the OP asked for.– Henrik Schumacher
1 hour ago
@UlrichNeumann
(M+Transpose[M])/2
is the symmetrized part, and in particular the orthogonal projection onto the linear space of symmetric matrices (orthogonal with respect to the Frobenius metric). But as by OP's examples, this was not what the OP asked for.– Henrik Schumacher
1 hour ago
@Henrik: Referring to your last point, you are right that your
code
gives me what I wanted. I checked it with other examples and it works.– Tugrul Temel
53 mins ago
@Henrik: Referring to your last point, you are right that your
code
gives me what I wanted. I checked it with other examples and it works.– Tugrul Temel
53 mins ago
add a comment |Â
up vote
2
down vote
Maybe a bit simpler:
M Transpose[M]
Comparing with Henrik's answer:
M Subtract[1, Unitize[Subtract[Transpose[M], M]]] == M Transpose[M]
True
add a comment |Â
up vote
2
down vote
Maybe a bit simpler:
M Transpose[M]
Comparing with Henrik's answer:
M Subtract[1, Unitize[Subtract[Transpose[M], M]]] == M Transpose[M]
True
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Maybe a bit simpler:
M Transpose[M]
Comparing with Henrik's answer:
M Subtract[1, Unitize[Subtract[Transpose[M], M]]] == M Transpose[M]
True
Maybe a bit simpler:
M Transpose[M]
Comparing with Henrik's answer:
M Subtract[1, Unitize[Subtract[Transpose[M], M]]] == M Transpose[M]
True
answered 44 mins ago


bill s
51.9k375146
51.9k375146
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184809%2fextract-the-symetric-matrix-built-in-another-matrix%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Do you have a particular algorithm in mind?
– corey979
1 hour ago
@corey979: I do not have any algorithm in mind but maybe
Scan
can be used to collect the non-negative symmetric positions inM
.– Tugrul Temel
1 hour ago