Skip to content

Instantly share code, notes, and snippets.

@ggggggggg
ggggggggg / list.md
Last active December 24, 2015 03:09
Links to iJulia example notebooks
@ggggggggg
ggggggggg / bool.jl
Created October 2, 2013 21:22
Making a list of names while assigning parts of an array
boollist = String[]
bool = ones(10,10)
macro newbool(name, value)
push!(boollist, repr(name)[2:end])
bool[length(boollist),:] = eval(value)
end
@newbool shoes rand(10)
@ggggggggg
ggggggggg / output.txt
Last active August 19, 2017 02:26
Work in progress towards robust complex division algorithm in Julia
The archive paper provides 10 example hard complex divions with answers. It also provides an algorith for measuring the accuracy of the result in "bits", which I have implemented. The robust cdiv algorithm is said to get 53 bits for all but #8 on the hard problems, where it gets 52 bits. I reproduce all of the results (also the default julia / reproduces results for smith's algorithm), except I get 0 bits on #5. I've tracked this down to the division of b/c returning zero inside robust_cdiv2, after r is also zero. But it's not clear how to fix it.
cdiv #1 ,53 bits accurate, 1.1125369292536007e-308 - 1.1125369292536007e-308im
cdiv #2 ,53 bits accurate, 8.98846567431158e307 + 0.0im
cdiv #3 ,53 bits accurate, 1.4334366349937947e104 - 3.645561009778199e-304im
cdiv #4 ,53 bits accurate, 8.98846567431158e307 + 0.0im
cdiv #5 ,0 bits accurate, 3.757668132438133e109 - 2.0e-323im
cdiv #6 ,53 bits accurate, 2.0e-323 + 1.048576e6im
cdiv #7 ,53 bits accurate, 3.8981256045591133e289 + 8.174961907852354e295im
v = dot(a[j:j+length(filter)-1], filter)
elapsed time: 1.305102964 seconds (640420192 bytes allocated)
v = Base.dot(sub(a,j:j+length(filter)-1), filter)
elapsed time: 10.830825758 seconds (2561056544 bytes allocated)
v = Base.dot(unsafe_view(a,j:j+length(filter)-1), filter)
elapsed time: 0.171855427 seconds (420640 bytes allocated)
v = NumericExtensions.dot(unsafe_view(a,j:j+length(filter)-1), filter)
elapsed time: 0.165605407 seconds (420640 bytes allocated)
v = -a[j]-a[j+1]+a[j+2]+a[j+3]
elapsed time: 0.050317084 seconds (420208 bytes allocated)
@ggggggggg
ggggggggg / bench_cdiv.jl
Last active December 31, 2015 21:29
robust complex division benchmark
function bench_smith(n,d)
for i = 1:length(n)
smith_cdiv(n[i], d[i])
end
end
function bench_robust(n,d)
for i = 1:length(n)
robust_cdiv(n[i], d[i])
end
# implement WirelessKeyboard as K
immutable K
f::Int
s::Int
end
# implement InterferesWith as <
>(k::K,K::K)=k.f==K.f
#prepare randomized array
k = [K(f,(j-1)*3+f) for j=1:12,f=1:3]
k9 = [K(f,(j-1)*3+f) for j=1:3,f=1:3] # smaller testing array
@ggggggggg
ggggggggg / client output.py
Created March 7, 2014 22:18
frame bit error causing client crash logs
dfbSetSettlingTime to settling time = 29, number of samples = 1
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8, 0))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/pcuser/trunk/python/autotune/autoTune.py in <module>()
837 a.logSquidTESStatus()
@ggggggggg
ggggggggg / submit.md
Created August 3, 2014 14:51
Possible Pkg.submit() info

Pkg has noticed that your local git repository is not ready to create a pull request.

Best practice is to create a feature branch before you make any changes.

git checkout master
git checkout -b yourfeaturebranch

Then make your changes, including adding relevant test cases in to test/runtests.jl, and ensure the tests all pass. Then commit our changes before running Pkg.submit("PackageName") again.

git add .
import Base: isempty, copy, eltype, sizehint, push!, union!, pop!, delete!, ==, <, <=, length, start, next, done,
setdiff, symdiff, symdiff!, setdiff!, show, first, last, intersect, intersect!, symdiff, symdiff!
using Base.Test
type IntSetBitVector
b::BitVector # n is in IntSet if s[n+1]==true
fill1s::Bool
IntSetBitVector() = new(falses(256), false)
end
IntSetBitVector(itr) = (s=IntSetBitVector(); for a in itr; push!(s,a); end; s)
@ggggggggg
ggggggggg / bitarray_test.py
Created September 30, 2014 23:08
faster bit transitions
import bitarray
import time
import numpy as np
a = np.arange(100000, dtype=np.uint64)
def transitions(a):
b = bitarray.bitarray()
b.frombytes(a.tostring())
c=b.itersearch(bitarray.bitarray("01"))
return [d for d in c]