org-mode table row operations

Is it possible to do row operations of the following form in org-mode?

``````|  x1 |  x2 |  x3 | x4 | z1 | z2 | b |
|-----+-----+-----+----+----+----+---|
|   2 |   1 |  -7 | -1 |  1 |  0 | 0 |
| -39 |  -7 |  39 |  2 |  0 |  1 | 0 |
| -46 | -43 | 271 | -8 |  0 |  0 | 0 |
``````

get's transformed to

``````| x1 |    x2 |   x3 |   x4 |   z1 | z2 | b |
|----+-------+------+------+------+----+---|
|  1 |   0.5 | -3.5 | -0.5 |  0.5 |  0 | 0 |
|  0 | -12.5 | 19.5 | 21.5 | 19.5 |  1 | 0 |
|  0 |   -20 |  110 |  -15 |   23 |  0 | 0 |
``````

The first row gets scaled by 0.5. Subtract 39 times the first row from the second row. Add 46x first row to the third row.

Context: I'm trying to make Simplex tableaus in org-mode. There are other uses of such a feature like doing gaussian-elimination etc. I could only find table features that would let you sum along a column and write it in the bottom row and not a feature that would let you replace the contents a row with an equation of other rows. Is this possible?

You can use `remote` references and field references:

Some hints:

• `@2` stands for all columns of row 2
• `remote(FOO,REF)` refers to the cells of table named `FOO` at reference `REF`
• `@#` and `\$#` are substituted early by the current row and column number respectively. Thereby early means that the replacement happens when `remote` is not in action yet.
• `@>` and `\$>` refer to the last row and column respectively.
``````#+NAME: FOO
|  x1 |   x2 |    x3 |    x4 |   z1 | z2 |  b |
|-----+------+-------+-------+------+----+----|
|   2 |    1 |    -7 |    -1 |    1 |  0 |  0 |
| -39 |   -7 |    39 |     2 |    0 |  1 |  0 |
| -46 |  -43 |   271 |    -8 |    0 |  0 |  0 |

| x1 |   x2 |    x3 |    x4 |   z1 | z2 |  b |
|----+------+-------+-------+------+----+----|
| 1. |  0.5 |  -3.5 |  -0.5 |  0.5 | 0. | 0. |
| 0. | 12.5 | -97.5 | -17.5 | 19.5 | 1. | 0. |
| 0. | -20. |  110. |  -31. |  23. | 0. | 0. |
#+TBLFM: @2=remote(FOO,@2\$\$#)/remote(FOO,@2\$1)::@3\$1..@>\$>=remote(FOO,@@#\$\$#)-remote(FOO,@@#\$1)*@2\$0
``````

The formulation is quite general. You must take care that the result table has the same number of rows and columns as the input table. But that is easy. You can just copy-paste the input table.