Skip to content

Instantly share code, notes, and snippets.

View Sacha0's full-sized avatar

Sacha Verweij Sacha0

  • Stanford University
View GitHub Profile
@Sacha0
Sacha0 / indextribenchcode.jl
Last active December 27, 2015 22:29
Benchmark indexing through triangular types in Julia.
import Base.LinAlg.UnitLowerTriangular
import Base.LinAlg.UnitUpperTriangular
# Define getindex candidates for LowerTriangular matrices (tern_ is the original)
tern_getindex{T,S}(A::LowerTriangular{T,S}, i::Integer, j::Integer) = i >= j ? A.data[i,j] : zero(A.data[j,i])
ternz_getindex{T,S}(A::LowerTriangular{T,S}, i::Integer, j::Integer) = i >= j ? A.data[i,j] : zero(T)
ifelse_getindex{T,S}(A::LowerTriangular{T,S}, i::Integer, j::Integer) = ifelse(i >= j, A.data[i,j], zero(A.data[j,i]))
ifelsez_getindex{T,S}(A::LowerTriangular{T,S}, i::Integer, j::Integer) = ifelse(i >= j, A.data[i,j], zero(T))
ltmethstrings = ("tern", "ternz", "ifelse", "ifelsez")
using Benchmarks: @benchmark, SummaryStatistics
function prettytimesandmem(bench)
stats = SummaryStatistics(bench)
timecenter = stats.elapsed_time_center
timelower = get(stats.elapsed_time_lower)
timeupper = get(stats.elapsed_time_upper)
numallocs = stats.allocations
bytesalloc = stats.bytes_allocated
# based on Benchmarks.pretty_time_string
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.3 (2016-01-12 21:37 UTC)
_/ |\__'_|_|_|\__'_| |
|__/ | x86_64-apple-darwin14.5.0
julia> function burntime(n)
@Sacha0
Sacha0 / defull-concattypemap.jl
Last active September 14, 2016 18:51
ConcatTypeMapping
### vector-vector vcat type mapping ###
vcat(Array{Float64,1}, Array{Float64,1}) -> Array{Float64,1}
vcat(Array{Float64,1}, SparseVector{Float64,Int64}) -> SparseMatrixCSC{Float64,Int64}
vcat(SparseVector{Float64,Int64}, Array{Float64,1}) -> SparseMatrixCSC{Float64,Int64}
vcat(SparseVector{Float64,Int64}, SparseVector{Float64,Int64}) -> SparseVector{Float64,Int64}
### matrix-matrix vcat type mapping ###
vcat(Array{Float64,2}, Array{Float64,2}) -> Array{Float64,2}
vcat(Array{Float64,2}, SparseMatrixCSC{Float64,Int64}) -> SparseMatrixCSC{Float64,Int64}
vcat(Array{Float64,2}, Diagonal{Float64}) -> SparseMatrixCSC{Float64,Int64}
@Sacha0
Sacha0 / log.txt
Created October 24, 2016 03:16
CIFailureLog_AVi686PR19083
[00:00:00] Build started
[00:00:00] git config --global core.autocrlf input
[00:00:00] git clone -q --depth=50 https://github.com/JuliaLang/julia.git C:\projects\julia
[00:00:06] git fetch -q origin +refs/pull/19083/merge:
[00:00:08] git checkout -qf FETCH_HEAD
[00:00:11] Restoring build cache
[00:00:12]
[00:00:13] Cache 'i686-4.9.2-release-win32-sjlj-rt_v4-rev3.7z' - Downloading (68,612,950 bytes)...1%
[00:00:13] Cache 'i686-4.9.2-release-win32-sjlj-rt_v4-rev3.7z' - Downloading (68,612,950 bytes)...10%
[00:00:14] Cache 'i686-4.9.2-release-win32-sjlj-rt_v4-rev3.7z' - Downloading (68,612,950 bytes)...20%
@Sacha0
Sacha0 / i686
Created January 10, 2017 05:11
travislogs_19925_9jan2017
travis_fold:start:worker_info
Worker information
hostname: ip-10-12-9-196:cda474ee-8aea-403d-b0f2-5b045a48d857
version: v2.5.0-8-g19ea9c2 https://github.com/travis-ci/worker/tree/19ea9c20425c78100500c7cc935892b47024922c
instance: b8d0595:travis:default
startup: 1.204977372s
travis_fold:end:worker_info
travis_fold:start:system_info
Build system information
Build language: cpp
@Sacha0
Sacha0 / onesinthewild.jl
Last active November 9, 2017 21:49
ones in the wild
# rewrites mostly preserve surrounding style.
# sometimes I've added whitespace for sanity.
# several of these would be better rewritten more extensively,
# but instead I've mostly just transliterated ones to something more appropriate.
# orig
p = poly([ones(1,4*k),2*ones(1,3*k),3*ones(1,2*k),4*ones(1,k)]);
# rewrite
p = poly([fill(1.,1,4k),fill(2.,1,3k),fill(3.,1,2k),fill(4.,1,k)]);
# summary