Nemocas / Nemo.jl

Julia bindings for various mathematical libraries (including flint2)
http://nemocas.github.io/Nemo.jl/
Other
185 stars 59 forks source link

Document allowed mutation behaviour for Nemo, especially matrix inplace operations #278

Closed wbhart closed 3 years ago

wbhart commented 6 years ago

We decided:

wbhart commented 4 years ago

The following example of @martinra shows why arithmetic operations should also be careful to not allow aliasing of any part of their inputs with their output:

R,x = LaurentSeriesRing(QQ,20,"x")
a = sum(n*x^n for n in 1:17)
b = 83 + 43*x^10 + O(x^20)
c = a + b
ccp = deepcopy(c)
addeq!(a,b)
c-a
c-ccp

Here, if c aliases some coefficients with a or b after c = a + b then c will be modified by the call to addeq!(a, b).

wbhart commented 3 years ago

This is now documented in devel docs.