Extract the symetric matrix built-in another matrix

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












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.










share|improve this question





















  • 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














up vote
1
down vote

favorite
1












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.










share|improve this question





















  • 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












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 maybe Scan can be used to collect the non-negative symmetric positions in M.
    – Tugrul Temel
    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















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










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]]];





share|improve this answer




















  • 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 fullfills A==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 your code gives me what I wanted. I checked it with other examples and it works.
    – Tugrul Temel
    53 mins ago

















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





share|improve this answer




















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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]]];





    share|improve this answer




















    • 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 fullfills A==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 your code gives me what I wanted. I checked it with other examples and it works.
      – Tugrul Temel
      53 mins ago














    up vote
    1
    down vote



    accepted










    Maybe this is what you are looking for:



    A = M Subtract[1, Unitize[Subtract[Transpose[M], M]]];





    share|improve this answer




















    • 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 fullfills A==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 your code gives me what I wanted. I checked it with other examples and it works.
      – Tugrul Temel
      53 mins ago












    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]]];





    share|improve this answer












    Maybe this is what you are looking for:



    A = M Subtract[1, Unitize[Subtract[Transpose[M], M]]];






    share|improve this answer












    share|improve this answer



    share|improve this answer










    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 fullfills A==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 your code 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






    • 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






    • 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 your code 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










    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





    share|improve this answer
























      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





      share|improve this answer






















        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





        share|improve this answer












        Maybe a bit simpler:



        M Transpose[M]


        Comparing with Henrik's answer:



        M Subtract[1, Unitize[Subtract[Transpose[M], M]]] == M Transpose[M]
        True






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 44 mins ago









        bill s

        51.9k375146




        51.9k375146



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery