-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory allocation in diagonal_matrix #1108
Comments
|
No, this is intentional, see the discussion in #692 |
It is documented as the first item here: http://nemocas.github.io/Nemo.jl/latest/developer/topics/#Aliasing-rules |
hmm. I see this in there:
Are we even doing this? julia> using AbstractAlgebra
julia> R, x = PolynomialRing(ZZ, "x")
(Univariate Polynomial Ring in x over Integers, x)
julia> a = ZZ(1)
1
julia> p = R([a, a, a])
x^2 + x + 1
julia> coeff(p, 0) === coeff(p, 1)
true |
Yes, you are constructing it (you are the "Constructor") and must ensure that the coefficients do not alias each other. We are not checking this :) |
I think it is badly worded. I think it means that users of such constructors... |
Sure, so the documentation is meant to push the burden onto the user. But, of course the ownership problems don't end with this. julia> R, x = PolynomialRing(ZZ, "x")
(Univariate Polynomial Ring in x over Integers, x)
julia> a = ZZ(1);
julia> array = [a, deepcopy(a), deepcopy(a)];
julia> p = R(array)
x^2 + x + 1
julia> array[2] += 1; p
x^2 + 2*x + 1 |
That is just the normal julia "no copy on construction" behavior which is unrelated to aliasing questions I believe. I am happy to review/discuss any proposal to have a consistent and easy to use aliasing/mutation model for both matrices and polynomials or anything else. Bonus points if it can be implemented in julia. |
Hmm...OK. The funny thing is that the "zero" entries in the identity matrix are unaliased, since it is created using The "Julian" solution might be to have a Alternatively, one can introduce a
|
Hello AbstractAlgebra folks,
Is this intended behaviour?
If so, I think it might be nice to make a note of this peculiarity in the documentation. In either case, I'm happy to follow this up with a PR.
The text was updated successfully, but these errors were encountered: