Docstrings
EltypeExtensions._to_basetype
— Method_to_basetype(T::Type, S::Type)
Convert type S
to have the basetype
of T
.
EltypeExtensions._to_eltype
— Method_to_eltype(T, S)
Convert type S
to have the eltype
of T
. See also convert_eltype
.
EltypeExtensions._to_precisiontype
— Method_to_precisiontype(T::Type, S::Type)
Convert type S
to have the precisiontype
of T
. An exception is that if T<:Integer
, then Rational
will also be unwrapped.
Examples
julia> _to_precisiontype(Float64, Complex{Rational{Int}})
+Docstrings · EltypeExtensions Docstrings
EltypeExtensions._to_basetype
— Method_to_basetype(T::Type, S::Type)
Convert type S
to have the basetype
of T
.
sourceEltypeExtensions._to_eltype
— Method_to_eltype(T, S)
Convert type S
to have the eltype
of T
. See also convert_eltype
.
sourceEltypeExtensions._to_precisiontype
— Method_to_precisiontype(T::Type, S::Type)
Convert type S
to have the precisiontype
of T
. An exception is that if T<:Integer
, then Rational
will also be unwrapped.
Examples
julia> _to_precisiontype(Float64, Complex{Rational{Int}})
ComplexF64 (alias for Complex{Float64})
julia> _to_precisiontype(BigFloat, Matrix{Complex{Bool}})
Matrix{Complex{BigFloat}} (alias for Array{Complex{BigFloat}, 2})
julia> _to_precisiontype(Int, Complex{Rational{BigInt}})
-Complex{Rational{Int64}}
sourceEltypeExtensions.basetype
— Methodbasetype(T::Type)
Recursively apply eltype
to T
until convergence.
Examples
julia> basetype(Matrix{BitArray})
+Complex{Rational{Int64}}
sourceEltypeExtensions.basetype
— Methodbasetype(T::Type)
Recursively apply eltype
to T
until convergence.
Examples
julia> basetype(Matrix{BitArray})
Bool
julia> basetype(Vector{Set{Complex{Float64}}})
ComplexF64 (alias for Complex{Float64})
julia> basetype([1:n for n in 1:10])
-Int64
sourceEltypeExtensions.convert_basetype
— Methodconvert_basetype(T::Type, A)
Similar to convert(T, A)
, but T
refers to the basetype
.
sourceEltypeExtensions.convert_eltype
— Methodconvert_eltype(T, A)
Similar to convert(T, A)
, but T
refers to the eltype. See also _to_eltype
.
Examples
julia> convert_eltype(Float64, 1:10)
+Int64
sourceEltypeExtensions.convert_basetype
— Methodconvert_basetype(T::Type, A)
Similar to convert(T, A)
, but T
refers to the basetype
.
sourceEltypeExtensions.convert_eltype
— Methodconvert_eltype(T, A)
Similar to convert(T, A)
, but T
refers to the eltype. See also _to_eltype
.
Examples
julia> convert_eltype(Float64, 1:10)
1.0:1.0:10.0
julia> typeof(convert_eltype(Float64, rand(Int, 3, 3)))
-Matrix{Float64} (alias for Array{Float64, 2})
sourceEltypeExtensions.convert_precisiontype
— Methodconvert_precisiontype(T::Type, A, prec)
Convert A
to have the precisiontype
of T
. prec
is optional.
- When
T
has static precision (e.g. Float64
), prec
has no effect. - When
T
has dynamic precision (e.g. BigFloat
), prec
specifies the precision of conversion. When prec
is not provided, the precision is decided by the external setup from T
. - When
T
is an integer, the conversion will dig into Rational
as well. In contrast, since Rational
as a whole is more "precise" than an integer, precisiontype
doesn't unwrap Rational
.
Examples
julia> convert_precisiontype(BigFloat, 1//3+im, 128)
+Matrix{Float64} (alias for Array{Float64, 2})
sourceEltypeExtensions.convert_precisiontype
— Methodconvert_precisiontype(T::Type, A, prec)
Convert A
to have the precisiontype
of T
. prec
is optional.
- When
T
has static precision (e.g. Float64
), prec
has no effect. - When
T
has dynamic precision (e.g. BigFloat
), prec
specifies the precision of conversion. When prec
is not provided, the precision is decided by the external setup from T
. - When
T
is an integer, the conversion will dig into Rational
as well. In contrast, since Rational
as a whole is more "precise" than an integer, precisiontype
doesn't unwrap Rational
.
Examples
julia> convert_precisiontype(BigFloat, 1//3+im, 128)
0.3333333333333333333333333333333333333338 + 1.0im
julia> convert_precisiontype(Float16, [[m/n for n in 1:3] for m in 1:3])
3-element Vector{Vector{Float16}}:
[1.0, 0.5, 0.3333]
[2.0, 1.0, 0.6665]
- [3.0, 1.5, 1.0]
sourceEltypeExtensions.precisiontype
— Methodprecisiontype(T::Type)
Returns the type that decides the precision of T
. The difference from basetype
is that precisiontype
unwraps composite basetypes such as Complex
and that precisiontype
is not generalised.
Examples
julia> precisiontype(Complex{Float32})
+ [3.0, 1.5, 1.0]
sourceEltypeExtensions.precisiontype
— Methodprecisiontype(T::Type)
Returns the type that decides the precision of T
. The difference from basetype
is that precisiontype
unwraps composite basetypes such as Complex
and that precisiontype
is not generalised.
Examples
julia> precisiontype(Complex{Float32})
Float32
julia> precisiontype(Matrix{ComplexF64})
-Float64
sourceSettings
This document was generated with Documenter.jl version 1.8.0 on Monday 23 December 2024. Using Julia version 1.6.7.
+Float64