# Matrix notation for double sum of row and column with the same index

a biologist/ecologist here,

I never took any courses in algebra (definitely missing in my education) but I am working with matrices all day.

For one paper, I have to write the matrix formulation but I am unsure of the conventions and how to write this:

  |1|2|3|4| j
1| 0 0 0 1
2| 0 0 0 0
3| 0 1 1 1
4| 0 1 0 0
i


Let's assume this binary matrix of i rows and j columns (Aij), I want to compute the sum of rows and columns i and j where i = j. A column and a row contains info on one species (i=1 and j=1 contains info on species i). I call my ensemble of species k.

For each species k, I want to calculate the sum of a species abundance (wk) multiplied by the sum of 1 in a species row and column (so sum of aik and akj). For instance, when k=1, the sum would be (0+0+0+0)+(0+0+0+1) = 1

So far I wrote this:

https://i.stack.imgur.com/aJp7u.png

Is this correct? Is there a better/simpler notation?

$$\begin{equation*} wG=\frac{\sum ^{S}_{k=1} \ \left( w_{k} \ \sum ^{S}_{i=1}( a_{ik} +a_{ki}) \ \right)}{\sum ^{S}_{k=1} w_{k}} \ where\ i=j \end{equation*}$$

If you want to add the entries of the $$k$$th row with the entries of the $$k$$th column, then the sum would be $$\sum_{i=1}^n \left( a_{ik} + a_{ki} \right).$$