"""
!=(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
julia> nt_proto_a_names = (:first, :last) | |
(:first, :last) | |
julia> nt_proto_b_names = (:larger, :smaller) | |
(:larger, :smaller) | |
julia> nt_proto_a = NamedTuple{nt_proto_a_names} | |
NamedTuple{(:first, :last),T} where T<:Tuple | |
julia> nt_proto_b = NamedTuple{nt_proto_b_names} |
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
julia> nt_proto_a_names = (:first, :last) | |
(:first, :last) | |
julia> nt_proto_b_names = (:larger, :smaller) | |
(:larger, :smaller) | |
julia> nt_proto_a = NamedTuple{nt_proto_a_names} | |
NamedTuple{(:first, :last),T} where T<:Tuple | |
julia> nt_proto_b = NamedTuple{nt_proto_b_names} |
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 | |
C_code = raw""" | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int compare(const void* l, const void* r){ | |
char* cl = *(char**)l+8; | |
char* cr = *(char**)r+8; | |
return strcmp(cl, cr); |
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> | |
<title></title> | |
<meta name="generator" content="LibreOffice 5.4.2.2 (Linux)"/> | |
<meta name="author" content="Jeffrey Sarnoff"/> | |
<meta name="created" content="2018-09-07T22:36:43.113857750"/> |
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
# some more bit related operators for Julia | |
# Jeffrey Sarnoff (2012-Oct-07) | |
# bitsizeof, allbits1, lsbs1, lsbs0, msbs1, msbs0, | |
# rol, ror, ispow2, pow2lte, pow2gte, pow2lt, pow2gt, | |
# signs_differ, signs_same, floor_avg, ceil_avg | |
bitsizeof(x) = sizeof(x)<<3 | |
SUS = Union{Signed,Unsigned} |
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
""" | |
BitOps exports functions using low level bit manipulation to modify standard Int and UInt values. | |
Note: Functions that check their arguments are named `safe_..`, others do no checking. | |
Copyright 2017 by Jeffrey Sarnoff. Released under the MIT License. | |
""" | |
module BitOps | |
export bitsizeof, clr_bit, set_bit, flp_bit, |
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 |
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
# 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 |