问题
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.
回答1:
Just write
for .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.
来源:https://stackoverflow.com/questions/22410175/clean-mathematical-notation-of-a-for-loop