FastUnitfulOperations

FastUnitfulOperations provides fast methods for dealing with unitful arrays, such as multiplication and sorting.

Installation

Note that this package usually does not have to be directly installed by the user, instead install any of the implementing packages.

This package is only available through the local registry CosmoSimsRegistry, for which access first needs to be granted. It is recommended that an ssh key pair is created with the following command (which can be saved as id_rsa_gitlab, for example):

ssh-keygen -t rsa -b 4096 -m PEM

For the package manager to pick up on the ssh key, either ssh-agent has to be used, or the following two environment variables should be set (e.g., by setting them in the .bashrc file with export in front of each line):

SSH_KEY_PATH=~/.ssh/id_rsa_gitlab
SSH_PUB_KEY_PATH=~/.ssh/id_rsa_gitlab.pub

The package registry can be loaded from the Julia REPL with the Julia package manager:

using Pkg
pkg"registry add https://gitlab.com/juliacosmosims/CosmoSimsRegistry"

This only needs to be done once per Julia installation.

The latest version of the package is available for Julia 1.7 and newer versions and can be installed with:

using Pkg
Pkg.add("FastUnitfulOperations")

Documentation

FastUnitfulOperations.uproduct!Method
uproduct!(c::AbstractArray, a::AbstractArray{T1}, b::AbstractArray{T2}) where {T1 and/or T2 <:Quantity}

Fast in-place matrix multiplication for Unitful arrays.

This method reinterprets the unitful arrays as arrays with the number's type to make use of optimized matrix multiplication for integers or floats. The method will throw an error if the array contains Unitful elements that do not have a fixed value or unit type.

source
FastUnitfulOperations.uproductMethod
uproduct(a::AbstractArray{T1}, b::AbstractArray{T2}) where {T1 and/or T2 <:Quantity}
*ᵘ(a::AbstractArray{T1}, b::AbstractArray{T2}) where {T1 and/or T2 <:Quantity}

Fast matrix multiplication for Unitful arrays.

This method reinterprets the unitful arrays as arrays with the number's type to make use of optimized matrix multiplication for integers or floats. The method will throw an error if the array contains Unitful elements that do not have a fixed value or unit type.

Type *\^u followed by the tab key to input the operator *ᵘ.

source
FastUnitfulOperations.usort!Method
usort!(a::AbstractArray{T}; kwargs...) where {T<:Quantity}
usort!(a; kwargs...)

Sort a unitful array in-place as a reinterpreted array according to the number's type.

Calls Base.sort! on the reinterpreted array. This enables the use of sorting algorithms that only work for integers or floats (e.g. RadixSort from SortingAlgorithms.

The method falls back Base.sort! for other array types.

source
FastUnitfulOperations.usortMethod
usort(a::AbstractArray{T}; kwargs...) where {T<:Quantity}
usort(a; kwargs...)

Sort a unitful array as a reinterpreted array according to the number's type.

Calls Base.sort on the reinterpreted array. This enables the use of sorting algorithms that only work for integers or floats (e.g. RadixSort from SortingAlgorithms.

The method falls back Base.sort for other array types.

source
FastUnitfulOperations.usortperm!Method
usortperm!(ix, a::AbstractArray{T}; kwargs...) where {T<:Quantity}
usortperm!(ix, a; kwargs...)

Return the permutation vector in the preallocated vector ix to sort a unitful array as a reinterpreted array according to the number's type.

Calls Base.sortperm! on the reinterpreted array. This enables the use of sorting algorithms that only work for integers or floats (e.g. RadixSort from SortingAlgorithms.

The method falls back Base.sortperm! for other array types.

source
FastUnitfulOperations.usortpermMethod
usortperm(a::AbstractArray{T}; kwargs...) where {T<:Quantity}
usortperm(a; kwargs...)

Return the permutation vector to sort a unitful array as a reinterpreted array according to the number's type.

Calls Base.sortperm on the reinterpreted array. This enables the use of sorting algorithms that only work for integers or floats (e.g. RadixSort from SortingAlgorithms.

The method falls back Base.sortperm for other array types.

source