6 added 124 characters in body

# Dyalog APL, 10199646262 59 bytes

{+/¨+/∘,¨⍵∘×¨d∘=¨k[⍋k←↑∪/∪/,d←∘.{((+/1x×××⌊/∘|)⍺⍵},)⍨(⍳x)-⌈.5×x←≢⍵]}


Using Dennis' awesome algorithm.

# Dyalog APL, 101996462 bytes

{+/¨+/¨⍵∘×¨d∘=¨k[⍋k←↑∪/∪/d←∘.{(+/1x×××⌊/∘|)⍺⍵}⍨(⍳x)-⌈.5×x←≢⍵]}


Try it online!

Using Dennis' awesome algorithm.

# Dyalog APL, 101996462 59 bytes

{+/∘,¨⍵∘×¨d∘=¨k[⍋k←↑∪/,d←∘.((+/1x×××⌊/∘|),)⍨(⍳x)-⌈.5×x←≢⍵]}


Try it online!

Using Dennis' awesome algorithm.

5 deleted 2316 characters in body

# Dyalog APL, 101999964 62 bytes

{,/↑,+/,¨+/¨(⍉2↑o)(+¨⍵∘×¨d∘=¨k[⍋k←↑∪/+∪/⍵×∘d←∘.{⍺ ⍵∊⍨⌈x}⍨⍳≢⍵)(⊖⍉2↓o←++/¨+1x×××⌊/¨⍵∘×¨(0 3 1 2∘|)∘.{⌽∘⍉⍣⍺⊢⍵⍺⍵}⍨(⍳⌊x←.5×≢⍵⍳x)∘.=⊂∘-⌈.⌈⍨⍳≢⍵)5×x←≢⍵]}


How? Using Dennis' awesome algorithm.

      m                ⍝ the matrix
1 2 3 2 1
0 3 2 3 0
4 2 5 6 3
7 4 7 9 4
0 6 7 2 5
{⍳≢⍵} m         ⍝ range of length
1 2 3 4 5
{⊂∘.⌈⍨⍳≢⍵} m    ⍝ outer product with maximum
┌─────────┐
│1 2 3 4 5│
│2 2 3 4 5│
│3 3 3 4 5│
│4 4 4 4 5│
│5 5 5 5 5│
└─────────┘
{(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ check equality for n, for every n to the size of m / 2
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
└─────────┴─────────┘
{(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ rotate right n times for every n on the left
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│1 0 0 0 0│0 1 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 1 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 1│0 0 0 1 0│
└─────────┴─────────┘
{⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ apply masks to original matrix
┌─────────┬─────────┐
│1 0 0 0 0│0 2 0 0 0│
│0 0 0 0 0│0 3 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│7 4 0 0 0│
│0 0 0 0 0│0 6 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 2 0│
│0 0 0 0 0│0 0 0 3 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 9 4│
│0 0 0 0 5│0 0 0 2 0│
└─────────┴─────────┘
o ← {+/¨+/¨⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m ⋄ o
⍝ sum of each matrix
1  5
0 17
1  5
5 15
⊖⍉2↓o   ⍝ right side of the array
5 15
1  5
{+/+/⍵×∘.{⍺ ⍵∊⍨⌈.5×≢⍵}⍨⍳≢⍵} m   ⍝ middle element of the array
20
⍉2↑o    ⍝ left side of the array
1  0
5 17


# Dyalog APL, 10199 bytes

{,/↑,/,/¨(⍉2↑o)(+/+/⍵×∘.{⍺ ⍵∊⍨⌈x}⍨⍳≢⍵)(⊖⍉2↓o←+/¨+/¨⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵)}


Try it online!

How?

      m                ⍝ the matrix
1 2 3 2 1
0 3 2 3 0
4 2 5 6 3
7 4 7 9 4
0 6 7 2 5
{⍳≢⍵} m         ⍝ range of length
1 2 3 4 5
{⊂∘.⌈⍨⍳≢⍵} m    ⍝ outer product with maximum
┌─────────┐
│1 2 3 4 5│
│2 2 3 4 5│
│3 3 3 4 5│
│4 4 4 4 5│
│5 5 5 5 5│
└─────────┘
{(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ check equality for n, for every n to the size of m / 2
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
└─────────┴─────────┘
{(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ rotate right n times for every n on the left
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│1 0 0 0 0│0 1 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 1 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 1│0 0 0 1 0│
└─────────┴─────────┘
{⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ apply masks to original matrix
┌─────────┬─────────┐
│1 0 0 0 0│0 2 0 0 0│
│0 0 0 0 0│0 3 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│7 4 0 0 0│
│0 0 0 0 0│0 6 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 2 0│
│0 0 0 0 0│0 0 0 3 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 9 4│
│0 0 0 0 5│0 0 0 2 0│
└─────────┴─────────┘
o ← {+/¨+/¨⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m ⋄ o
⍝ sum of each matrix
1  5
0 17
1  5
5 15
⊖⍉2↓o   ⍝ right side of the array
5 15
1  5
{+/+/⍵×∘.{⍺ ⍵∊⍨⌈.5×≢⍵}⍨⍳≢⍵} m   ⍝ middle element of the array
20
⍉2↑o    ⍝ left side of the array
1  0
5 17


# Dyalog APL, 1019964 62 bytes

{+/¨+/¨⍵∘×¨d∘=¨k[⍋k←↑∪/∪/d←∘.{(+/1x×××⌊/∘|)⍺⍵}⍨(⍳x)-⌈.5×x←≢⍵]}


Try it online!

Using Dennis' awesome algorithm.

4 added 2589 characters in body

How?

      m                ⍝ the matrix
1 2 3 2 1
0 3 2 3 0
4 2 5 6 3
7 4 7 9 4
0 6 7 2 5
{⍳≢⍵} m         ⍝ range of length
1 2 3 4 5
{⊂∘.⌈⍨⍳≢⍵} m    ⍝ outer product with maximum
┌─────────┐
│1 2 3 4 5│
│2 2 3 4 5│
│3 3 3 4 5│
│4 4 4 4 5│
│5 5 5 5 5│
└─────────┘
{(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ check equality for n, for every n to the size of m / 2
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
└─────────┴─────────┘
{(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ rotate right n times for every n on the left
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│1 0 0 0 0│0 1 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 1 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 1│0 0 0 1 0│
└─────────┴─────────┘
{⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ apply masks to original matrix
┌─────────┬─────────┐
│1 0 0 0 0│0 2 0 0 0│
│0 0 0 0 0│0 3 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│7 4 0 0 0│
│0 0 0 0 0│0 6 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 2 0│
│0 0 0 0 0│0 0 0 3 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 9 4│
│0 0 0 0 5│0 0 0 2 0│
└─────────┴─────────┘
o ← {+/¨+/¨⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m ⋄ o
⍝ sum of each matrix
1  5
0 17
1  5
5 15
⊖⍉2↓o   ⍝ right side of the array
5 15
1  5
{+/+/⍵×∘.{⍺ ⍵∊⍨⌈.5×≢⍵}⍨⍳≢⍵} m   ⍝ middle element of the array
20
⍉2↑o    ⍝ left side of the array
1  0
5 17


How?

      m                ⍝ the matrix
1 2 3 2 1
0 3 2 3 0
4 2 5 6 3
7 4 7 9 4
0 6 7 2 5
{⍳≢⍵} m         ⍝ range of length
1 2 3 4 5
{⊂∘.⌈⍨⍳≢⍵} m    ⍝ outer product with maximum
┌─────────┐
│1 2 3 4 5│
│2 2 3 4 5│
│3 3 3 4 5│
│4 4 4 4 5│
│5 5 5 5 5│
└─────────┘
{(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ check equality for n, for every n to the size of m / 2
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
└─────────┴─────────┘
{(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ rotate right n times for every n on the left
┌─────────┬─────────┐
│1 0 0 0 0│0 1 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│1 1 0 0 0│
│1 0 0 0 0│0 1 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 1 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 1 1│
│0 0 0 0 1│0 0 0 1 0│
└─────────┴─────────┘
{⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m
⍝ apply masks to original matrix
┌─────────┬─────────┐
│1 0 0 0 0│0 2 0 0 0│
│0 0 0 0 0│0 3 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│7 4 0 0 0│
│0 0 0 0 0│0 6 0 0 0│
├─────────┼─────────┤
│0 0 0 0 1│0 0 0 2 0│
│0 0 0 0 0│0 0 0 3 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
├─────────┼─────────┤
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 0 0│
│0 0 0 0 0│0 0 0 9 4│
│0 0 0 0 5│0 0 0 2 0│
└─────────┴─────────┘
o ← {+/¨+/¨⍵∘×¨(0 3 1 2)∘.{⌽∘⍉⍣⍺⊢⍵}(⍳⌊x←.5×≢⍵)∘.=⊂∘.⌈⍨⍳≢⍵} m ⋄ o
⍝ sum of each matrix
1  5
0 17
1  5
5 15
⊖⍉2↓o   ⍝ right side of the array
5 15
1  5
{+/+/⍵×∘.{⍺ ⍵∊⍨⌈.5×≢⍵}⍨⍳≢⍵} m   ⍝ middle element of the array
20
⍉2↑o    ⍝ left side of the array
1  0
5 17

3 deleted 206 characters in body
2 deleted 3 characters in body
1