Skip to content

Instantly share code, notes, and snippets.

View andreasnoack's full-sized avatar

Andreas Noack andreasnoack

View GitHub Profile
@andreasnoack
andreasnoack / gist:9f3f63d7f1d00a07359b
Created October 21, 2014 14:54
A new RNG for Julia
module XORShift
import Base.rand
type XORShiftStar1024 <: AbstractRNG
p::Int
state::Vector{Uint64}
end
XORShiftStar() = XORShiftStar1024(1, rand(Uint64, 16))
@andreasnoack
andreasnoack / GF2type.jl
Created February 21, 2014 11:05
GF(2) Gaussian elimination
import Base: &,|,<,+,-,*,/,abs,and_int,box,convert,div,or_int,rem,promote_rule,show,udiv_int,ult_int,unbox,urem_int,xor_int
bitstype 8 GF2 <: Unsigned
convert(::Type{GF2}, x::GF2) = x
convert(::Type{GF2}, x::Uint8) = box(GF2,unbox(Uint8,x))
convert(::Type{GF2}, x::Number) = convert(GF2,uint8(x))
convert(::Type{Int8}, x::GF2) = box(Int8,unbox(GF2,x))
convert(::Type{Uint8}, x::GF2) = box(Uint8,unbox(GF2,x))
convert(::Type{Uint64}, x::GF2) = uint64(uint8(x))
gf2(x::Number) = convert(GF2,x)
promote_rule(::Type{GF2},::Type{Uint64}) = Uint64