list manipulation – Replacing a submatrix of a matrix

Minding the fact that

In[102]:= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}[[1 ;; 2, 1 ;; 2]]

Out[102]= {{1, 2}, {4, 5}}

is the upper left submatrix.

I would like to do the following :

> helios = {{{3, 2}, {1, 2}}, {{3, 2}, {2, 1}}, {{3, 1}, {2, 2}}, {{1, 
>     3}, {2, 2}}, {{2, 3}, {1, 2}}, {{2, 3}, {2, 1}}, {{1, 2}, {3, 
>     2}}, {{2, 2}, {3, 1}}, {{2, 1}, {3, 2}}, {{2, 1}, {2, 3}}, {{1, 
>     2}, {2, 3}}, {{2, 2}, {1, 3}}}

ReplacePart[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {1 ;; 2, 
     1 ;; 2} -> #] & /@ helios

That is, i would like to replace the upper left submatrix by a series of other matrices !
But this does not work as :

ReplacePart::pkspec1: The expression 1;;2 cannot be used as a part specification.

Does anyone have a efficient way of doing this ? with built-in functions if possible.

Thank you very much.

What is the standard algorithm for largest rank submatrix?

Given a matrix over $mathbb R^{ntimes m}$ of rank $r$ what is the complexity to find the largest full-rank submatrix of rank $k$?

algorithms – Find a sub-matrix containing the maximum number of elements composed only of 1

I am trying to get help here, originally published first on:

https://stackoverflow.com/questions/59446920/find-sub-matrix-containing-the-maximum-number-of-elements-consisting-only-of-1s

Essentially, try to get the max sub-matrix which only contains 1's from a matrix filled with 0's and 1's.

I could understand the maximum sub-matrix, now I just need to figure out how to make the sub-matrix only 1.

c ++ – Sub-matrix maximum sum and these index-Divide and Conquer

My code above on the search for the maximum sum of sub-matrix and search for the beginning index, the end index of this sub-matrix.

int Max(int a,int b){return (a>b)?a:b;}
int Max(int a,int b,int c){return Max(Max(a,b),c);}
int MaxAcrossSubArray(int arr(),int l,int m,int r,int &Start,int &End) 
{
    Start=m;//initialize start index
    int sum=arr(m);
    int sum_l=arr(m);
    for(int i=m-1;i>=l;--i)//include mid(---------|)
    {
        sum+=arr(i);
        if(sum>sum_l)
        {
            Start=i;
            sum_l=sum;
        }

    }
    End=m+1;//initialize end index
    sum=arr(m+1);
    int sum_r=arr(m+1);
    for(int i=m+2;i<=r;++i)//include mid(|-----------------)
    {
        sum+=arr(i);
        if(sum>sum_r){
            End=i;
            sum_r=sum;
        }
    }
    return sum_l+sum_r;//(-----------|---------------------)

}
int MaxSubArray(int arr(),int l,int r,int &Start,int &End)
{
    if(l==r)
    {
        Start=l;
        End=r;
        return arr(l);
    }

    else
    {
       int mid=(l+r)/2;
        int sA=-1,eA=-1,sB=-1,eB=-1,sC=-1,eC=-1;
        int a=MaxSubArray(arr,l,mid,sA,eA);
        int b=MaxSubArray(arr,mid+1,r,sB,eB);
        int c=MaxAcrossSubArray(arr,l,mid,r,sC,eC);
        int Maximum=Max(a,b,c);

        if(Maximum==a)
        {
            Start=sA;
            End=eA;
            return a;
        }

        else if(Maximum==b)
            {
                Start=sB;
                End=eB;
                return b;
            }
        else
            {
                Start=sC;
                End=eC;
                return c;
            }
    }
    }

}
int main()
{
    int arr(9)={-2, 1, -3, 4, -1, 2, 1, -5, 4};
    int Start=-1;
    int End=-1;


    cout<

My algorithm works well in all cases, but I still need you to help me improve my algorithm to make it better. Is there a way to improve it?

linear algebra – conjecture on the sub-matrix of the orthogonal matrix

Let $ U $ bean $ n times n $ orthogonal matrix, that is to say $ U in mathbb {R} ^ n $. For all non-empty sets $ S_1, S_2 subset {1,2, …, n } $, to define $ U_ {S_1S_2} $ be a $ | S_1 | times | S_2 | $ sub-matrix of $ U $ which consists of the intersection entries of lines in $ S_1 $ and columns in $ S_2 $. Let $ odot $ to the Hadamard product (elementary product). Right here $ | S | $ is the cardinality of the whole $ S $. Is the following conjecture true?

For any unit vector $ v = (v_1, …, v_k) $ in $ mathbb {R} ^ k, k leq n $ and any orthogonal matrix $ U in O (n) $, there are subsets $ S_1, S_2 subset {1,2, …, n }, | S_1 | = k, | S_2 | = k $, such as:
$$ sum_ {j = 1} ^ n left ( sum_ {i = 1} ^ kv_iU_ {ij} ^ 2 right) ^ 2 leq v ^ T[U_{S_1S_2}odot U_{S_1S_2}]v $$

python – How to take a sub-matrix from a list of lists?

With an m x n grid filled with non-negative numbers, look for a path from top left to bottom right that minimizes the sum of all numbers along your route.

Note: You can only move down or to the right at any time.

I want to know how move in a list of lists.

For example with:

[
  [1,3,1],
  [1,5,1],
  [4,2,1]
]

for example

gridValued class:

def init (self, grid: List[List[int]]):
self.grid = grid
gridRight = new gridValued ([grid[i][1:]    for i in the range (0, len (grid))])
self.lengthRight = gridRight.value
gridDown = new gridValued ([grid[i][0:]    for i in the range (1, len (grid))])

matrix – How to find the largest rectangular submatrix

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

How to identify the biggest non-contiguous rectangular sub-matrix consisting solely of 1-Inputs?

edit: The pattern is very rare or there are very few large sub-matrices, but the blocks may overlap.

In the simplified example below, there would be elements {2,4} to {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) $