Clean mathematical notation of a for-loop

拟墨画扇 提交于 2020-02-03 19:02:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!