How to find the largest rectangular submatrix












3












$begingroup$


I have a sparse non-symmetric binary matrix with a block structure. The dimensions of the matrix are thousands long x less than one hundred wide.



How do I identify the largest non-contiguous rectangular sub-matrix consisting only of 1-entries?



edit: The pattern is either very sparse, or there are very few large submatrices, however the blocks are likely to overlap.



In the simplified example below, it would be elements {2,4} towards {6,6}.




$mat=left( begin{array}{ccc}
1&1&1&1&0&0\
1&1&1&1&1&1\
0&0&0&1&1&1\
1&1&0&1&1&1\
1&1&1&1&1&1\
1&1&1&1&1&1\
end{array} right)$











share|improve this question











$endgroup$












  • $begingroup$
    How is this related to graphs and networks? Might there be an additional structure behind the matrix? For example, if mat is an adjacency matrix of a graph, you might be looking for a maximal complete subgraph or a clique. Szabolcs' package "IGraphM`" has tools for that...
    $endgroup$
    – Henrik Schumacher
    2 hours ago








  • 1




    $begingroup$
    You still want to solve the problem for general binary matrices? (It is not unlikely that his discrete optimization problem is a very hard...)
    $endgroup$
    – Henrik Schumacher
    2 hours ago






  • 1




    $begingroup$
    If you want non-contiguous too, then this is indeed the clique problem, which is NP-complete, and there's not going to be a simpler solution. Use FindClique, then filter for blocks that also have 1s on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago








  • 1




    $begingroup$
    Before FindClique, remove every row/column that has a 0 on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago






  • 1




    $begingroup$
    I added the size (thousands long, less than a hundred wide and that I am looking for non-contiguous solutions.
    $endgroup$
    – Sander
    1 hour ago
















3












$begingroup$


I have a sparse non-symmetric binary matrix with a block structure. The dimensions of the matrix are thousands long x less than one hundred wide.



How do I identify the largest non-contiguous rectangular sub-matrix consisting only of 1-entries?



edit: The pattern is either very sparse, or there are very few large submatrices, however the blocks are likely to overlap.



In the simplified example below, it would be elements {2,4} towards {6,6}.




$mat=left( begin{array}{ccc}
1&1&1&1&0&0\
1&1&1&1&1&1\
0&0&0&1&1&1\
1&1&0&1&1&1\
1&1&1&1&1&1\
1&1&1&1&1&1\
end{array} right)$











share|improve this question











$endgroup$












  • $begingroup$
    How is this related to graphs and networks? Might there be an additional structure behind the matrix? For example, if mat is an adjacency matrix of a graph, you might be looking for a maximal complete subgraph or a clique. Szabolcs' package "IGraphM`" has tools for that...
    $endgroup$
    – Henrik Schumacher
    2 hours ago








  • 1




    $begingroup$
    You still want to solve the problem for general binary matrices? (It is not unlikely that his discrete optimization problem is a very hard...)
    $endgroup$
    – Henrik Schumacher
    2 hours ago






  • 1




    $begingroup$
    If you want non-contiguous too, then this is indeed the clique problem, which is NP-complete, and there's not going to be a simpler solution. Use FindClique, then filter for blocks that also have 1s on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago








  • 1




    $begingroup$
    Before FindClique, remove every row/column that has a 0 on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago






  • 1




    $begingroup$
    I added the size (thousands long, less than a hundred wide and that I am looking for non-contiguous solutions.
    $endgroup$
    – Sander
    1 hour ago














3












3








3





$begingroup$


I have a sparse non-symmetric binary matrix with a block structure. The dimensions of the matrix are thousands long x less than one hundred wide.



How do I identify the largest non-contiguous rectangular sub-matrix consisting only of 1-entries?



edit: The pattern is either very sparse, or there are very few large submatrices, however the blocks are likely to overlap.



In the simplified example below, it would be elements {2,4} towards {6,6}.




$mat=left( begin{array}{ccc}
1&1&1&1&0&0\
1&1&1&1&1&1\
0&0&0&1&1&1\
1&1&0&1&1&1\
1&1&1&1&1&1\
1&1&1&1&1&1\
end{array} right)$











share|improve this question











$endgroup$




I have a sparse non-symmetric binary matrix with a block structure. The dimensions of the matrix are thousands long x less than one hundred wide.



How do I identify the largest non-contiguous rectangular sub-matrix consisting only of 1-entries?



edit: The pattern is either very sparse, or there are very few large submatrices, however the blocks are likely to overlap.



In the simplified example below, it would be elements {2,4} towards {6,6}.




$mat=left( begin{array}{ccc}
1&1&1&1&0&0\
1&1&1&1&1&1\
0&0&0&1&1&1\
1&1&0&1&1&1\
1&1&1&1&1&1\
1&1&1&1&1&1\
end{array} right)$








matrix graphs-and-networks regions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 14 mins ago







Sander

















asked 2 hours ago









SanderSander

1,109512




1,109512












  • $begingroup$
    How is this related to graphs and networks? Might there be an additional structure behind the matrix? For example, if mat is an adjacency matrix of a graph, you might be looking for a maximal complete subgraph or a clique. Szabolcs' package "IGraphM`" has tools for that...
    $endgroup$
    – Henrik Schumacher
    2 hours ago








  • 1




    $begingroup$
    You still want to solve the problem for general binary matrices? (It is not unlikely that his discrete optimization problem is a very hard...)
    $endgroup$
    – Henrik Schumacher
    2 hours ago






  • 1




    $begingroup$
    If you want non-contiguous too, then this is indeed the clique problem, which is NP-complete, and there's not going to be a simpler solution. Use FindClique, then filter for blocks that also have 1s on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago








  • 1




    $begingroup$
    Before FindClique, remove every row/column that has a 0 on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago






  • 1




    $begingroup$
    I added the size (thousands long, less than a hundred wide and that I am looking for non-contiguous solutions.
    $endgroup$
    – Sander
    1 hour ago


















  • $begingroup$
    How is this related to graphs and networks? Might there be an additional structure behind the matrix? For example, if mat is an adjacency matrix of a graph, you might be looking for a maximal complete subgraph or a clique. Szabolcs' package "IGraphM`" has tools for that...
    $endgroup$
    – Henrik Schumacher
    2 hours ago








  • 1




    $begingroup$
    You still want to solve the problem for general binary matrices? (It is not unlikely that his discrete optimization problem is a very hard...)
    $endgroup$
    – Henrik Schumacher
    2 hours ago






  • 1




    $begingroup$
    If you want non-contiguous too, then this is indeed the clique problem, which is NP-complete, and there's not going to be a simpler solution. Use FindClique, then filter for blocks that also have 1s on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago








  • 1




    $begingroup$
    Before FindClique, remove every row/column that has a 0 on the diagonal.
    $endgroup$
    – Szabolcs
    2 hours ago






  • 1




    $begingroup$
    I added the size (thousands long, less than a hundred wide and that I am looking for non-contiguous solutions.
    $endgroup$
    – Sander
    1 hour ago
















$begingroup$
How is this related to graphs and networks? Might there be an additional structure behind the matrix? For example, if mat is an adjacency matrix of a graph, you might be looking for a maximal complete subgraph or a clique. Szabolcs' package "IGraphM`" has tools for that...
$endgroup$
– Henrik Schumacher
2 hours ago






$begingroup$
How is this related to graphs and networks? Might there be an additional structure behind the matrix? For example, if mat is an adjacency matrix of a graph, you might be looking for a maximal complete subgraph or a clique. Szabolcs' package "IGraphM`" has tools for that...
$endgroup$
– Henrik Schumacher
2 hours ago






1




1




$begingroup$
You still want to solve the problem for general binary matrices? (It is not unlikely that his discrete optimization problem is a very hard...)
$endgroup$
– Henrik Schumacher
2 hours ago




$begingroup$
You still want to solve the problem for general binary matrices? (It is not unlikely that his discrete optimization problem is a very hard...)
$endgroup$
– Henrik Schumacher
2 hours ago




1




1




$begingroup$
If you want non-contiguous too, then this is indeed the clique problem, which is NP-complete, and there's not going to be a simpler solution. Use FindClique, then filter for blocks that also have 1s on the diagonal.
$endgroup$
– Szabolcs
2 hours ago






$begingroup$
If you want non-contiguous too, then this is indeed the clique problem, which is NP-complete, and there's not going to be a simpler solution. Use FindClique, then filter for blocks that also have 1s on the diagonal.
$endgroup$
– Szabolcs
2 hours ago






1




1




$begingroup$
Before FindClique, remove every row/column that has a 0 on the diagonal.
$endgroup$
– Szabolcs
2 hours ago




$begingroup$
Before FindClique, remove every row/column that has a 0 on the diagonal.
$endgroup$
– Szabolcs
2 hours ago




1




1




$begingroup$
I added the size (thousands long, less than a hundred wide and that I am looking for non-contiguous solutions.
$endgroup$
– Sander
1 hour ago




$begingroup$
I added the size (thousands long, less than a hundred wide and that I am looking for non-contiguous solutions.
$endgroup$
– Sander
1 hour ago










2 Answers
2






active

oldest

votes


















3












$begingroup$

A brute force approach:



mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1, 1, 0, 1, 1, 1}, 
{1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};
pairs = Transpose /@ MaximalBy[DeleteDuplicates[CoordinateBounds /@
Subsets[SparseArray[mat]["NonzeroPositions"], {2}]],
Min[#] Total[#, 2] &@mat[[## & @@ Span @@@ #]] &]



{{{2, 4}, {6, 6}}}







share|improve this answer









$endgroup$





















    1












    $begingroup$

    Update: This answer is not correct but for referencing, because the Subsets does not give all the possible slices of the matrix.



    mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1,
    1, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};

    mat//MatrixForm//TeXForm



    $left(
    begin{array}{cccccc}
    1 & 1 & 1 & 1 & 0 & 0 \
    1 & 1 & 1 & 1 & 1 & 1 \
    0 & 0 & 0 & 1 & 1 & 1 \
    1 & 1 & 0 & 1 & 1 & 1 \
    1 & 1 & 1 & 1 & 1 & 1 \
    1 & 1 & 1 & 1 & 1 & 1 \
    end{array}
    right)$




    lst = Subsets@mat;

    result = DeleteDuplicates@(MatrixForm /@ Select[lst, DeleteDuplicates@Flatten@# == {1} &]) // Sort;
    result // TeXForm



    $
    left{left(
    begin{array}{cccccc}
    1 & 1 & 1 & 1 & 1 & 1 \
    end{array}
    right),left(
    begin{array}{cccccc}
    1 & 1 & 1 & 1 & 1 & 1 \
    1 & 1 & 1 & 1 & 1 & 1 \
    end{array}
    right),left(
    begin{array}{cccccc}
    1 & 1 & 1 & 1 & 1 & 1 \
    1 & 1 & 1 & 1 & 1 & 1 \
    1 & 1 & 1 & 1 & 1 & 1 \
    end{array}
    right)right}
    $




    Is this ok? I'm not sure to apply Transpose to the last one of the result.






    share|improve this answer











    $endgroup$













    • $begingroup$
      Thanks Jerry, there seem to be two issues: 1 the largest sub-matrix in the example is 5x3, your answer results in (after transpose) a 6x3 sub-matrix; Also, I am concerned the Subset will explode beyond memory capacity once we work with large matrices? 2. I would like to recover the coordinates of where the sub-matrix is residing.
      $endgroup$
      – Sander
      50 mins ago












    • $begingroup$
      @Sander Here is a similar question in other language, see geeksforgeeks.org/…
      $endgroup$
      – Jerry
      43 mins ago











    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    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%2f190162%2fhow-to-find-the-largest-rectangular-submatrix%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3












    $begingroup$

    A brute force approach:



    mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1, 1, 0, 1, 1, 1}, 
    {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};
    pairs = Transpose /@ MaximalBy[DeleteDuplicates[CoordinateBounds /@
    Subsets[SparseArray[mat]["NonzeroPositions"], {2}]],
    Min[#] Total[#, 2] &@mat[[## & @@ Span @@@ #]] &]



    {{{2, 4}, {6, 6}}}







    share|improve this answer









    $endgroup$


















      3












      $begingroup$

      A brute force approach:



      mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1, 1, 0, 1, 1, 1}, 
      {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};
      pairs = Transpose /@ MaximalBy[DeleteDuplicates[CoordinateBounds /@
      Subsets[SparseArray[mat]["NonzeroPositions"], {2}]],
      Min[#] Total[#, 2] &@mat[[## & @@ Span @@@ #]] &]



      {{{2, 4}, {6, 6}}}







      share|improve this answer









      $endgroup$
















        3












        3








        3





        $begingroup$

        A brute force approach:



        mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1, 1, 0, 1, 1, 1}, 
        {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};
        pairs = Transpose /@ MaximalBy[DeleteDuplicates[CoordinateBounds /@
        Subsets[SparseArray[mat]["NonzeroPositions"], {2}]],
        Min[#] Total[#, 2] &@mat[[## & @@ Span @@@ #]] &]



        {{{2, 4}, {6, 6}}}







        share|improve this answer









        $endgroup$



        A brute force approach:



        mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1, 1, 0, 1, 1, 1}, 
        {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};
        pairs = Transpose /@ MaximalBy[DeleteDuplicates[CoordinateBounds /@
        Subsets[SparseArray[mat]["NonzeroPositions"], {2}]],
        Min[#] Total[#, 2] &@mat[[## & @@ Span @@@ #]] &]



        {{{2, 4}, {6, 6}}}








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        kglrkglr

        180k9200413




        180k9200413























            1












            $begingroup$

            Update: This answer is not correct but for referencing, because the Subsets does not give all the possible slices of the matrix.



            mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1,
            1, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};

            mat//MatrixForm//TeXForm



            $left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 0 & 0 \
            1 & 1 & 1 & 1 & 1 & 1 \
            0 & 0 & 0 & 1 & 1 & 1 \
            1 & 1 & 0 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)$




            lst = Subsets@mat;

            result = DeleteDuplicates@(MatrixForm /@ Select[lst, DeleteDuplicates@Flatten@# == {1} &]) // Sort;
            result // TeXForm



            $
            left{left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)right}
            $




            Is this ok? I'm not sure to apply Transpose to the last one of the result.






            share|improve this answer











            $endgroup$













            • $begingroup$
              Thanks Jerry, there seem to be two issues: 1 the largest sub-matrix in the example is 5x3, your answer results in (after transpose) a 6x3 sub-matrix; Also, I am concerned the Subset will explode beyond memory capacity once we work with large matrices? 2. I would like to recover the coordinates of where the sub-matrix is residing.
              $endgroup$
              – Sander
              50 mins ago












            • $begingroup$
              @Sander Here is a similar question in other language, see geeksforgeeks.org/…
              $endgroup$
              – Jerry
              43 mins ago
















            1












            $begingroup$

            Update: This answer is not correct but for referencing, because the Subsets does not give all the possible slices of the matrix.



            mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1,
            1, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};

            mat//MatrixForm//TeXForm



            $left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 0 & 0 \
            1 & 1 & 1 & 1 & 1 & 1 \
            0 & 0 & 0 & 1 & 1 & 1 \
            1 & 1 & 0 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)$




            lst = Subsets@mat;

            result = DeleteDuplicates@(MatrixForm /@ Select[lst, DeleteDuplicates@Flatten@# == {1} &]) // Sort;
            result // TeXForm



            $
            left{left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)right}
            $




            Is this ok? I'm not sure to apply Transpose to the last one of the result.






            share|improve this answer











            $endgroup$













            • $begingroup$
              Thanks Jerry, there seem to be two issues: 1 the largest sub-matrix in the example is 5x3, your answer results in (after transpose) a 6x3 sub-matrix; Also, I am concerned the Subset will explode beyond memory capacity once we work with large matrices? 2. I would like to recover the coordinates of where the sub-matrix is residing.
              $endgroup$
              – Sander
              50 mins ago












            • $begingroup$
              @Sander Here is a similar question in other language, see geeksforgeeks.org/…
              $endgroup$
              – Jerry
              43 mins ago














            1












            1








            1





            $begingroup$

            Update: This answer is not correct but for referencing, because the Subsets does not give all the possible slices of the matrix.



            mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1,
            1, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};

            mat//MatrixForm//TeXForm



            $left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 0 & 0 \
            1 & 1 & 1 & 1 & 1 & 1 \
            0 & 0 & 0 & 1 & 1 & 1 \
            1 & 1 & 0 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)$




            lst = Subsets@mat;

            result = DeleteDuplicates@(MatrixForm /@ Select[lst, DeleteDuplicates@Flatten@# == {1} &]) // Sort;
            result // TeXForm



            $
            left{left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)right}
            $




            Is this ok? I'm not sure to apply Transpose to the last one of the result.






            share|improve this answer











            $endgroup$



            Update: This answer is not correct but for referencing, because the Subsets does not give all the possible slices of the matrix.



            mat = {{1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {1,
            1, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}};

            mat//MatrixForm//TeXForm



            $left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 0 & 0 \
            1 & 1 & 1 & 1 & 1 & 1 \
            0 & 0 & 0 & 1 & 1 & 1 \
            1 & 1 & 0 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)$




            lst = Subsets@mat;

            result = DeleteDuplicates@(MatrixForm /@ Select[lst, DeleteDuplicates@Flatten@# == {1} &]) // Sort;
            result // TeXForm



            $
            left{left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right),left(
            begin{array}{cccccc}
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            1 & 1 & 1 & 1 & 1 & 1 \
            end{array}
            right)right}
            $




            Is this ok? I'm not sure to apply Transpose to the last one of the result.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 1 hour ago

























            answered 1 hour ago









            JerryJerry

            1,252112




            1,252112












            • $begingroup$
              Thanks Jerry, there seem to be two issues: 1 the largest sub-matrix in the example is 5x3, your answer results in (after transpose) a 6x3 sub-matrix; Also, I am concerned the Subset will explode beyond memory capacity once we work with large matrices? 2. I would like to recover the coordinates of where the sub-matrix is residing.
              $endgroup$
              – Sander
              50 mins ago












            • $begingroup$
              @Sander Here is a similar question in other language, see geeksforgeeks.org/…
              $endgroup$
              – Jerry
              43 mins ago


















            • $begingroup$
              Thanks Jerry, there seem to be two issues: 1 the largest sub-matrix in the example is 5x3, your answer results in (after transpose) a 6x3 sub-matrix; Also, I am concerned the Subset will explode beyond memory capacity once we work with large matrices? 2. I would like to recover the coordinates of where the sub-matrix is residing.
              $endgroup$
              – Sander
              50 mins ago












            • $begingroup$
              @Sander Here is a similar question in other language, see geeksforgeeks.org/…
              $endgroup$
              – Jerry
              43 mins ago
















            $begingroup$
            Thanks Jerry, there seem to be two issues: 1 the largest sub-matrix in the example is 5x3, your answer results in (after transpose) a 6x3 sub-matrix; Also, I am concerned the Subset will explode beyond memory capacity once we work with large matrices? 2. I would like to recover the coordinates of where the sub-matrix is residing.
            $endgroup$
            – Sander
            50 mins ago






            $begingroup$
            Thanks Jerry, there seem to be two issues: 1 the largest sub-matrix in the example is 5x3, your answer results in (after transpose) a 6x3 sub-matrix; Also, I am concerned the Subset will explode beyond memory capacity once we work with large matrices? 2. I would like to recover the coordinates of where the sub-matrix is residing.
            $endgroup$
            – Sander
            50 mins ago














            $begingroup$
            @Sander Here is a similar question in other language, see geeksforgeeks.org/…
            $endgroup$
            – Jerry
            43 mins ago




            $begingroup$
            @Sander Here is a similar question in other language, see geeksforgeeks.org/…
            $endgroup$
            – Jerry
            43 mins ago


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190162%2fhow-to-find-the-largest-rectangular-submatrix%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to label and detect the document text images

            Vallis Paradisi

            Tabula Rosettana