This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Base: start, next, done | |
using BenchmarkTools | |
mutable struct RowJacobi{matT,vecT} | |
A::matT | |
x::vecT | |
next::vecT | |
b::vecT | |
maxiter::Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
import Base.BLAS: BlasInt, @blasfunc, liblapack | |
# subroutine dhseqr ( | |
# character JOB, | |
# character COMPZ, | |
# integer N, | |
# integer ILO, | |
# integer IHI, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
import Base: getindex | |
@inline function getindex(v::UnitRange{Int32}, i::Integer) | |
first(v) + Core.Intrinsics.trunc_int(Int32, i) - one(Int32) | |
end | |
function copy_via_broadcast!(x::AbstractVector{Ti}, r::UnitRange{Ti}) where {Ti} | |
x .= r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Base: start, next, done | |
using Base: BitInteger | |
using BenchmarkTools | |
struct OpenRange{T} | |
start::T | |
stop::T | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With bounds check Using @inbounds | |
Range type Index type Current New x faster Current New x faster | |
StepRange{Bool,Bool} Int8 93.605 μs 46.465 μs 2.0 83.849 μs 29.769 μs 2.8 | |
StepRange{Bool,Bool} UInt8 92.478 μs 42.743 μs 2.2 81.760 μs 29.775 μs 2.7 | |
StepRange{Bool,Bool} Int32 91.492 μs 45.854 μs 2.0 83.108 μs 29.780 μs 2.8 | |
StepRange{Bool,Bool} UInt32 89.812 μs 41.530 μs 2.2 82.168 μs 26.783 μs 3.1 | |
StepRange{Bool,Bool} Int64 92.273 μs 45.849 μs 2.0 78.521 μs 29.781 μs 2.6 | |
StepRange{Bool,Bool} UInt64 86.641 μs 44.617 μs 1.9 74.546 μs 29.793 μs 2.5 | |
StepRange{Int8,Int8} Int8 24.084 μs 21.805 μs 1.1 11.753 μs 1.444 μs 8.1 | |
StepRange{Int8,Int8} UInt8 24.099 μs 28.102 μs 0.9 11.755 μs 1.444 μs 8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> a, b = bench(100_000, Float64, Int64) | |
(Trial(704.422 μs), Trial(1.505 ms)) # Julia 0.6 | |
(Trial(1.354 ms), Trial(735.759 μs)) # Julia 0.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ZipStuff | |
import Base: iterate | |
using Test, Base.Iterators | |
abstract type AbstractZip end | |
struct ZipBase{H} <: AbstractZip | |
head::H | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Zipperino | |
import Base: iterate, tail, @nexprs, @ntuple | |
using Test, Base.Iterators | |
struct LinearZip{N,T} | |
t::T | |
end | |
zip(a...) = LinearZip{length(a),typeof(a)}(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Base.LinAlg: givensAlgorithm | |
import Base: convert | |
struct Householder{T} | |
u::T | |
end | |
""" | |
Returns a reflector s.t. Q * x = norm(x) * e1. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using LinearAlgebra | |
using Test | |
function generate_real_H_with_imaginary_eigs(n, T::Type = Float64) | |
while true | |
H = triu(rand(T, n + 1, n), -1) | |
λs = sort!(eigvals(view(H, 1 : n, 1 : n)), by = abs) | |
for i = 1 : n | |
μ = λs[i] |