Skip to content

Instantly share code, notes, and snippets.

View kalmarek's full-sized avatar

Marek Kaluba kalmarek

View GitHub Profile
@kalmarek
kalmarek / ma_arb.jl
Last active November 15, 2023 14:45
MA.add_mul!! with Arbs
using Revise
using Arblib
import MutableArithmetics
const MA = MutableArithmetics
using LinearAlgebra
MA.mutability(::Type{Arb}) = MA.IsMutable()
MA.mutable_copy(x::Arb) = set!(Arb(prec=precision(x)), x)
@kalmarek
kalmarek / fast_paced_gh.md
Created November 12, 2023 15:28
Documenter.jl fast paced github setting up guide

Fast paced github setting up guide

Situation

You have your own repository on github.com/username/MyPackage.jl with a julia package and would like to write and deploy documentation for it using Documenter.jl.

Step 0 - Prerequisites

Install DocumenterTools.jl:

@kalmarek
kalmarek / fast_paced_gh.md
Created November 12, 2023 15:25
Documenter.jl fast paced github setting up guide

Fast paced github setting up guide

Situation

You have your own repository on github.com/username/MyPackage.jl with a julia package and would like to write and deploy documentation for it using Documenter.jl.

Step 0 - Prerequisites

Install DocumenterTools.jl:

@kalmarek
kalmarek / backtrack.jl
Last active October 14, 2022 16:32
Simple backtracking search over iterators in julia
struct BacktrackSearch{V<:AbstractVector, VI<:AbstractVector, VS<:AbstractVector, O, A}
nodes::V
iterators::VI
states::VS
oracle_descend::O
node_accept::A
end
"""
BacktrackSearch(iterators; oracle_descend, node_accept)
import Arblib: arb_struct, arf_struct, @libarb, ArbLike
struct arf_interval
lo::arf_struct
hi::arf_struct
# function arf_interval()
# v = new()
# init!(v)
# finalizer(clear!, v)
module Monoids
using KnuthBendix
import KnuthBendix: Alphabet, AbstractWord, LenLex, alphabet
export Alphabet, FreeMonoid, gens
# this should go to KnuthBendix.jl
Base.convert(::Type{Word{I}}, v::AbstractVector{<:Integer}) where I = Word{I}(v)
@kalmarek
kalmarek / order.jl
Last active March 21, 2021 10:20
Order implementation
struct Order{I} <: Integer
val::I
Order{I}(n::Integer) where I<:Integer = (n > 0 ? new{I}(n) : throw(DomainError(0, "invalid order")))
Order{I}(::Val{Inf}) where I<:Integer = new{I}(0)
end
Order(n::I) where I<:Integer = Order{I}(n)
Order(v::Val{Inf}) = Order{Int}(v)
@kalmarek
kalmarek / W_statistic.jl
Last active January 22, 2021 08:56
Shapiro-Wilk coefficients, computed exactly (up to `eps(Float64)`) using Arb with 512 bits of precision and itegration radius 32.0
using Statistics
using Random
using LinearAlgebra
function Wstatistic(X, sw_coeffs)
@boundscheck @assert length(X) == length(sw_coeffs)
@assert issorted(X)
@assert last(X) - first(X) > length(X) * eps(eltype(X)) "Data seems to be constant!"
µ = mean(X)
using Groups
using KnuthBendix
import Groups: ϱ, λ
KnuthBendix.Word(A::Alphabet{T}, v::AbstractVector{T}) where {T} = Word([A[s] for s in v])
invof(A::Alphabet{T}, a::T) where {T} = A[-A[a]]
comm(A::Alphabet, x::S, y::S) where {S<:Groups.GSymbol} =
Word([A[x], A[y], A[invof(A, x)], A[invof(A, y)]])
# using Pkg
# Pkg.activate(joinpath(@__DIR__, ".."))
using PropertyT
using PropertyT.GroupRings
using PropertyT.Groups
using PropertyT.AbstractAlgebra
using PropertyT.JuMP
using PropertyT.IntervalArithmetic