Skip to content

Instantly share code, notes, and snippets.

@AndyGreenwell
AndyGreenwell / groupslices_update.jl
Created May 11, 2016 02:25
Update to groupslices
@generated function groupslices{T,N}(A::AbstractArray{T,N}, dim::Int)
quote
if !(1 <= dim <= $N)
ArgumentError("Input argument dim must be 1 <= dim <= $N, but is currently $dim")
end
hashes = zeros(UInt, size(A, dim))
# Compute hash for each row
k = 0
@nloops $N i A d->(if d == dim; k = i_d; end) begin
@AndyGreenwell
AndyGreenwell / test_failure_javacall_32bit_windows.txt
Created April 26, 2016 22:22
Pkg.test("JavaCall") error on 32-bit Windows
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.5 (2016-03-18 00:58 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | i686-w64-mingw32
julia> Pkg.build("JavaCall")
@AndyGreenwell
AndyGreenwell / uniqueslices_possibilities2.jl
Created December 4, 2015 18:47
Proposal 2 for alternative uniqueslices function signatures (but with fake names)
@generated function foo{T,N}(A::AbstractArray{T,N}, dim::Int)
quote
1 <= dim <= $N || return copy(A)
hashes = zeros(UInt, size(A, dim))
# Compute hash for each row
k = 0
@nloops $N i A d->(if d == dim; k = i_d; end) begin
@inbounds hashes[k] = hash(hashes[k], hash((@nref $N A i)))
end
@AndyGreenwell
AndyGreenwell / uniqueslices_possibilities1.jl
Last active December 4, 2015 18:47
Proposal 1 for alternative uniqueslices function signatures (but with fake names)
@generated function foo{T,N}(A::AbstractArray{T,N}, dim::Int)
quote
1 <= dim <= $N || return copy(A)
hashes = zeros(UInt, size(A, dim))
# Compute hash for each row
k = 0
@nloops $N i A d->(if d == dim; k = i_d; end) begin
@inbounds hashes[k] = hash(hashes[k], hash((@nref $N A i)))
end
@AndyGreenwell
AndyGreenwell / OptimTest.jl
Last active August 29, 2015 14:19
Test case for triggering "ERROR: UndefVarError: Error not defined" in secant2! of hz_linesearch.jl
module OptimTest
using Optim, Hadamard
function symcond(n,κ)
Q = hadamard(n)
D = diagm(exp(linspace(0,-log(κ),n)));
Q*D*Q'/n
end
A = symcond(12,1e14)