View vectorprism.jl
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
module VectorPrisms | |
function check_compatible(::Type{T}) where T | |
isconcretetype(T) || error("Type is not fully concrete") | |
for ft in fieldtypes(T) | |
check_compatible(ft) | |
end | |
end | |
check_compatible(::Type{<:Array}) = error("Type contains an array") | |
check_compatible(::Type{Nothing}) = error("Nothing is not supporting.") |
View example.jl
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
#Helpers: | |
"Given some IR generates a MethodInstance suitable for passing to infer_ir!, if you don't already have one with the right argument types" | |
function get_toplevel_mi_from_ir(ir, _module::Module) | |
mi = ccall(:jl_new_method_instance_uninit, Ref{Core.MethodInstance}, ()); | |
mi.specTypes = Tuple{ir.argtypes...} | |
mi.def = _module | |
return mi | |
end | |
"run type inference and constant propagation on the ir" |
View active_rrule.jl
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
abstract type ActivityMarked{T} end | |
struct Active{T} <: ActivityMarked{T} | |
val::T | |
end | |
struct Dead{T} <: ActivityMarked{T} | |
val::T | |
end | |
View thomas_tests.jl
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 LinearAlgebra | |
# Wikipedia non-preserving version (transcribed from VB) | |
# https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm | |
# this one is wrong (found this in use in the wild 😢) | |
function thomas_algorithm!(a, b, c, r, ::Val{1}) | |
n = length(b) | |
for i in 2:(n-1) | |
m = a[i]/b[i-1]; | |
b[i] = b[i] - m * c[i - 1]; |
View day1.dx
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
'# Advent of Code 2020. Day 1 | |
DexLang, [Lyndon White](http://oxinabox.net) | |
## part 1 | |
From the list find two entries that sum to 2020, and compute their product. | |
list = [1567, 1223, 1758, 1842, 1933, 1898, 1409, 1058, 1533, 1417, 1032, 1634, 1477, 1394, 1888, 1972, 1237, 1390, 1677, 1546, 1302, 1070, 1369, 1455, 1065, 1924, 1593, 1131, 1064, 1346, 1914, 1129, 1830, 1450, 1278, 1740, 1809, 1176, 1734, 1102, 1807, 1982, 1603, 1736, 2008, 1980, 1905, 1633, 1732, 1350, 1865, 1988, 1805, 1998, 1152, 1046, 1870, 1557, 1789, 1766, 1945, 1359, 1002, 1126, 1719, 1497, 1296, 1560, 1936, 1929, 1464, 2005, 1281, 618, 1257, 1107, 1632, 1688, 1964, 1803, 1360, 1384, 1889, 1411, 1328, 1452, 1868, 1515, 1586, 1631, 1618, 1087, 1710, 1094, 1774, 1295, 1700, 1636, 1230, 1421, 1910, 1522, 1366, 1144, 1757, 1493, 1316, 1103, 687, 1371, 1720, 1155, 1559, 1900, 989, 1367, 1999, 1066, 1773, 1787, 1402, 1047, 1806, 1956, 1219, 1555, 1307, 1419, 1706, 1884, 1109, 1181, 2010, 1298, 1730, 1078, 1848, 1398, 1687, 2007, 1550, 1664, 1225 |
View demo.jl
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 DataFrames, BenchmarkTools, DataFramesMeta | |
eg_df(n=100_000) = DataFrame(a=rand(1:10, n), b=rand('a':'z', n), c=rand('A':'Z', n)) | |
# for eachrow loop | |
# 7.132 ms (239156 allocations: 4.10 MiB) | |
@btime let | |
df = $(eg_df()) | |
for row in eachrow(df) | |
if row.a == 1 |
View isbits.jl
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
function print_isbits(f) | |
seen = Set() | |
MAX_ELE = 3 | |
function print_isbits(fname, fval::FTYPE, indent) where FTYPE | |
ftext = "$fname - $FTYPE\n" | |
print(" "^indent) | |
fbits = isbitstype(FTYPE) | |
if fbits |
View convexbased.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View NNMF.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View ex.jl
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
## With this PR | |
julia> using Dates | |
# PERIOD | |
julia> d = Day(1) | |
1 day | |
julia> show(d) |
NewerOlder