"""
!=(x)
Create a function that compares its argument to `x` using [`!=`](@ref), i.e.
a function equivalent to `y -> y != x`.
The returned function is of type `Base.Fix2{typeof(!=)}`, which can be
used to implement specialized methods.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools, Statistics | |
const BParams = BenchmarkTools.DEFAULT_PARAMETERS | |
BParams.evals = 1; # generally good to set as 1 | |
BParams.samples = 2; # usually set to e.g. 3000, here it is 2 so result is viewable | |
avec = collect(1:8); | |
trial = @benchmark $avec .+ $avec; | |
#= | |
julia> trial = @benchmark $avec .+ $avec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= | |
# follows code by Jacob Quinn in response to this | |
t = zeros(Int64, 100000); | |
@btime sum(t) | |
12.084 μs (0 allocations: 0 bytes) | |
0 | |
t2 = reinterpret(Int64, zeros(UInt64, 100000)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Base: uniontypes | |
""" | |
is_type_stable(fn, argtypes) | |
`fn` returns values of a stable type | |
if `is_type_stable(fn, argtypes)` | |
then `y = fn(args)` supports fast dispatch on `y` | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Colors, FixedPointNumbers | |
const TurboColors = RGB{Normed{UInt8,8}}[ | |
RGB{N0f8}(0.192,0.075,0.243), | |
RGB{N0f8}(0.196,0.082,0.259), | |
RGB{N0f8}(0.196,0.09,0.278), | |
RGB{N0f8}(0.2,0.094,0.294), | |
RGB{N0f8}(0.204,0.102,0.314), | |
RGB{N0f8}(0.204,0.11,0.329), | |
RGB{N0f8}(0.208,0.118,0.349), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= | |
Can we make `compactify` run more quickly than it already does? | |
=# | |
#= | |
The algorithm for `compactify` is from Hiroshi Murakami's paper | |
Calculation of rational numbers in an interval whose denominator is the smallest | |
ACM Communications in Computer Algebra, Vol 48, No. 3, Issue 189, September 2014 | |
Hiroshi Murakami, Department of Mathematics and Information Sciences, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= | |
These examples use ArbNumerics v0.4.4, no earlier version supports `exp(matrix)`. | |
So, either first do `pkg> up` or do `pkg> rm ArbNumerics` then `pkg> add ArbNumerics`. | |
Sometimes, rebuilding with `pkg> build ArbNumerics` cleans up after itself. | |
All the matrix handling is new code, the examples here are working as of now. | |
If you find anything unclear or something awry, post an issue and | |
please use slack's direct message to draw my attention. | |
=# | |
#= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# within Base/mpfr.jl | |
function _duplicate(x::BigFloat) | |
z = BigFloat(; precision = precision(x)) | |
ccall((:mpfr_set, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, 0) | |
return z | |
end | |
function nextfloat!(x::BigFloat) | |
ccall((:mpfr_nextabove, :libmpfr), Int32, (Ref{BigFloat},), x) != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/pfitzseb/240744ce79a9d7561c1277de7dbfa43e | |
module TraceCalls | |
using Cassette | |
mutable struct Trace | |
level::Int | |
cutoff::Int | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dates | |
const DTM = Union{Date, DateTime} | |
value(dtm::DTM) = dtm.instant.periods.value | |
abstract type AbstractDayCountConvention end | |
struct ActualActualConvention <: AbstractDayCountConvention end |