Module: gears.math

Various math related functions.

Math module for gears.

Static module functions

gears.math.subsets (set) -> () Return all subsets of a specific set.
gears.math.cycle (t, i) -> () Make i cycle.
gears.math.round (x) -> integer Round a number to an integer.
gears.math.sign (x) -> integer Return the sign of the number x return 1 if x is positive, -1 if negative and 0 if x is 0


Static module functions

🔗 gears.math.subsets (set) -> ()
Return all subsets of a specific set. This function, giving a set, will return all subset it. For example, if we consider a set with value { 10, 15, 34 }, it will return a table containing 2^n set: { }, { 10 }, { 15 }, { 34 }, { 10, 15 }, { 10, 34 }, etc.

Parameters:

Name Type(s) Description
set A set.

Returns:

    A table with all subset.
🔗 gears.math.cycle (t, i) -> ()
Make i cycle.

Parameters:

Name Type(s) Description
t A length. Must be greater than zero.
i An absolute index to fit into #t.

Returns:

    An integer in (1, t) or nil if t is less than or equal to zero.
🔗 gears.math.round (x) -> integer
Round a number to an integer.

Parameters:

Name Type(s) Description
x number

Returns:

    integer
🔗 gears.math.sign (x) -> integer
Return the sign of the number x return 1 if x is positive, -1 if negative and 0 if x is 0

Parameters:

Name Type(s) Description
x number

Returns:

    integer
generated by LDoc 1.5.0