Functions

StaticNumbers.staticFunction

static(X) is shorthand for StaticInteger{X}(), StaticReal{X}() or StaticNumber{X}(), depending on the type of X.

source

static(range) converts to a range where all aspects are Static.

source
StaticNumbers.unstaticFunction

unstatic(x) returns a non-static version of x. This function is rarely needed, as most operations on a static number (e.g. x+0) will yield a non-static result.

source
StaticNumbers.@generate_static_methodsMacro
@generate_static_methods numbers 1argfuns 2argfuns

This macro creates methods that return Static numbers when functions are called with only Static arguments.

The inputs should be a list of literal numbers that will be tested as inputs and outputs of all functions.

Optionally a fourth argument can give a list of numbers that will only be considered as results, but not as inputs.

Example:

@generate_static_methods (0, 1) (sin, cos) (+, -)

will create all the following method definitions:

sin(::StaticInteger{0}) = StaticInteger{0}()
cos(::StaticInteger{0}) = StaticInteger{1}()
+(::StaticInteger{0}, ::StaticInteger{0}) = StaticInteger{0}()
+(::StaticInteger{0}, ::StaticInteger{1}) = StaticInteger{1}()
+(::StaticInteger{1}, ::StaticInteger{0}) = StaticInteger{1}()
-(::StaticInteger{0}, ::StaticInteger{0}) = StaticInteger{0}()
-(::StaticInteger{1}, ::StaticInteger{0}) = StaticInteger{0}()
-(::StaticInteger{1}, ::StaticInteger{1}) = StaticInteger{1}()

(Note: The macro will run in the local scope. Functions from Base must be imported before they can be extended.)

source