{{ message }}

Instantly share code, notes, and snippets.

# Denis Telnovdenius

Created Oct 29, 2017
Application of Householder reflector from right
View reflectorApplyRight!.jl
 # apply reflector from right # derived from base/linalg/generic.jl @inline function reflectorApplyRight!(x::AbstractVector, τ::Number, A::AbstractMatrix) m, n = size(A) if length(x) != n throw(DimensionMismatch("reflector has length \$(length(x)), which must match the first dimension of matrix A, \$n")) end @inbounds begin for i = 1:m # note: ommited x[1] == 1
Created Oct 29, 2017
QR decomposition by Givens rotations
View qr-givens.jl
 """ QR decomposition by givens rotations of matrix without pivoting. ```math A = Q R ``` Thin (reduced) method will produce `Q` and `R` in truncated form, in opposite case `thin=false` Q is full, but R is still reduced, see [`qr`](@ref). """
Created Oct 30, 2017
QR benchmark
View perf-qr.jl
 using StaticArrays using BenchmarkTools, Compat a = m = 0 for K = 1:18 a = rand(SMatrix{K,K,Float64,K*K}) m = Matrix(a) print("K=\$K\n") @time qr(a) @btime qr(\$a)
Last active Oct 30, 2017
QR benchmark results
View perf-qr.jl.txt
 K=1 0.403818 seconds (113.14 k allocations: 5.859 MiB) 7.123 ns (0 allocations: 0 bytes) 775.527 ns (21 allocations: 1.13 KiB) K=2 0.021828 seconds (19.79 k allocations: 1019.997 KiB) 12.328 ns (0 allocations: 0 bytes) 1.474 μs (21 allocations: 1.22 KiB) K=3 0.036278 seconds (38.94 k allocations: 1.880 MiB)
Created Nov 2, 2017
test evaluating default values parameters in `@generated` functions
View test-generated.jl
 const U = Union{Type{Val{true}}, Type{Val{false}}} f1(p::U = Val{false}) = p isa Type{Val{true}} f2(p::U = Val{false}) = p isa Val{true} # false f3(p::U = Val{false}) = p <: Type{Val{true}} # false f4(p::U = Val{false}) = p <: Val{true} f5(p::U = Val{false}) = p === Type{Val{true}} # false f6(p::U = Val{false}) = p === Val{true} f7(p::U = Val{false}) = p == Type{Val{true}} # false
You can’t perform that action at this time.