Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/src/fraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ julia> h = gcd(f, g)

### Square root

```@docs
Base.sqrt(::FracElem{T}) where {T <: RingElem}
```
Methods for `is_square` and `sqrt` are provided for inputs of type `FracElem`.

**Examples**

Expand Down
4 changes: 1 addition & 3 deletions docs/src/function_field.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ julia> h = gcd(f, g)

### Square root

```@docs
Base.sqrt(::Generic.RationalFunctionFieldElem{T, U}) where {T <: FieldElem, U <: Union{PolyRingElem, MPolyRingElem}}
```
Methods for `is_square` and `sqrt` are provided for inputs of type `RationalFunctionFieldElem`.

**Examples**

Expand Down
4 changes: 1 addition & 3 deletions docs/src/polynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,7 @@ deflate(::PolyRingElem)

### Square root

```@docs
Base.sqrt(::PolyRingElem{T}; check::Bool) where T <: RingElement
```
Methods for `is_square` and `sqrt` are provided for inputs of type `PolyRingElem`.

**Examples**

Expand Down
6 changes: 1 addition & 5 deletions docs/src/puiseux.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,7 @@ true
Base.log(a::Generic.PuiseuxSeriesElem)
Base.exp(a::Generic.PuiseuxSeriesElem)
```

```@docs
Base.sqrt(a::Generic.PuiseuxSeriesElem)
```

Methods for `is_square` and `sqrt` are provided for inputs of type `PuiseuxSeriesElem`.

**Examples**

Expand Down
4 changes: 1 addition & 3 deletions docs/src/residue.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ julia> h = gcd(f, g)

### Square Root

```@docs
Base.sqrt{T <: Integer}(::ResFieldElem{T})
```
Methods for `is_square` and `sqrt` are provided for inputs of type `ResFieldElem`.

**Examples**

Expand Down
11 changes: 11 additions & 0 deletions docs/src/ring.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,17 @@ evaluate(a::Fac)
getindex(a::Fac, b)
setindex!(a::Fac{Int}, c::Int, b::Int)
```
## Square root

Rings may implement functionality for detecting and computing square roots.

The exact behaviour depends on the ring. Some rings provide both operations,
while others only implement `is_square`.

```@docs
is_square
sqrt(::NCRingElem)
```

## Miscellaneous

Expand Down
5 changes: 1 addition & 4 deletions docs/src/series.md
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,7 @@ Base.log(a::SeriesElem{T}) where T <: FieldElem
```@docs
Base.exp(a::RelPowerSeriesRingElem)
```

```@docs
Base.sqrt(a::RelPowerSeriesRingElem)
```
Methods for `is_square` and `sqrt` are provided for inputs of type `RelPowerSeriesRingElem`.


**Examples**
Expand Down
7 changes: 0 additions & 7 deletions src/AbsSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -905,13 +905,6 @@ function sqrt_classical(a::AbsPowerSeriesRingElem; check::Bool=true)
return true, asqrt
end

@doc raw"""
sqrt(a::AbsPowerSeriesRingElem; check::Bool=true)

Return the square root of the power series $a$. By default the function will
throw an exception if the input is not square. If `check=false` this test is
omitted.
"""
function Base.sqrt(a::AbsPowerSeriesRingElem; check::Bool=true)
flag, q = sqrt_classical(a; check=check)
if check && !flag
Expand Down
6 changes: 0 additions & 6 deletions src/Fraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -697,12 +697,6 @@ function is_square(a::FracElem{T}) where T <: RingElem
return is_square(numerator(a)) && is_square(denominator(a))
end

@doc raw"""
Base.sqrt(a::FracElem{T}; check::Bool=true) where T <: RingElem

Return the square root of $a$. By default the function will throw an
exception if the input is not square. If `check=false` this test is omitted.
"""
function Base.sqrt(a::FracElem{T}; check::Bool=true) where T <: RingElem
return parent(a)(sqrt(numerator(a); check=check), sqrt(denominator(a); check=check))
end
Expand Down
11 changes: 11 additions & 0 deletions src/NCRings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ See also `is_square(M::MatElem)` which tests whether a matrix has square shape.
"""
function is_square end

@doc raw"""
sqrt(a::NCRingElem; check::Bool=true)

Return a square root of `a`, if it exists. By default (`check=true`),
implementations should raise an exception if `a` is not a square in its ring.
If `check=false`, implementations may skip this verification.

See also `is_square` and `is_square_with_sqrt`.
"""
sqrt(::NCRingElem)

###############################################################################
#
# Characteristic
Expand Down
6 changes: 0 additions & 6 deletions src/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1825,12 +1825,6 @@ function sqrt_classical(f::PolyRingElem{T}; check::Bool=true) where T <: RingEle
return true, q
end

@doc raw"""
Base.sqrt(f::PolyRingElem{T}; check::Bool=true) where T <: RingElement

Return the square root of $f$. By default the function checks the input is
square and raises an exception if not. If `check=false` this check is omitted.
"""
function Base.sqrt(f::PolyRingElem{T}; check::Bool=true) where T <: RingElement
flag, q = sqrt_classical(f; check=check)
check && !flag && error("Not a square in sqrt")
Expand Down
7 changes: 0 additions & 7 deletions src/RelSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,6 @@ function sqrt_classical(a::RelPowerSeriesRingElem; check::Bool=true)
return true, asqrt
end

@doc raw"""
sqrt(a::RelPowerSeriesRingElem)

Return the square root of the power series $a$. By default the function raises
an exception if the input is not a square. If `check=false` this check is
omitted.
"""
function Base.sqrt(a::RelPowerSeriesRingElem; check::Bool=true)
flag, q = sqrt_classical(a; check=check)
if check && !flag
Expand Down
6 changes: 0 additions & 6 deletions src/ResidueField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,6 @@ function is_square(a::ResFieldElem{T}) where T <: Integer
return isone(a^pm1div2)
end

@doc raw"""
sqrt(a::ResFieldElem{T}; check::Bool=true) where T <: Integer

Return the square root of $a$. By default the function will throw an exception
if the input is not square. If `check=false` this test is omitted.
"""
function Base.sqrt(a::ResFieldElem{T}; check::Bool=true) where T <: Integer
U = parent(a)
p = modulus(a)
Expand Down
7 changes: 0 additions & 7 deletions src/Rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,6 @@ end
#
################################################################################

@doc raw"""
sqrt(a::FieldElem)

Return the square root of the element `a`. By default the function will
throw an exception if the input is not square. If `check=false` this test is
omitted.
"""
function Base.sqrt(a::FieldElem; check::Bool=true)
R = parent(a)
R, t = polynomial_ring(R, :t; cached = false)
Expand Down
7 changes: 0 additions & 7 deletions src/generic/LaurentSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1395,13 +1395,6 @@ function sqrt_classical(a::LaurentSeriesElem; check::Bool=true)
return true, asqrt
end

@doc raw"""
sqrt(a::Generic.LaurentSeriesElem; check::Bool=true)

Return the square root of the power series $a$. By default the function will
throw an exception if the input is not square. If `check=false` this test is
omitted.
"""
function Base.sqrt(a::LaurentSeriesElem; check::Bool=true)
flag, s = sqrt_classical(a, check=check)
check && !flag && error("Not a square in sqrt")
Expand Down
7 changes: 0 additions & 7 deletions src/generic/PuiseuxSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,6 @@ function sqrt_classical(a::PuiseuxSeriesElem{T}; check::Bool=true) where T <: Ri
return true, S(s, sscale)
end

@doc raw"""
sqrt(a::Generic.PuiseuxSeriesElem{T}; check::Bool=true) where T <: RingElement

Return the square root of the given Puiseux series $a$. By default the function
will throw an exception if the input is not square. If `check=false` this test
is omitted.
"""
function Base.sqrt(a::PuiseuxSeriesElem{T}; check::Bool=true) where T <: RingElement
flag, s = sqrt_classical(a; check=check)
check && !flag && error("Not a square in sqrt")
Expand Down
6 changes: 0 additions & 6 deletions src/generic/RationalFunctionField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,6 @@ function is_square(a::RationalFunctionFieldElem)
return is_square(data(a))
end

@doc raw"""
Base.sqrt(a::RationalFunctionFieldElem; check::Bool=true)

Return the square root of $a$. By default the function will throw an exception
if the input is not square. If `check=false` this test is omitted.
"""
function Base.sqrt(a::RationalFunctionFieldElem; check::Bool=true)
R = parent(a)
return R(sqrt(data(a); check=check))
Expand Down