Skip to content

Instantly share code, notes, and snippets.

@jiahao
jiahao / typerecurse.jl
Last active October 11, 2015 00:29
Ref: JuliaLang/julia#13503
function normtypes(S) #For the first post, comparing vector outputs with naive definitions
try
R0 = typeof(abs(one(S))^0+abs(one(S))^0)
R1 = typeof(abs(one(S))+abs(one(S)))
Rp = typeof(sqrt(abs(one(S))^2+abs(one(S))^2))
Ri = typeof(maximum(abs(one(S))))
Ri2 = typeof(abs(one(S)))
R0i = typeof(norm([one(S)], 0))
R1i = typeof(norm([one(S)], 1))
Rpi = typeof(norm([one(S)]))
@jiahao
jiahao / events.json
Created September 5, 2015 17:16
JSON from GitHub API query, https://api.github.com/repos/JuliaLang/julia/events, 2015-09-05T13:16:07
[{"id":"3121457012","type":"IssueCommentEvent","actor":{"id":11798751,"login":"ScottPJones","gravatar_id":"","url":"https://api.github.com/users/ScottPJones","avatar_url":"https://avatars.gitubusercontent.com/u/11798751?"},"repo":{"id":1644196,"name":"JuliaLang/julia","url":"https://api.github.com/repos/JuliaLang/julia"},"payload":{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/12835","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/12835/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/12835/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/12835/events","html_url":"https://github.com/JuliaLang/julia/pull/12835","id":103615789,"number":12835,"title":"let's release this thing !","user":{"login":"carnaval","id":5307791,"avatar_url":"https://avatars.githubusercontent.com/u/5307791?v=3","gravatar_id":"","url":"https://api.github.com/users/carnaval","html_url":"https://github.com/carnaval","follow
@jiahao
jiahao / 12899.jl
Last active September 1, 2015 04:09
This code triggers a weird bug on OSX https://github.com/JuliaLang/julia/issues/12899
type BrokenArrowBidiagonal{T} <: AbstractMatrix{T}
dv::Vector{T}
av::Vector{T}
ev::Vector{T}
end
Base.size(B::BrokenArrowBidiagonal) = (n=length(B.dv); (n, n))
function Base.size(B::BrokenArrowBidiagonal, n::Int)
if n==1 || n==2
return length(B.dv)
else
@jiahao
jiahao / tsqr.jl
Created August 4, 2015 05:50
Tall and skinny QR in Julia
#################################################################
# A simple implementation of TSQR (Tall and Skinny QR) in Julia #
# Jiahao Chen <[email protected]>, 2015-08-03 #
#################################################################
#
# TSQR is a communication-avoiding QR algorithm designed for
# distributed computation on tall, skinny matrices, which are
# typical of data matrices in Big Data applications.
#
# The primary reference is
#function axpy!{T}(a::T, b::StridedVector{T}, c::StridedVector{T})
# @simd for i=1:size(b, 1)
# c[i] += a*b[i]
# end
#end
mgs(A)=mgs!(copy(A))
function mgs!(Q) #Does not store R
m, n = size(Q)
Qc= [slice(Q,:,k) for k=1:n]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiahao
jiahao / githubworkflow.svg
Last active September 2, 2019 02:15
Julia developers' basic Github workflow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiahao
jiahao / .gitignore
Last active May 13, 2018 18:46
Julia Package Digest: automatic weekly summarizer of what's new in the Julia package ecosystem
.ipynb_checkpoints
*.ipynb
@jiahao
jiahao / doublelength.jl
Last active August 29, 2015 14:05
An implementation of doublelength floating point arithmetic as described in Dekker, 1971. http://link.springer.com/article/10.1007%2FBF01397083 (See also https://github.com/jiahao/DoublelengthFloat.jl)
import Base: +, -, ⋅, *, /, √, convert
export DoublelengthFloat
immutable DoublelengthFloat{T<:FloatingPoint} <: FloatingPoint
head :: T
tail :: T
end
DoublelengthFloat(x::FloatingPoint) = DoublelengthFloat(x, zero(x))
convert{T<:FloatingPoint}(::Type{DoublelengthFloat{T}}, x::T) = DoublelengthFloat(x)