Skip to content

Instantly share code, notes, and snippets.


Klaus Crusius KlausC

View GitHub Profile
KlausC /
Last active Apr 27, 2019
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.



Universal Matrix Wrappers


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)).