Skip to content
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

copy with matrix argument gives error #1337

Open
matthias314 opened this issue Aug 14, 2022 · 4 comments
Open

copy with matrix argument gives error #1337

matthias314 opened this issue Aug 14, 2022 · 4 comments

Comments

@matthias314
Copy link

The following code works for AbstractAlgebra, but not for Nemo (v0.32.2):

julia> a = zero_matrix(ZZ, 2, 2);
julia> copy(a)
ERROR: MethodError: no method matching copy(::fmpz_mat)

The same happens with QQ and GF(2) instead of ZZ. Shouldn't Nemo provide a method for copy?

@thofma
Copy link
Member

thofma commented Aug 15, 2022

It is impossible to define a copy method for Nemo matrices with the same semantics. We should probably remove the copy method in AbstractAlgebra to make it more uniform.

@matthias314
Copy link
Author

Maybe the exact semantics are impossible. But it must be possible to produce a matrix B that is equal to a given matrix A and that one can modify without changing A. I think there are use cases for such a function, and it would make sense to call it copy.

@thofma
Copy link
Member

thofma commented Aug 15, 2022

There is deepcopy.

@matthias314
Copy link
Author

Yes. Instead of removing copy from AbstractAlgebra, would it make sense to make it call deepcopy in Nemo? Plain Julia also provides copy for arrays, so people might expect it to exist for other matrix types. I would guess that most users are not concerned about the exact semantics, but only want a cheap way to get a copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants