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
julia> code_native(Tuple{Vector{Int}}) do v | |
sum(v; init=0) | |
end | |
.text | |
.file "#12" | |
.globl "julia_#12_1605" # -- Begin function julia_#12_1605 | |
.p2align 4, 0x90 | |
.type "julia_#12_1605",@function | |
"julia_#12_1605": # @"julia_#12_1605" | |
; ┌ @ REPL[10]:2 within `#12` |
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
julia> code_native(Tuple{Vector{Int}}) do v | |
sum(v; init=0) | |
end | |
.text | |
.file "#58" | |
.globl "julia_#58_2730" # -- Begin function julia_#58_2730 | |
.p2align 4, 0x90 | |
.type "julia_#58_2730",@function | |
"julia_#58_2730": # @"julia_#58_2730" | |
; ┌ @ REPL[24]:2 within `#58` |
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 LoopVectorization | |
using Bumper | |
using StrideArraysCore | |
using StaticTools | |
set_default_buffer_size!(1000) | |
@inline function sumArray_alloc(N) | |
smallarray = Array{Float64}(undef,N) | |
@turbo for i ∈ 1:N |
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 StaticArrays, Plots, Dictionaries | |
struct PSL2{T <: Real} | |
a::T | |
b::T | |
c::T | |
d::T | |
function PSL2(a::T,b::T,c::T,d::T) where {T} | |
(a*d - b*c ≈ 1) || error("Bad PSL₂($T) parameters, must have ad - bc = 1, got $((;a, b, c, d))") | |
a >= 0 ? new{T}(a,b,c,d) : new{T}(-a,-b,-c,-d) |
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 SUFib | |
using SymbolicUtils | |
using SymbolicUtils.Rewriters | |
@syms fib(x::Int)::Int | |
const rset = [ | |
@rule fib(0) => 0 | |
@rule fib(1) => 1 | |
@rule fib(~n) => fib(~n - 1) + fib(~n - 2) |
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
#+BEGIN_SRC jupyter-julia | |
struct ArrayString{Store <: AbstractVector{<:AbstractChar}} <: AbstractString | |
chars::Store | |
end | |
ArrayString(str::String) = ArrayString(collect(str)) | |
ArrayString(T, str::String) = ArrayString(T(collect(str))) | |
Base.String(s::ArrayString) = String(s.chars) |
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
#+BEGIN_SRC jupyter-julia | |
using CUDA | |
struct StaticString{N} <: AbstractString | |
chars::NTuple{N, Char} | |
end | |
macro s_str(s) | |
chars = tuple(collect(s)...) | |
N = length(chars) | |
esc(:(StaticString{$N}($chars))) | |
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
#+BEGIN_SRC jupyter-julia | |
using CUDA | |
struct StaticString{N} <: AbstractString | |
chars::NTuple{N, Char} | |
end | |
macro s_str(s) | |
chars = tuple(collect(s)...) | |
N = length(chars) | |
esc(:(StaticString{$N}($chars))) | |
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
#+BEGIN_SRC julia | |
const ketpat = r"\|.*?\>" | |
ketrep(str) = "Ket("*(match(r"(?<=\|).*?(?=>)", str).match)*")" | |
const brapat = r"\<.*?\|" | |
brarep(str) = "Bra("*(match(r"(?<=<).*?(?=\|)", str).match)*")" | |
function rep_braket(str) | |
replace(replace(str, brapat => brarep), ketpat => ketrep) | |
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
#+BEGIN_SRC jupyter-julia | |
using Interpolations | |
xs = range(-10, 10, length=50) # 50 evenly spaced points from -5 to 5 | |
# model function, some Gaussian | |
f(x; A=1, σ=2, b=0) = A * exp(-x^2/2σ) + b | |
ys = f.(xs) | |
method = BSpline(Cubic(Line(OnGrid()))) #interpolation method | |
f_itp = scale(interpolate(ys, method), xs) # interpolation function |
NewerOlder