MATL, 13(削除) 13 (削除ここまで) 11 bytes
This uses logical indexing. As an index we use an identity matrix of the size of the input and or it with it's flipped version, just like in my Octave answer. Thanks @LuisMendo for -2 bytes:)
GG&nxXytPY|tZyXytPY|)s
Explanation
GG t push input twice to stack
&n Zy get size of matrix
x discard one of the two size numbers
Xy get an identity matrix of that size
t duplicate the identity matrix
P flip one of the identty matrices
Y| logical OR the two identity matrices
) perform (logical) indexing to the original matrix
s compute the sum
MATL, 13 bytes
This uses logical indexing. As an index we use an identity matrix of the size of the input and or it with it's flipped version, just like in my Octave answer.
GG&nxXytPY|)s
Explanation
GG push input twice to stack
&n get size of matrix
x discard one of the two size numbers
Xy get an identity matrix of that size
t duplicate the identity matrix
P flip one of the identty matrices
Y| logical OR the two identity matrices
) perform (logical) indexing to the original matrix
s compute the sum
MATL, (削除) 13 (削除ここまで) 11 bytes
This uses logical indexing. As an index we use an identity matrix of the size of the input and or it with it's flipped version, just like in my Octave answer. Thanks @LuisMendo for -2 bytes:)
tZyXytPY|)s
Explanation
t push input twice to stack
Zy get size of matrix
Xy get an identity matrix of that size
t duplicate the identity matrix
P flip one of the identty matrices
Y| logical OR the two identity matrices
) perform (logical) indexing to the original matrix
s compute the sum
MATL, 13 bytes
This uses logical indexing. As an index we use an identity matrix of the size of the input and or it with it's flipped version, just like in my Octave answer.
GG&nxXytPY|)s
Explanation
GG push input twice to stack
&n get size of matrix
x discard one of the two size numbers
Xy get an identity matrix of that size
t duplicate the identity matrix
P flip one of the identty matrices
Y| logical OR the two identity matrices
) perform (logical) indexing to the original matrix
s compute the sum