[Question]
  [
Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix.
**Rotated sum:**
Take the sum of the original matrix and the same matrix rotated 90, 180 and 270 degrees.
Suppose the matrix is:
```
 2    5    8
 3   12    8
 6    6   10
```
then the rotated sum will be:
```
2    5    8     8    8   10    10    6    6     6    3    2
3   12    8  +  5   12    6  +  8   12    3  +  6   12    5  = 
6    6   10     2    3    6     8    5    2    10    8    8   
26   22   26
22   48   22
26   22   26
```
### Test cases:
Input and output separated by dashes, different test cases separated by a newline. Test cases in [more convenient formats can be found here](https://tio.run/##ZZExEsIwDAR7v@IeoCJKQoDxUzIu6KGjy@TtRqfY4JgiM7rzaSXHr8f7mfO6akph23Tfg5UhmCGYkmAdBfNxZsYu2Gh4zHSEH3t@FiyCq0Bn9lmtdqgTv2KYphwoL1aUyHjwGwDnnADFqADKFuD7NP0Rp26XtTfiNLrubor@YBXX05vgXkJW0Zq8ZEjrJYkfh2Oop8sfU2@26PK9WsPn9h2fVsf3VM8vD/Dj15s3@IgOHtGhI/7A/pLN2jl/AA).
```
1
-------------
4
1 3
2 4
-------------
10   10 
10   10    
14    6    7   14
 6   12   13   13
 6    2    3   10
 5    1   12   12
-------------
45   37   24   45
24   30   30   37
37   30   30   24
45   24   37   45    
14    2    5   10    2
18    9   12    1    9
 3    1    5   11   14
13   20    7   19   12
 2    1    9    5    6
-------------
24   29   31   41   24
41   49   31   49   29
31   31   20   31   31
29   49   31   49   41
24   41   31   29   24
```
### Shortest code in bytes in each language wins. Explanations are highly encouraged!
  
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 29 bytes
```
@(x)(y=x+rot90(x))+rot90(y,2)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0JTo9K2Qrsov8TSAMjRhLIqdYw0/6dpRBspmCpYWBsrGBoBKTMFMwVDg1jN/wA "Octave – Try It Online")
### Explanation
This adds the input matrix with a 90-degree rotated version of itself. The result is then added with a 180-degree rotated version of itself.
[Answer]
# [Python 2](https://docs.python.org/2/), 78 bytes
Thanks to [Dennis](https://codegolf.stackexchange.com/users/12012/dennis) for golfing two bytes off my previous recursive approach.
```
f=lambda*l:l[3:]and[map(sum,zip(*d))for d in zip(*l)]or f(zip(*l[0][::-1]),*l)
```
[Try it online!](https://tio.run/##LYtLDsMgDESv4iWOXKkk6Q@pJ7FYUCFUJEJQmizay1OHduWZ5zflvT7n3Nca7slND@@6ZBIPxrrseXJFvbaJPrGoziOGeQEPMUMDCa30oH6Fj5aNOWiLJJ9alphXFVTMZVsVIlZmPRL0BCcCfZRkCVhfCW7SBWtJOxpa3CU5emyWsF4mFwHN3uF/0tSztV8 "Python 2 – Try It Online") or [See a test suite.](https://tio.run/##LY9LDoMwDET3nMLLBKUSCZS2kThJ5AUVRUXiJ6CL9vKpbbKK53k80azf473MLsa@Gdvp2bX56MdQemznLkztqvbPZH7DqvJO637ZoINhBgGjRtK9OkUoMHh/sagNbeLx2o8dGggh2MqAM3A1YAua0ECwdwMP0oQtTYxKGdlEj63ERczRyY2AuBmmE7HWyEQ@qE@b3NUpmSPLBEizLFheJUIsLiXQNoVXiSBilnFhbsKdpZHPYN2G@VC9Yq11/AM "Python 2 – Try It Online")
---
### [Python 2](https://docs.python.org/2/), 80 ~~81 83 85~~ bytes (non-recursive)
Takes input [as a singleton list](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/11884#11884).
```
l=input()
exec"l+=zip(*l[-1][::-1]),;"*3
print[map(sum,zip(*d))for d in zip(*l)]
```
[Try it online!](https://tio.run/##LYvLDoIwEEX3fMWEVYtjYgFfGL5k0oURjE1KabAk6s/XaXUzc@/Juf4dHrOrY7S9cX4NQhbja7yVdtN/jBeVpa3S1HV8JV7Kqin8Ylyg6erFc50wS4OU93mBAYyD30rqGIlItQg1wh5B7ThpBFInhDN3xopTQk2OSeKn2mwxq3lyZJDtBP@TrB601l8 "Python 2 – Try It Online")
### Code functionality
Since this is quite length-ish to analyse it as a whole, let's check it out piece-by-piece:
```
f = lambda *l:                # This defines a lambda-function that can accept any number
                              # of arguments (the matrix) using starred expressions.
l[3:] and ...X... or ...Y...  # If l[3:] is truthy (that is, the length of the list is
                              # higher than 3), return X, otherwise Y.
[map(sum,zip(*d))for d in zip(*l)]     # The first expression, X.
[                                ]     # Start a list comprehension, that:
                 for d in              # ... Iterates using a variable d on:
                          zip(*l)      # ... The "input", l, transposed.
         zip(*d)                       # ... And for each d, transpose it...
 map(sum,       )                      # ... And compute the sum of its rows.
                                       # The last two steps sum the columns of d.
f(zip(*l[0][::-1]),*l)     # The second expression, Y. This is where the magic happens.
f(                   )     # Call the function, f with the following arguments:
  zip(*          )         # ... The transpose of:
       l[0][::-1]          # ...... The first element of l (the first arg.), reversed.
                  ,        # And:
                   *l      # ... l splatted. Basically turns each element of l
                           # into a separate argument to the function.
```
And for the second program:
```
l=input()                                # Take input and assign it to a variable l.
                                         # Note that input is taken as a singleton list.
exec"l+=zip(*l[-1][::-1]),;"*3           # Part 1. Create the list of rotations.
exec"                     ;"*3           # Execute (Do) the following 3 times:
     l+=                 ,               # ... Append to l the singleton tuple:
        zip(*           )                # ...... The transpose of:
             l[-1][::-1]                 # ......... The last element of l, reversed.
print[map(sum,zip(*d))for d in zip(*l)]  # Part 2. Generate the matrix of sums.
print                                    # Output the result of this expression:
     [                for d in        ]  # Create a list comprehension, that iterates
                                         # with a variable called "d" over:
                               zip(*l)   # ... The transpose of l.
      map(sum,       )                   # ... And computes the sum:
              zip(*d)                    # ... Of each row in d's transpose.
                                         # The last 2 steps generate the column sums.
```
**TL;DR:** Generate the list of matrices needed by rotating the input 3 times by 90-degrees and collecting the results. Then, get the sums of the columns of each matrix in the result's transpose.
[Answer]
# [Clean](https://clean.cs.ru.nl), 110 bytes
```
import StdEnv,StdLib
r=reverse
t=transpose
z=zipWith(+)
$m=[z(z(r b)a)(z(r c)d)\\a<-m&b<-r m&c<-t m&d<-r(t m)]
```
[Try it online!](https://tio.run/##TVHLasMwEDxHX7HQECwqQ2S7aQr2rT0UcsuhB0UH@dFWYNlGVgL1x9ddywoUBDszmtllpaptVDebvr62DRilu1mbobcOzq5@624My0mXxBa2uTV2bIgrnFXdOPSIp2LSw4d239EjJVtTiCmaIgslVdSDitb0clF5bHZlHlswuyqPHZYaWYSAyvnslHXkAXQ3XN0IBQiyEYJLyXxlkEoGImGQBQnhE4OjZCJlwBMPQRwY4OH7ey7z/BmlLFwvVr5E0iAgT30EKXbkwZL8a7HO4ntEi4sfGbwEG6JFSj1cTPw@axmS7Nfh3h0W4D6M1oOUZCMJKfDBB9iG1eff6rNVX@Mcv5/m159OGV2tZP2DPw "Clean – Try It Online")
From the matricies:
* `X = transpose(reverse M)`: 90-degree rotation
* `Y = reverse(map reverse M)`: 180-degree rotation
* `Z = reverse(transpose M)`: 270-degree rotation
This zips the addition operator over `M` and `X`, as well as `Y` and `Z`, and then over the results.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 28 bytes
```
Sum[a=Reverse@a,{a=#;4}]&
```
`` is [`\[Transpose]`](http://reference.wolfram.com/language/ref/character/Transpose.html).
[Try it online!](https://tio.run/##RY4xDsIwDEWvYrVSJyPqNhQQKuoREIxVhwilokMYSmGJMjNyVI4Q7BLEEOX97@/8WD1djNXTcNahhxrC6W5bXR/Nw4w30@j364lO1@lO@S4Lh3G4Tm2KkMBiDwlC36ZdBxksG3DOkffINyGUAgWCio5CqBDWCKTEYCaeUiknGqxF5iJXDDFS/F9gKYOcSTzaIGxjikmsckYJ0a9KOor82z2n489oXuZo5b0PHw "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Julia 0.6](http://julialang.org/), 29 bytes
```
x*y=rotr90(y,x)
!x=x+1x+2x+3x
```
[Try it online!](https://tio.run/##VU1Na4NAEL37K17oRaOUndXYyhLoj@gteFjCklXaWNZNO/56uyM5JPBghvc53r4G264r75djmGLoVL5UXGQ7PnJJXGoua14/Zj/9YRfc7O2Py0/UV8ipoqLAy6cfZiSIY5luuLgIC2LCt41hYAxXjLIC9doiDzZ6FxC9vSbbrzvHKRRZdl84EWoDjaZ/oBq0eAM1Jl3SoDpBfo30KYMDaOP1c0iLoKAN6B3d5kBnJCMCbYWpSyspF12GkyWpbb/@Aw "Julia 0.6 – Try It Online")
I couldn't get below [LukeS's solution](https://codegolf.stackexchange.com/a/153695/4397)
But in trying I did come up with this, which I think is kinda cute.
First we redefine multiplication to be the rotate operation, where there first time is the number of times to rotate.
So since julia multipes by juxtaposition then: `1x` becomes `rotr90(x,1)` and `3x` becomes `rotr90(x,3)` etc.
Then we write out the sum.
[Answer]
# [Julia 0.6](http://julialang.org/), ~~28~~ 24 bytes
```
~A=sum(rotr90.([A],0:3))
```
[Try it online!](https://tio.run/##VY/BTsQgGITvfYrJ7gUSVKC1azV7aOLVeHA9NRwaZV1MlzaURk/76pVCqpFwYGa@4YfPqTNtOT@13pk3PWKfIazG6fHUDpo0QjEimKCUZdsUCeQP8SRRqD@3QIkdRJGyEkJC5GGvWiIontQtRMzlv75cfA6ZGHGHKkKokhHqCyB@Z4TrJV9mLtz6pIAHqlRqvtT7cToT13tX8WvS1Irx@5zS@dg71DAW66djdTz1X@Tl8Pj8emDYeP3tb4auNXbDcKkptjaQDuep8@aqM1ZjcMZ6Yz9iO4rOEppp@z7/AA "Julia 0.6 – Try It Online")
```
~A=sum(rotr90.([A],0:3)) #
~                        # redefine unary operator ~
 A                       # function argument
               [A]       # put input matrix A into a list with one element
                   0:3   # integer range from 0 to 3
       rotr90.(   ,   )  # apply function rotr90 elementwise, expand singleton dimensions
       rotr90.([A],0:3)  # yields list of rotated matrices:
                         # [rotr90(A,0), rotr90(A,1), rotr90(A,2), rotr90(A,3)]
  sum(                )  # sum
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
ZU+µUṚ+
```
[Try it online!](https://tio.run/##y0rNyan8/z8qVPvQ1tCHO2dp////PzraSMdUxyJWJ9pYx9AIzDDTMdMxNIiNBQA "Jelly – Try It Online")
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 33 bytes
```
@(a)a+(r=@rot90)(a)+r(a,2)+r(a,3)
```
[Try it online!](https://tio.run/##RY5BC8MgDIXv@xU5Kg1i1HUrodD/MXqQMa8FKfv7LprCDpL38d5LPN5n/n5aWZ1zbTPZ5snUdavHuXgrOFWTMeiIthVD9lbMixAiQ0BIu3JCmBEeCJS4KxKPYn8DhTp4hruMyw7/rmA3vCgGeiIsV0YUj6oGSA/0zcHrvZEcf6FRk9i82/YD "Octave – Try It Online")
## Explanation:
`(r=@rot90)` in an inline way of creating a function handle `r` used to rotate the matrix 90 degrees. If a second argument, `k` is given to `r` then it will rotate the matrix `k*90` degrees. So this is equivalent to the pseudo code:
```
a + rot90(a) + rot180(a) + rot270(a)
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 8 bytes
```
(⌽+⍉)⊖+⌽
```
[Try it online!](https://tio.run/##RVDLasMwELznK/YoEQLa1VqyPsektAQMKeTUHyik1KE9tPde8w/9Gf2IOyunMRjvY8Yzsx6ex93DyzAen3b7cTidDvu5Xr4Ox/r6EeZHvF19/93W6ezr2/cW/Tw7rD@dUEe9d5FYrCZKxMH7ev5paCIRkuQdivYY/LrbQGG6cuNOV90sgkwRHNK7BgdTvJV/ksInE6s5wpnhH60Xio3dEbe93GW0o5hJlLSDvlIM7cnInm@DQA40A7PRVjO7EgGQnnsqTZlKu9oAbkGQQYKFMtxOAAVoWn8GdApFJuXFCt0yFwBQYxug0RoolBVXbqF1oRT7/g8 "APL (Dyalog Classic) – Try It Online")
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 9 bytes
```
i3:"G@X!+
```
Try it at [MATL Online](https://matl.io/?code=i3%3A%22G%40X%21%2B&inputs=%5B2+5+8%3B3+12+8%3B6+6+10%5D&version=20.6.0)
**Explanation**
```
i       # Explicitly grab the input matrix
3:"     # Loop through the values [1, 2, 3], and for each value, N:
  G     # Grab the input again
  @X!   # Rotate the value by 90 degrees N times
  +     # Add it to the previous value on the stack
        # Implicitly end the for loop and display the resulting matrix
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 13 bytes
```
m+MCdC.u_CN3Q
```
[Try it online!](http://pyth.herokuapp.com/?code=m%2BMCdC.u_CN3Q&test_suite=1&test_suite_input=%5B%5B1%5D%5D%0A%5B%5B1%2C+3%5D%2C+%5B2%2C+4%5D%5D%0A%5B%5B2%2C+5%2C+8%5D%2C+%5B3%2C+12%2C+8%5D%2C+%5B6%2C+6%2C+10%5D%5D%0A%5B%5B14%2C+6%2C+7%2C+14%5D%2C+%5B6%2C+12%2C+13%2C+13%5D%2C+%5B6%2C+2%2C+3%2C+10%5D%2C+%5B5%2C+1%2C+12%2C+12%5D%5D%0A%5B%5B14%2C+2%2C+5%2C+10%2C+2%5D%2C+%5B18%2C+9%2C+12%2C+1%2C+9%5D%2C+%5B3%2C+1%2C+5%2C+11%2C+14%5D%2C+%5B13%2C+20%2C+7%2C+19%2C+12%5D%2C+%5B2%2C+1%2C+9%2C+5%2C+6%5D%5D&debug=0)
[Answer]
# [J](http://jsoftware.com/), ~~16~~ 15 bytes
```
[:+/|.@|:^:(<4)
```
[Try it online!](https://tio.run/##NYxBCsIwEEX3nuItlYaamaS1HRS8h9CNWMRNL9C7x0lQZvHhv/fnU8p663lYd977@26LHa/5VF7P98aKkIKh5MOvUAamQELU0xj9JP6p5CZIRAMyMVdNmNugAnHFSUIjF6Ty9t8dx2P5Ag)
[Answer]
# [R](https://www.r-project.org/), ~~69~~ 64 bytes
```
function(x,a=function(y)apply(y,1,rev))x+a(x)+a(a(x))+a(a(a(x)))
```
[Try it online!](https://tio.run/##PYpRCoAgEESvs0sbZFL0kYcRSRDKRCzW05sWxMC8NzCx2LUv9vImudMDk1b/yKhD2DNkEhS3G5E7DYy1Gj6@hiVE5xNYYHXoFB2DgZEmWkiSGCvmGjEgyXZ@AA "R – Try It Online")
---
Attempt number three at codegolf. 
From 69 to 64 bytes thanks to Giuseppe!
[Answer]
# [MATL](https://github.com/lmendo/MATL), 7 bytes
```
,t@QX!+
```
Try it at [MATL Online!](https://matl.io/?code=%2Ct%40QX%21%2B&inputs=%5B2+5+8%3B3+12+8%3B6+6+10%5D&version=20.6.0)
### Explanation
Port of my Octave answer.
```
,        % Do twice
  t      %   Duplicate. Takes input (implicit) the first time
  @Q     %   Push 1 in the first iteration, and 2 in the second
  X!     %   Rotate by that many 90-degree steps
  +      %   Add
         % End (implicit). Display (implicit)
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 31 bytes
```
a->sum(i=1,4,a=Mat(Vecrev(a))~)
```
[Try it online!](https://tio.run/##NY7BDoIwEER/ZcKpTZaEhYqaBv7AqxfCoTFgSNQ0iCZe/PW6LXhod97uzLbezVN@9WFEg@Dy9vm6q6lhMuSak1vUebjMw1s5rb86OO9vH@WQt/Dz9FhEZhEyjNFB6Dru5WZCZVESTCJDqAl7AhsbFcuEq3gSCkUoLHZStnH5TwrEdiHKgg@E4@YQZVNwNfC6Pu4ti/W15Ez/4BQTW933OvwA "Pari/GP – Try It Online")
[Answer]
## JavaScript (ES6), 77 bytes
```
a=>a.map((b,i)=>b.map((c,j)=>c+a[j][c=l+~i]+a[c][c=l+~j]+a[c][i]),l=a.length)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
ṚZ$3Ð¡S
```
[Try it online!](https://tio.run/##y0rNyan8///hzllRKsaHJxxaGPz////oaEMTHQUjHQVTHQVDAyArVkch2tBCR8ESyAcKGwJZICFjMBOkCEgZmoBVAcWMgFrMgQJg1SBBqBawUrPYWAA "Jelly – Try It Online")
Saved 1 byte thanks to [Erik the Outgolfer](https://codegolf.stackexchange.com/users/41024/erik-the-outgolfer) (also thanks to a suggestion for fixing a bug).
### How?
```
ṚZ$3Ð¡S || Full program (monadic).
   3Ð¡  || Do this 3 times and collect results in a list
  $     || –> Apply the last two links as a monad
Ṛ       || –––> Reverse,
 Z      || –––> Transpose.
      S || Summation.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 76 bytes
```
f=lambda x,k=-2:k*x or[map(sum,zip(*r))for r in zip(x,f(zip(*x)[::-1],k+1))]
```
[Try it online!](https://tio.run/##ZVDLasMwEDxbX7FHKVXAK7lpasiXCB1cgolx/EBNQcnPu7uy6lAiEIxmZ2YHzffbZRrNsrSnazN8nRuIuj/tTd3vIkzBDc0sv38G/ehmuQtKtVOAAN0ITETdyjSIytX1Hr3u31Apv7AqskoKUThnNMA73aPXAv6OsxrQvLAHYuhi6YlmM25AgyVYAOdVG1utBvggU7XOUwCJkFfYJwe8zqbwleNSmLXmX2KujCXjVY1Hwp@5NDLOKTa/WY/PFrzdlLlZ8mX95s/fcvBeCFXT8u13WxmJKIo5dOMNAo0SWn4B "Python 2 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 12 bytes
```
3FÂø}3F‚øε`+
```
[Try it online!](https://tio.run/##MzBNTDJM/f/f2O1w0@EdtcZujxpmHd5xbmuC9v//0dGGJjoKRjoKpjoKhgZAVqyOQrShhY6CJZAPFDYEskBCxmAmSBGQMjQBqwKKGQG1mAMFwKpBglAtYKVmsbEA "05AB1E – Try It Online")
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/attache), 20 bytes
```
Sum@MatrixRotate&0:3
```
[Try it online!](https://tio.run/##VY5LC8IwEITv@RWLiKc9NG19gsWDV0H0GBYJpcFCfVAjKOJvr7uxhTYkMDP7JRPrvc3PRbMtXHktzNhhc3xeNjvr6/J1uHnri0m0ShpSHeFzBKOAlzGaCDuJkBBPYoS0l6YIM4Q5gk5lylozoRM5bcBebCR2yqJF4uErHMkwYiWgXiAsW5KVREmQAumuTnri6N8f6PaHOlxmdEakeCv1CVXb8nGv7NucKNh9XV69Ga2zEQ3GjoE@UTlSX1hn4PPmBw "Attache – Try It Online")
## Explanation
```
Sum@MatrixRotate&0:3
```
`MatrixRotate&0:3` expands to, with input `x`, `MatrixRotate[x, 0:3]`, which in turn exapnds to `[MatrixRotate[x, 0], MatrixRotate[x, 1], MatrixRotate[x, 2], MatrixRotate[x, 3]]`. That is to say, it vectorizes over the RHS. Then, `Sum` takes the sum of all of these matrices by one level. This gives the desired result.
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 17 bytes
```
{⍵+⌽∘⍉⍵+⌽∘⊖⍵+⍉⌽⍵}
```
[Try it online!](https://tio.run/##jZDBCsIwDIbvPkVua5HB2nXTPU5XmQgDhZ1EvMocVrwoPog7@jJ5kZqWHXYqloY0/xfyh@pDm26Out1vU9PqrtsZ505oxyXevti/0V5nxfAKBWlU2/HsGrw8/u5e4P1J/ZpCgkT7EZCDBDXpSTo7ySQ2oONYxHBNoUB5KwUlrCAkIUHk/pbkTo8MChBBlXGvOoYNRQEFeWE/MDKSfmwGkjOxhirMh4ozMvSADBUR@oDM7@U5Z6GFaMnji5iF@wE "APL (Dyalog Classic) – Try It Online")
# APL NARS 34bytes ~~21~~17 chars
```
{⍵+⌽∘⍉⍵+⌽∘⊖⍵+⍉⌽⍵}
```
-2 chars thanks to ngn
-2 chars because operator composite ∘ seems to have precedence on +
it seems ⌽⍉a rotate a from 90°,⌽⊖a rotate a from 180°,⌽⍉⌽⊖a rotate a from 270° as ⍉⌽
If exist the operator p as:
```
∇r←(g p)n;a;i;k
   a←⌽,n⋄r←⍬⋄i←0⋄k←⍴a⋄→C
A: →B×⍳r≡⍬⋄r←g¨r
B: r←r,⊂i⊃a
C: →A×⍳k≥i+←1
   r←⌽r
∇
```
The operator p above would be such that if g is a 1 argument function (monadic?) it should be:
```
"g f a a a a" is "a ga gga ggga"
```
the solution would be pheraps 15 chars
```
  g←{⊃+/⌽∘⍉ p 4⍴⊂⍵}
  a←2 2⍴1 3 2 4
  g a
10 10 
10 10 
  g 1
4
```
But could be better one operator "composed n time" d such that "3 d f w" is f(f(f(w))).
Now I wrote something but it is too much fragile without the need type checking.
But i like more the operator q that repeat compose of f with argument m
(it is not complete because the error cases of the types are not written)
```
∇r←(n q f)m;i;k;l
   r←⍬⋄k←⍴,n⋄→A×⍳k≤1⋄i←0⋄→D
C: r←r,⊂(i⊃n)q f m
D: →C×⍳k≥i+←1
   →0
A: l←n⋄r←m⋄→0×⍳n≤0
B: l-←1⋄r←f r⋄→B×⍳l≥1
∇
```
the solution would be 17 chars but i prefer it
```
  g←{⊃+/(0..3)q(⌽⍉)⍵}
  ⎕fmt g a
┌2─────┐
2 10 10│
│ 10 10│
└~─────┘
  ⎕fmt g 1
4
~
```
[Answer]
# [K4](http://kx.com/download/) / [K (oK)](https://github.com/JohnEarnest/ok), ~~23~~ 8 bytes
**Solution:**
```
+/(|+:)\
```
[Try it online!](https://tio.run/##y9bNz/7/X1tfo0bbSjPGWMFY2UjBVMFCwVjB0AhImQGhocH//wA "K (oK) – Try It Online") 
**Example:**
```
+/(|+:)\5 5#14 2 5 10 2 18 9 12 1 9 3 1 5 11 14 13 20 7 19 12 2 1 9 5 6
24 29 31 41 24
41 49 31 49 29
31 31 20 31 31
29 49 31 49 41
24 41 31 29 24
```
**Explanation:**
Thanks to [ngn](https://codegolf.stackexchange.com/users/24908/ngn) for the simplified transformation technique. 
```
+/(|+:)\ / the solution
       \ / converge
  (   )  / function to converge
    +:   / flip
   |     / reverse
+/       / sum over the result
```
**Extra:**
In Q this could be written as
```
sum (reverse flip @) scan
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~74 72~~ 66 bytes
```
->a{r=0...a.size;r.map{|i|r.map{|j|(0..3).sum{i,j=j,~i;a[i][j]}}}}
```
[Try it online!](https://tio.run/##LcpNCoMwEIbhq8xSYTo4xv4h6UVCFilUSECQiAubtFdPJ8VZvXzzxO25l0mX08OlqDsicrT692uMNLslZZ@PCLmRr2pp3ebkMeiAXz86460J9iNXFpioMYYHhB7hjNxJWDR8Q7gjy8YSMoD6pwhGHqpQ2Au@IldXxYErgou1bfkB "Ruby – Try It Online")
This works on an element-by-element basis, finding the associated elements mathematically, instead of rotating the array. The key part is `i,j=j,~i`, which turns (i, j) clockwise 90 degrees.
-2 bytes thanks to Mr. Xcoder
-6 bytes because of `sum` 
[Answer]
# [Python 3](https://docs.python.org/3/), ~~105~~ 102 bytes
3 bytes thanks to Mr. Xcoder.
```
def f(a):l=len(a)-1;r=range(l+1);return[[a[i][j]+a[l-j][i]+a[l-i][l-j]+a[j][l-i]for j in r]for i in r]
```
[Try it online!](https://tio.run/##bU9BCoMwELz3FXs0mIJrrLUVXxJyEKptgkQJ9tDXp5sYoUghh5nZmZ3N8llfsxXeP4YRxqxn96mbBkvgjK3rXG@fQzblyFo3rG9npeylVtKovJfT2SgiEZEWKGGjIh1nBwa0BReh3qBfnLZrNmZSolKMnX44B6E4yJJDdRiRdOHQhKnggGXCNQd6WBwXVVG/0qhKthDBEBVJIC5ilCitxmQp/6zayrEgFNzYcLglO6H9ps2Ee2coK4vtiOhOP8MYJmsdmvwX "Python 3 – Try It Online")
[Answer]
# [Ruby](http://www.ruby-lang.org) 89 79 bytes
-10 bytes thanks to Unihedron
```
->m{n=m;3.times{n=n.zip(m=m.transpose.reverse).map{|i,j|i.zip(j).map &:sum}};n}
```
[Try it online!](https://tio.run/##pVJNT4NAEL33V0w4WE1ww7K0lTboDzCxF2@UmIpbhYSPsGDUwm9HOrO026S3XoaZefPevJ1QNe@//S7Y9PeP2T4PspVgdZJJNeQ5@0vK2yzIWF1tc1UWSrJKfstKyTuWbct9m9hpm@BUih24Waom67pV3vXhBCDEwKMhRjbmHuZDQYgNIrIPmWuDZ4xxxwYA7hB4rM643qEJc4wLHPBonHrcxSgomgggAsJcATPscYPpmrYRFrjGxcXeTBvHSjhGXBBC0ybiaoOkppkLrXbhbeRzRj6pow/ygJV/ckvOwdevEUaP@Ny8EF3FdYzbaS3NP9M8qcDcuAn5dxEWOOrxs1dSz8R9Yuj78BNCVsaOvqx/me9x8/KeqeLr/XjLScTkNv7at3XcDo2yqRVYST58l9ZQ13HojBNpS3Cqf@vhp66LN8WqtFE1iI6lRZLD1IZpd1Ta5J8FKe1C1LpOTP6UMq7lx@iNXydnjfloLghQFJ7AWj9bsATrZf0KQ2qQDrSu/wc)
[Answer]
# [Haskell](https://www.haskell.org/), ~~84 83~~ 67 bytes
```
z=zipWith
e=[]:e
f l=foldr(\_->z(z(+))l.foldr(z(:).reverse)e)l"123"
```
[Try it online!](https://tio.run/##bVBNT4NAED27v2LkBBEb9qOtNMGD1xp70KQH3NgmXYS4/QhQbfnzCLvYXah7mMB7b968mXRdfAkp67qKquywzMoUiSjmM4ESkFGyl5vcff@4f6zcyr3zPDnSUOXOvFEuvkVeCE940sGEOvVpVaT7o9w8idUZIjgcy9cyf97BtvhENz@pyEX72TBZAqcoOkOZih04i/nIASELAc7L4g0W81sHoe062zXKzR4QNC@BOMacg5nQAIxzZFgfKPfVb/Ni4gMb6nEAPgAOLNkFsp1Yi8FE1ani2aUlVjAmqlJdByQoEuhgWDxWMLb6ydVGSkPVUKJisLEx0AgNrDo1rO6yWWLF1s6dw7Rzvl5aRx/r6Box12rO9aCw0Oyg94HQVlGL0FZ4cMXWSqlIYF25s7VVvRnGECbDy@nNiNJQpWd4cIP2CpqxVaHu6@XHhtcB/5BetPB/L9ZXMZOlcwy7XBzVvw "Haskell – Try It Online")
Thanks to [Laikoni](https://codegolf.stackexchange.com/users/56433/laikoni) and [totallyhuman](https://codegolf.stackexchange.com/users/68615/totallyhuman) for saving a lot of bytes!
[Answer]
# [Husk](https://github.com/barbuz/Husk), 9 bytes
```
F‡+↑4¡(↔T
```
[Try it online!](https://tio.run/##yygtzv7/3@1Rw0LtR20TTQ4t1HjUNiXk////0dGGJjpmOuY6hiaxOtFmOoZGOobGQATmGOkAmQZApqmOIVjGKDYWAA "Husk – Try It Online")
### Explanation
```
F‡+↑4¡(↔T)  -- implicit input M, for example: [[1,0,1],[2,3,4],[0,0,2]]
     ¡(  )  -- repeat infinitely times starting with M  
        T   -- | transpose: [[1,2,0],[0,3,0],[1,4,2]]
       ↔    -- | reverse: [[1,4,2],[0,3,0],[1,2,0]]
            -- : [[[1,0,1],[2,3,4],[0,0,2]],[[1,4,2],[0,3,0],[1,2,0]],[[2,0,0],[4,3,2],[1,0,1]],[[0,2,1],[0,3,0],[2,4,1]],[[1,0,1],[2,3,4],[0,0,2]],…
   ↑4       -- take 4: [[[1,0,1],[2,3,4],[0,0,2]],[[1,4,2],[0,3,0],[1,2,0]],[[2,0,0],[4,3,2],[1,0,1]],[[0,2,1],[0,3,0],[2,4,1]]]
F           -- fold (reduce) the elements (example with [[1,0,1],[2,3,4],[0,0,2]] [[1,4,2],[0,3,0],[1,2,0]])
 ‡+         -- | deep-zip addition (elementwise addition): [[2,4,3],[2,6,4],[1,2,2]]
            -- : [[4,6,4],[6,12,6],[4,6,4]]
```
[Answer]
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 132 bytes
Let's take the recently added library function `transpose` for a spin!
```
(load library
(d T transpose
(d R(q((m #)(i #(c m(R(reverse(T m))(dec #)))(
(q((m)(foldl(q(p(map(q((r)(map sum(T r))))(T p))))(R m 4
```
The last line is an unnamed lambda function that performs rotation summation.
 To actually use it, you'll want to use `d` to bind it to a name. [Try it online!](https://tio.run/##XY7BbsIwEETvfMVIXMa32Akp/EaUH0iJI0WyibGhEl@f7hr1QE@e3Xk7nsd6e4W1pH1n2KYZYf3OU34dOGPEI0@3krbidRx4JyOOhiuOvCJyYPY/PhfPEdEYzv4qtgjFl4obLluYg@jEOCXdZaMK5RnlLBvlR6T6Dojodi7gHaTDCWcDtrCuih49bKPk4Y@xnxNawRy6z20nd1@wXY2QLCuJbR0cWk0ET7DVcf8vtYRt4ISxZ1wqhMu7lVr2nSuRrtFPlKgdhBK/17z9Fw "tinylisp – Try It Online")
### Ungolfed, with comments
```
(load library) (comment Get functions from the standard library)
(comment Rotating a matrix by 90 degrees is just transpose + reverse)
(def rotate
 (lambda (matrix)
  (reverse (transpose matrix))))
(comment This function recursively generates a list of (count) successive rotations
          of (matrix))
(def rotations
 (lambda (matrix count)
  (if count
   (cons matrix
    (rotations (rotate matrix) (dec count)))
   nil)))
(comment To add two matrices, we zip them together and add the pairs of rows)
(def matrix-add
 (lambda two-matrices
  (map row-sum (transpose two-matrices))))
(comment To add two rows of a matrix, we zip them together and add the pairs of numbers)
(def row-sum
 (lambda (two-rows)
  (map sum (transpose two-rows))))
(comment Our final function: generate a list containing four rotations of the argument
          and fold them using matrix-add)
(def rotated-sum
 (lambda (matrix)
  (foldl matrix-add (rotations matrix 4))))
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 8 bytesSBCS
```
+∘⍉∘⊖⍣3⍨
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///X/tRx4xHvZ0gsmvao97Fxo96V/xPe9Q24VFv36O@qZ7@j7qaD603ftQ2EcgLDnIGkiEensH/0xQMFQwf9W4x5EpTMFEwAbFMFMwUzBXAlKGRgqExCJkpGCkAGQYKpiD1QFEjAA "APL (Dyalog Unicode) – Try It Online")
### How it works
```
+∘⍉∘⊖⍣3⍨  ⍝ Input: matrix m
  ⍉∘⊖     ⍝ Rotate 90 degrees clockwise
+∘        ⍝ Add the original matrix m
     ⍣3⍨  ⍝ Repeat 3 times, starting with m
```
---
# [J](http://jsoftware.com/), 12 bytes
```
(+|:@|.)^:3~
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/NbRrrBxq9DTjrIzr/mtypSZn5CukKRgqGKoYgjnqurq66jBhEwUTFUMTBTMFcwUwZWikYGgMQmYKRgpAhoGCKUgrUNToPwA "J – Try It Online")
Straightforward port of the APL answer above.
[Answer]
# Java 8, ~~135~~ ~~133~~ 131 bytes
```
a->{int l=a.length,r[][]=new int[l][l],i,j,k=0;for(;k<l*l;)r[i=k/l][j=k++%l]=a[i][j]+a[j][l+~i]+a[l+~i][l-++j]+a[l-j][i];return r;}
```
-4 bytes thanks to *@ceilingcat*.
**Explanation:**
[Try it online.](https://tio.run/##lVNdT4MwFH33VzRLTJhccLCJTsTEF9/0ZXtDHirrZqErpHQzy4J/fV7K5kfEZEsKtPdwTs5pbzO6pk5RMpnN8l0qaFWRJ8rl9owQLjVTc5oy8twsTSFO4oSk1mFG@yEiNT44Kk01T8kzkSQiO@rcb/E3IiLqCiYX@g1Uw4kkezdKIsEBHDLIo0E4L5QV5nfiQoR9FfMov0Q8i3LbPhdJRGOOq8Sm@IqF/cGbqfnGwrFtgwgHMZ6EiumVkkSF9S5sjZWrV4HG9v7WBZ@RJWa0JlpxuYgTqhZVv42oWaWtg0N021YJ@SptvdqUapP8KAIMa/hT9WF0slAAAVyDN@qQC8DzwRvi6AR9QGjQAV2BZ5j@yWZGKIrsAfgdst4NjI0ujDtQ9NJQve4omMIfNDkbhc6dQ1XkBz8t/25Bc8Qmw3ejthEmm0qzpVustFvi4Wshrd6jKpa3L7pnZ3gX3JXmwn1Qim4qd8ZYOS3aNrFof785XRrT4ggF6aaNyv8y@yj17hM)
```
a->{                       // Method with integer-matrix as both parameter and return-type
  int l=a.length,          //  Dimensions of the input-matrix
      r[][]=new int[l][l], //  Result-matrix of same size
      i,j,k=0;             //  Index-integers
  for(;k<l*l;)             //  Loop over the cells
    r[i=k/l][j=k++%l]=     //    Set the cell of the result-matrix to:
      a[i][j]+a[j][l+~i]+a[l+~i][l-++j]+a[l-j][i];
                           //     The four linked cells of the input-matrix
  return r;}               //  Return the result-matrix
```
]