PTYQoL.jl
PTYQoL.fields
— Method@generated fields(::Type{T}) where T = fieldnames(T)
The same as fieldnames
, but is @generated
so is fast.
PTYQoL.fracpochhammer
— Methodfracpochhammer(a, b, n)
Calculate the fraction of two Pochhammer symbols $\frac{(a)_n}{(b)_n}$ by multiplying the fractions. This approach reduces the risk of overflow/underflow when $n$ is large.
Examples
julia> fracpochhammer(1, 2, 3) # (1 * 2 * 3) / (2 * 3 * 4)
+PTYQoL.jl · PTYQoL PTYQoL.jl
PTYQoL.fields
— Method@generated fields(::Type{T}) where T = fieldnames(T)
The same as fieldnames
, but is @generated
so is fast.
sourcePTYQoL.fracpochhammer
— Methodfracpochhammer(a, b, n)
Calculate the fraction of two Pochhammer symbols $\frac{(a)_n}{(b)_n}$ by multiplying the fractions. This approach reduces the risk of overflow/underflow when $n$ is large.
Examples
julia> fracpochhammer(1, 2, 3) # (1 * 2 * 3) / (2 * 3 * 4)
0.25
fracpochhammer(a, b, stepa, stepb, n)
Similar to fracpochhammer(a, b, n)
, except that the steps of the Pochhammer symbols are not necessarily $1$.
Examples
julia> fracpochhammer(1, 2, 0.5, 1, 3) # (1 * 1.5 * 2) / (2 * 3 * 4)
-0.125
sourcePTYQoL.isalias
— Methodisalias(type)
Check if a type is alias.
Examples
julia> isalias(Vector)
+0.125
sourcePTYQoL.isalias
— Methodisalias(type)
Check if a type is alias.
Examples
julia> isalias(Vector)
true
julia> isalias(Array)
-false
sourcePTYQoL.ln
— Functionconst ln = Fix1(log,ℯ)
Natural logarithm.
sourcePTYQoL.seealso
— Methodseealso(s...)
Produce the "See also" parts of docstrings.
julia> seealso(sin)
+false
sourcePTYQoL.ln
— Functionconst ln = Fix1(log,ℯ)
Natural logarithm.
sourcePTYQoL.seealso
— Methodseealso(s...)
Produce the "See also" parts of docstrings.
julia> seealso(sin)
"See also [`sin`](@ref)."
julia> seealso(sin, cos)
"See also [`sin`](@ref) and [`cos`](@ref)."
julia> seealso(sin, cos, tan)
-"See also [`sin`](@ref), [`cos`](@ref) and [`tan`](@ref)."
sourcePTYQoL.@Vararg1
— Macro@Vararg1
Use before a function definition to let x::T...
means at least one (instead of zero by Julia default) of type T
. This can be used to avoid ambiguity as all Vararg{T}
overlap at zero argument.
Example
julia> mysum1(x::Int...) = x
+"See also [`sin`](@ref), [`cos`](@ref) and [`tan`](@ref)."
sourcePTYQoL.@Vararg1
— Macro@Vararg1
Use before a function definition to let x::T...
means at least one (instead of zero by Julia default) of type T
. This can be used to avoid ambiguity as all Vararg{T}
overlap at zero argument.
Example
julia> mysum1(x::Int...) = x
mysum1 (generic function with 1 method)
julia> mysum1() # works for 0 argument
@@ -31,7 +31,7 @@
mysum2 (generic function with 2 methods)
julia> mysum2()
-ERROR: MethodError: no method matching mysum2()
sourcePTYQoL.@struct_all
— Macro@struct_all(TYP, op)
+ERROR: MethodError: no method matching mysum2()
sourcePTYQoL.@struct_all
— Macro@struct_all(TYP, op)
@struct_all(TYP, ops...)
Define the operator of the type TYP
by applying the operator to each field and return true only when all the results are true. See also @struct_any
, @struct_copy
and @struct_map
.
Example
julia> struct Foo
a
b
@@ -55,7 +55,7 @@
julia> @struct_all Foo Base.:(==) Base.isequal Base.isapprox Base.isfinite
julia> x==y, isequal(x,y), isapprox(x,y), isfinite(x)
-(true, true, true, true)
sourcePTYQoL.@struct_any
— Macro@struct_any(TYP, op)
+(true, true, true, true)
sourcePTYQoL.@struct_any
— Macro@struct_any(TYP, op)
@struct_any(TYP, ops...)
Define the binary operator of the type TYP
by applying the operator to each field and return true when any of the results is true. See also @struct_all
, @struct_copy
and @struct_map
.
Example
julia> struct Foo
a
b
@@ -73,7 +73,7 @@
julia> @struct_any Foo Base.isinf Base.isnan
julia> isinf(x), isnan(x)
-(true, true)
sourcePTYQoL.@struct_copy
— Macro@struct_copy(TYP)
Generate Base.copy
for copying structs of type TYP
. See also @struct_all
, @struct_any
and @struct_map
.
Example
julia> struct Foo
+(true, true)
sourcePTYQoL.@struct_copy
— Macro@struct_copy(TYP)
Generate Base.copy
for copying structs of type TYP
. See also @struct_all
, @struct_any
and @struct_map
.
Example
julia> struct Foo
a
b
end
@@ -87,7 +87,7 @@
julia> @struct_copy Foo;
julia> y = copy(x)
-Foo(1, 1)
sourcePTYQoL.@struct_map
— Macro@struct_map(TYP, op)
+Foo(1, 1)
sourcePTYQoL.@struct_map
— Macro@struct_map(TYP, op)
@struct_map(TYP, ops...)
Define the function(s) of the type TYP
by applying the function(s) to each field and generate a new TYP
with the values. The generated function(s) are somehow faster than the naive implementation. See also @struct_all
, @struct_any
and @struct_copy
.
Example
julia> struct Foo
a
b
@@ -99,4 +99,4 @@
julia> @struct_map(Foo, Base.exp, Base.sin, Base.:+)
julia> exp(x), sin(x), x+x
-(Foo(2.718281828459045, 2.718281828459045), Foo(0.8414709848078965, 0.8414709848078965), Foo(2, 2))
sourceSettings
This document was generated with Documenter.jl version 1.7.0 on Monday 4 November 2024. Using Julia version 1.9.4.
+(Foo(2.718281828459045, 2.718281828459045), Foo(0.8414709848078965, 0.8414709848078965), Foo(2, 2))