Skip to content

Instantly share code, notes, and snippets.

View KlausC's full-sized avatar

Klaus Crusius KlausC

View GitHub Profile
@KlausC
KlausC / statistics.jl
Created April 14, 2024 10:50
statistics for accuracy and benchmarks of power function
"""
```julia
using BenchmarkTools
julia> nx = [randpower(maxex = 20) for _ in 1:10^6];
julia> D = stat_ulps(nx);
julia> overview(D)
1000000
@KlausC
KlausC / julia_syntax_where.md
Last active April 27, 2019 14:13
julia syntax of where clause and methods dispatch

Julia extension of where clause and dispatching

Idea is to enable dispatch of Julia methods depending not only on the type (including type parameters), but on special properties of argument types.

As we want to extend the method dispatching system, which is based on type hierarchies, the mentioned properties are expressed as function calls with the type as single argument. The return value of the function must be an abstract or concrete type by itself.

The syntax of the where clause is extended by allowing the type variable to be replaced by a function call to the variable. It may be restricted by upper - and lower bounds.

Syntax

@KlausC
KlausC / universalwrapper.md
Last active April 27, 2019 10:14
MatrixWrappers

Universal Matrix Wrappers

Motivation

In Julia there are some subtypes of AbstractMatrix, which are used as "lazy wrapper" objects for objects of type AbstractMatrix. These inlcude Transpose, Adjoint, Symmetric, Hermitian, UpperTriangular, LowerTriangular, UnitUpperTriangular, UnitLowerTriangular and maybe others. The purpose of those objects is primarily to avoid unnecessary moving or reorganizing element data of the underlying matrices and instead give a different view to the parent data. The use of the wrappers can improve performance, if there are specialized algorithms, which implicitly make use of the reorganized data, as is the case for the BLAS library or some methods for sparse matrices. It is possible to construct arbitrary nestings of such wrapped objects. Two nested wrapped matrices may be different in a strict sense - i.e. they have different types - while the mathematical meaning is identical. For example we have Transpose(UpperTriangular(A)) == LowerTriangular(Transpose(A)).