Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean mathematical notation of a for-loop

I am sorry if this doesn't really belong here but I'm looking for a way to describe the mathematical background of my code. Using numpy I sum two more dimensional arrays:

a.shape = (10, 5, 2)
b.shape = (5, 2)
c = a + b
c.shape = (10, 5, 2)

Is there a pure mathematical notation for this (so WITHOUT indroducing for-loops or numpy conventions in my text)? What I'm trying to avoid is to have to write something like this:

c_{1, y, z} = a_{1, y, z} + b_{y, z}

c_{2, y, z} = a_{2, y, z} + b_{y, z}

...

c_{10, y, z} = a_{10, y, z} + b_{y, z}

Any thoughts?

Edit: I'm using LaTeX for the documentation, so indexing is no problem. I'm currently using more or less the suggestion from Tobias. I was just hoping that there may be some other solution I haven't thought of.

like image 700
Lukas Avatar asked Mar 21 '23 05:03

Lukas


1 Answers

Just write

enter image description here for enter image description here.

You find this form often in books on numerics like Numerical Recipes (e.g., page 57).

If you have larger sections of code an alternative is to use pseudo-code.

like image 191
Tobias Avatar answered Mar 22 '23 18:03

Tobias