Skip to content

Commit 721bf21

Browse files
authored
condense doc for sqrt into single docstring (#2226)
1 parent fe402c9 commit 721bf21

17 files changed

+28
-80
lines changed

docs/src/fraction.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,7 @@ julia> h = gcd(f, g)
301301

302302
### Square root
303303

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

308306
**Examples**
309307

docs/src/function_field.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ julia> h = gcd(f, g)
162162

163163
### Square root
164164

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

169167
**Examples**
170168

docs/src/polynomial.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,7 @@ deflate(::PolyRingElem)
674674

675675
### Square root
676676

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

681679
**Examples**
682680

docs/src/puiseux.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,7 @@ true
328328
Base.log(a::Generic.PuiseuxSeriesElem)
329329
Base.exp(a::Generic.PuiseuxSeriesElem)
330330
```
331-
332-
```@docs
333-
Base.sqrt(a::Generic.PuiseuxSeriesElem)
334-
```
335-
331+
Methods for `is_square` and `sqrt` are provided for inputs of type `PuiseuxSeriesElem`.
336332

337333
**Examples**
338334

docs/src/residue.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ julia> h = gcd(f, g)
264264

265265
### Square Root
266266

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

271269
**Examples**
272270

docs/src/ring.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ evaluate(a::Fac)
252252
getindex(a::Fac, b)
253253
setindex!(a::Fac{Int}, c::Int, b::Int)
254254
```
255+
## Square root
256+
257+
Rings may implement functionality for detecting and computing square roots.
258+
259+
The exact behaviour depends on the ring. Some rings provide both operations,
260+
while others only implement `is_square`.
261+
262+
```@docs
263+
is_square
264+
sqrt(::NCRingElem)
265+
```
255266

256267
## Miscellaneous
257268

docs/src/series.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,7 @@ Base.log(a::SeriesElem{T}) where T <: FieldElem
686686
```@docs
687687
Base.exp(a::RelPowerSeriesRingElem)
688688
```
689-
690-
```@docs
691-
Base.sqrt(a::RelPowerSeriesRingElem)
692-
```
689+
Methods for `is_square` and `sqrt` are provided for inputs of type `RelPowerSeriesRingElem`.
693690

694691

695692
**Examples**

src/AbsSeries.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,13 +905,6 @@ function sqrt_classical(a::AbsPowerSeriesRingElem; check::Bool=true)
905905
return true, asqrt
906906
end
907907

908-
@doc raw"""
909-
sqrt(a::AbsPowerSeriesRingElem; check::Bool=true)
910-
911-
Return the square root of the power series $a$. By default the function will
912-
throw an exception if the input is not square. If `check=false` this test is
913-
omitted.
914-
"""
915908
function Base.sqrt(a::AbsPowerSeriesRingElem; check::Bool=true)
916909
flag, q = sqrt_classical(a; check=check)
917910
if check && !flag

src/Fraction.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,6 @@ function is_square(a::FracElem{T}) where T <: RingElem
697697
return is_square(numerator(a)) && is_square(denominator(a))
698698
end
699699

700-
@doc raw"""
701-
Base.sqrt(a::FracElem{T}; check::Bool=true) where T <: RingElem
702-
703-
Return the square root of $a$. By default the function will throw an
704-
exception if the input is not square. If `check=false` this test is omitted.
705-
"""
706700
function Base.sqrt(a::FracElem{T}; check::Bool=true) where T <: RingElem
707701
return parent(a)(sqrt(numerator(a); check=check), sqrt(denominator(a); check=check))
708702
end

src/NCRings.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ See also `is_square(M::MatElem)` which tests whether a matrix has square shape.
184184
"""
185185
function is_square end
186186

187+
@doc raw"""
188+
sqrt(a::NCRingElem; check::Bool=true)
189+
190+
Return a square root of `a`, if it exists. By default (`check=true`),
191+
implementations should raise an exception if `a` is not a square in its ring.
192+
If `check=false`, implementations may skip this verification.
193+
194+
See also `is_square` and `is_square_with_sqrt`.
195+
"""
196+
sqrt(::NCRingElem)
197+
187198
###############################################################################
188199
#
189200
# Characteristic

0 commit comments

Comments
 (0)