Comments (20)
What to do you mean by "now"? I did not observe a change to divrem in julia.
from abstractalgebra.jl.
I actually have no memory of writing this (though clearly I did).
But I assume divrem is defined as per rem, i.e. the % operator in C, which does not give the positive modulus, as we define it in Nemo. Therefore if you have negative values, divrem with Nemo ZZ will give a different answer than if you use BigInt's in Julia. This means AA will give a different answer to Nemo.
from abstractalgebra.jl.
I cannot follow. They give the same answer. Do you have an example?
from abstractalgebra.jl.
from abstractalgebra.jl.
I guess what I mean is, when we type divrem, we currently mean Euclidean division. But Julia does not give that. Therefore, we should instead use divmod in Nemo and make it return the right thing, instead of what Julia (and apparently Nemo), currently return.
from abstractalgebra.jl.
I don't see the problem. We currently have divrem(x, y) = div(x, y), rem(x, y)
for Int, BigInt and fmpz. What we return is a valid Euclidean divsion. I don't see the point of changing rem and introducing yet another function for division.
from abstractalgebra.jl.
from abstractalgebra.jl.
Sorry, yes there would be not change to rem
.
Currently mod(2, 5) and mod(-3, 5) return the same result.
from abstractalgebra.jl.
from abstractalgebra.jl.
from abstractalgebra.jl.
from abstractalgebra.jl.
I think we have been bitten by this before (divrem not yielding something positive as the second argument) and I see how divmod would help with this. I would like to hear what @fieker thinks.
So the proposal is to introduce divmod, which would be the same as divrem for polynomial rings, but would always return a positive remainder for integers.
from abstractalgebra.jl.
from abstractalgebra.jl.
I just did some more testing and searching and here is what I found out.
- Let's first look at
%
,mod
andrem
. There is no way we can be consistent with julia:
- julias mod is not the same as our mod: mod(x, y) will always have the same sign as y, that is,
mod(1, -2) = -1. On the other hand, for fmpz mod(x, y) is always positive. - % is just an alias for rem.
- More worrying is the following: Very often one needs a div(x, y) such that x - div(x, y) * y = mod(x, y). Think for example of reduction of a row in the Hermite form algorithm. At the moment, div(x, y) and divrem(x, y) won't give you such a division. Consequently you will find something like https://github.com/thofma/Hecke.jl/blob/c3e395397d4a5d890446b40ef477e85870fab793/src/Sparse/HNF.jl#L369-L374
I don't see a clear way forward. I don't mind too much about 1), but 2) is very annoying.
from abstractalgebra.jl.
from abstractalgebra.jl.
from abstractalgebra.jl.
from abstractalgebra.jl.
from abstractalgebra.jl.
No, it is not true that julias mod and rem are the same.
julia> rem(3, -2)
1
julia> mod(3, -2)
-1
Same for BigInt
.
from abstractalgebra.jl.
The original ticket here is no longer valid. And we are basically doing this optimally, with our own internal hacked versions of div and divrem defined in terms of mod not rem. It's not possible to do better without breaking HNF and ResidueRing/Field.
from abstractalgebra.jl.
Related Issues (20)
- How to convert an univariate polynomial to a multivariate polynomial? HOT 2
- `minpoly` `MethodError` HOT 2
- docs: duplicate entry for `evaluate`
- Missing or incomplete docstrings for various ring constructors
- `vars` for fractions of multivariate polynomials HOT 1
- New polynomial ring constructor implementation is type unstable
- [Bug] `view` only likes `UnitRange` even though it accepts other arguments HOT 6
- Loading this package breacks `show(Union{}[])` HOT 4
- `is_[lower/upper]_triangular` not useful for non-square matrices HOT 5
- The use of polynomial rings in multi-threaded programs HOT 3
- Rename `intersection` methods to `intersect`
- Try to export `Generic` HOT 1
- Pretty printing code (esp. indent) has issues with non-ASCII unicode strings HOT 6
- Should `macro show_name` / `@show_name` check for `:supercompact` in addition to `:compact` ? HOT 2
- Missing `Lowercase` in some printing functions HOT 2
- Implement `algebraic_closure(QQ)`
- Add a variant of `allow_unicode` which does not modify `LocalPreferences.toml` and only enables/disables unicode for the current session
- Invalidations caused by `lock(io::IOCustom)` HOT 2
- Documentation of aliases seems to fail on nightly? HOT 3
- Typo in incompatible rational function field error message
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abstractalgebra.jl.