Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#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]
@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 <jiahao@mit.edu>, 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
@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 / 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
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)]))
"""
estimate_coeffs
August, 2015
Anna C. Gilbert
input: xs = samples of signal
Λ = list of (freq,coeff) pairs in current approx
Ω = list of (freq,coeff) pairs found in this iteration
k = length of short filter
@jiahao
jiahao / savitzkygolay.jl
Last active May 12, 2024 06:13
An implementation of the Savitzky-Golay filter using generated functions. Accompanies https://medium.com/@acidflask/smoothing-data-with-julia-s-generated-functions-c80e240e05f3
"""
Savitzky-Golay filter of window half-width M and degree N
M is the number of points before and after to interpolate, i.e. the full width
of the window is 2M+1
"""
immutable SavitzkyGolayFilter{M,N} end
@generated function Base.call{M,N,T}(::Type{SavitzkyGolayFilter{M,N}},
data::AbstractVector{T})
@jiahao
jiahao / julia.jl
Created November 24, 2015 02:58
Rank calculus for JuliaLang/julia#4774
include("rankstability.jl")
info("Julia semantics")
axiomsused = Dict()
@axiom matmul Mat * Mat --> Mat
@axiom mattrans transpose(Mat) --> Mat
@axiom matdiv Mat / Mat --> Mat
@axiom matvec Mat * Vec --> Vec