Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.71 KB

README.md

File metadata and controls

54 lines (37 loc) · 1.71 KB

UnitfulCorrelations

Build Status Coverage

A simple macro for working with empirical correlations and Unitful.

Installation

UnitfulCorrelationsjl can be installed using Julia's built-in package manager. In a Julia session, enter the package manager mode by hitting ], then run the command

pkg> add https://github.com/aefarrell/UnitfulCorrelations.jl

Examples

Suppose you have an empirical correlation $ f(x) = 0.92 x^{0.2} $, where it is given that $x$ is in meters and $f$ is in seconds. You could figure out the units that the constants must have to make everything work out, or write a function that uses ustrip() to manage units, but that can get tedious if there are a lot of these.

The macro @ucorrel does this for you, adding another method for the case where the function is called with units. The arguments are: function (or function block), input units, output units.

f(x) = 0.92*x^0.2
@ucorrel f u"m" u"s"

# f(2) == 1.0568024865972723
# f(2 u"m") == 1.0568024865972723 u"s"

this can also be done with a function block

@ucorrel function f(x)
    return 0.92*x^0.2
end u"m" u"s"

# f(2) == 1.0568024865972723
# f(2 u"m") == 1.0568024865972723 u"s"

So far it only supports one dimensional correlations, because I have basically just copied over a macro that I use frequently and have not added anything to its funtionality.