The home of most of the SICMUtils extensible generic operations. The bulk of
the others live in sicmutils.value
.
See the Generics
cljdocs
for a detailed discussion of how to use and extend the generic operations
defined in sicmutils.generic
and sicmutils.value
.
The home of most of the SICMUtils extensible generic operations. The bulk of the others live in [[sicmutils.value]]. See [the `Generics` cljdocs](https://cljdoc.org/d/sicmutils/sicmutils/CURRENT/doc/basics/generics) for a detailed discussion of how to use and extend the generic operations defined in [[sicmutils.generic]] and [[sicmutils.value]].
(*)
(* x)
(* x y)
(* x y & more)
Generic implementation of *
. Returns the product of all supplied
arguments. (*)
returns 1, the multiplicative identity.
When applied between numbers, acts like clojure.core/*
. Dispatch is open,
however, making it possible to 'multiply' types wherever the behavior is
mathematically sound.
For example:
(* 2 #sicm/complex "3 + 1i")
;;=> #sicm/complex "6 + 2i"
Generic implementation of `*`. Returns the product of all supplied arguments. `(*)` returns 1, the multiplicative identity. When applied between numbers, acts like `clojure.core/*`. Dispatch is open, however, making it possible to 'multiply' types wherever the behavior is mathematically sound. For example: ```clojure (* 2 #sicm/complex "3 + 1i") ;;=> #sicm/complex "6 + 2i" ```
(+)
(+ x)
(+ x y)
(+ x y & more)
Generic implementation of +
. Returns the sum of all supplied arguments. (+)
returns 0, the additive identity.
When applied between numbers, acts like clojure.core/+
. Dispatch is open,
however, making it possible to 'add' types wherever the behavior is
mathematically sound.
For example:
(+ [1 2 3] [2 3 4])
;;=> ([[structure/up]] 3 5 7)
Generic implementation of `+`. Returns the sum of all supplied arguments. `(+)` returns 0, the additive identity. When applied between numbers, acts like `clojure.core/+`. Dispatch is open, however, making it possible to 'add' types wherever the behavior is mathematically sound. For example: ```clojure (+ [1 2 3] [2 3 4]) ;;=> ([[structure/up]] 3 5 7) ```
(-)
(- x)
(- x y)
(- x y & more)
Generic implementation of -
.
If one argument is supplied, returns the negation of a
. Else returns the
difference of the first argument a
and the sum of all remaining
arguments. (-)
returns 0.
When applied between numbers, acts like clojure.core/-
. Dispatch is open,
however, making it possible to 'subtract' types wherever the behavior is
mathematically sound.
For example:
(- [1 2 3] [2 3 4])
;;=> ([[structure/up]] -1 -1 -1)
(- [1 10])
;;=> ([[structure/up]] -1 -10)
Generic implementation of `-`. If one argument is supplied, returns the negation of `a`. Else returns the difference of the first argument `a` and the sum of all remaining arguments. `(-)` returns 0. When applied between numbers, acts like `clojure.core/-`. Dispatch is open, however, making it possible to 'subtract' types wherever the behavior is mathematically sound. For example: ```clojure (- [1 2 3] [2 3 4]) ;;=> ([[structure/up]] -1 -1 -1) (- [1 10]) ;;=> ([[structure/up]] -1 -10) ```
(/)
(/ x)
(/ x y)
(/ x y & more)
Generic implementation of /
.
If one argument is supplied, returns the multiplicative inverse of a
. Else
returns the result of dividing first argument a
by the product of all
remaining arguments. (/)
returns 1, the multiplicative identity.
When applied between numbers, acts like clojure.core//
. Dispatch is open,
however, making it possible to 'divide' types wherever the behavior is
mathematically sound.
For example:
(/ [2 4 6] 2)
([[structure/up]] 1 2 3)
Generic implementation of `/`. If one argument is supplied, returns the multiplicative inverse of `a`. Else returns the result of dividing first argument `a` by the product of all remaining arguments. `(/)` returns 1, the multiplicative identity. When applied between numbers, acts like `clojure.core//`. Dispatch is open, however, making it possible to 'divide' types wherever the behavior is mathematically sound. For example: ```clojure (/ [2 4 6] 2) ([[structure/up]] 1 2 3) ```
(ceiling a)
generic ceiling.
Returns the result of rounding a
up to the next largest integer.
Extensions beyond real numbers may behave differently; see the Documentation site for more detail.
generic ceiling. Returns the result of rounding `a` up to the next largest integer. Extensions beyond real numbers may behave differently; see the [Documentation site](https://cljdoc.org/d/sicmutils/sicmutils/CURRENT/doc/basics/generics) for more detail.
(cross-product a b)
generic cross-product
generic cross-product
(determinant a)
generic determinant
generic determinant
(dot-product a b)
generic dot-product
generic dot-product
(exact-divide a b)
generic exact-divide.
Similar to the binary case of /
, but throws if the ([[value/exact?]] <result>)
returns false.
generic exact-divide. Similar to the binary case of [[/]], but throws if the `([[value/exact?]] <result>)` returns false.
(exp a)
generic exp.
Returns the base-e exponential of x
. Equivalent to (expt e x)
, given
some properly-defined e
symbol.
generic exp. Returns the base-e exponential of `x`. Equivalent to `(expt e x)`, given some properly-defined `e` symbol.
(exp10 a)
generic exp10.
Returns the base-10 exponential of x
. Equivalent to (expt 10 x)
.
generic exp10. Returns the base-10 exponential of `x`. Equivalent to `(expt 10 x)`.
(exp2 a)
generic exp2.
Returns the base-2 exponential of x
. Equivalent to (expt 2 x)
.
generic exp2. Returns the base-2 exponential of `x`. Equivalent to `(expt 2 x)`.
(factorial n)
Returns the factorial of n
, ie, the product of 1 to n
(inclusive).
Returns the factorial of `n`, ie, the product of 1 to `n` (inclusive).
(floor a)
generic floor.
Returns the largest integer less than or equal to a
.
Extensions beyond real numbers may behave differently; see the Documentation site for more detail.
generic floor. Returns the largest integer less than or equal to `a`. Extensions beyond real numbers may behave differently; see the [Documentation site](https://cljdoc.org/d/sicmutils/sicmutils/CURRENT/doc/basics/generics) for more detail.
(fractional-part a)
generic fractional-part.
Returns the fractional part of the given value, defined as x - ⌊x⌋
.
For positive numbers, this is identical to (- a ([[integer-part]] a))
. For
negative a
, because floor
truncates toward negative infinity, you might
be surprised to find that fractional-part
returns the distance between a
and the next-lowest integer:
(= 0.6 (g/fractional-part -0.4))
generic fractional-part. Returns the fractional part of the given value, defined as `x - ⌊x⌋`. For positive numbers, this is identical to `(- a ([[integer-part]] a))`. For negative `a`, because [[floor]] truncates toward negative infinity, you might be surprised to find that [[fractional-part]] returns the distance between `a` and the next-lowest integer: ```clojure (= 0.6 (g/fractional-part -0.4)) ```
(gcd a b)
generic gcd.
Returns the greatest common
divisor of the two
inputs a
and b
.
generic gcd. Returns the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor) of the two inputs `a` and `b`.
(inner-product a b)
generic inner-product
generic inner-product
(integer-part a)
generic integer-part.
Returns the integer part of a
by removing any fractional digits.
generic integer-part. Returns the integer part of `a` by removing any fractional digits.
(invert a)
generic invert.
Returns the multiplicative inverse of a
.
Equivalent to ([[/]] 1 a)
.
generic invert. Returns the multiplicative inverse of `a`. Equivalent to `([[/]] 1 a)`.
(lcm a b)
generic lcm.
Returns the least common
multiple of the two
inputs a
and b
.
generic lcm. Returns the [least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of the two inputs `a` and `b`.
(Lie-derivative a)
generic Lie-derivative
generic Lie-derivative
(log a)
generic log.
Returns the natural logarithm of x
.
generic log. Returns the natural logarithm of `x`.
(log10 a)
generic log10.
Returns the base-10 logarithm of x
, ie, $log_10(x)$.
generic log10. Returns the base-10 logarithm of `x`, ie, $log_10(x)$.
(log2 a)
generic log2.
Returns the base-2 logarithm of x
, ie, $log_2(x)$.
generic log2. Returns the base-2 logarithm of `x`, ie, $log_2(x)$.
(make-rectangular a b)
generic make-rectangular
generic make-rectangular
(modulo a b)
generic modulo.
Returns the result of the
mathematical Modulo
operation between a
and b
(using the Knuth definition listed).
The contract satisfied by modulo
is:
(= a (+ (* b ([[floor]] (/ a b)))
([[modulo]] a b)))
For numbers, this differs from the contract offered by remainder
because ([[floor]] (/ a b))
rounds toward negative infinity, while
the quotient
operation in the contract for remainder
rounds toward 0.
The result will be either 0
or of the same sign as the divisor b
.
generic modulo. Returns the result of the mathematical [Modulo](https://en.wikipedia.org/wiki/Modulo_operation) operation between `a` and `b` (using the Knuth definition listed). The contract satisfied by [[modulo]] is: ```clojure (= a (+ (* b ([[floor]] (/ a b))) ([[modulo]] a b))) ``` For numbers, this differs from the contract offered by [[remainder]] because `([[floor]] (/ a b))` rounds toward negative infinity, while the [[quotient]] operation in the contract for [[remainder]] rounds toward 0. The result will be either `0` or of the same sign as the divisor `b`.
(negate a)
generic negate.
Returns the negation of a
.
Equivalent to ([[-]] ([[value/zero-like]] a) a)
.
generic negate. Returns the negation of `a`. Equivalent to `([[-]] ([[value/zero-like]] a) a)`.
(negative? a)
generic negative?.
Returns true if the argument a
is less than ([[value/zero-like]] a)
,
false otherwise. The default implementation depends on a proper Comparable
implementation on the type.`
generic negative?. Returns true if the argument `a` is less than `([[value/zero-like]] a)`, false otherwise. The default implementation depends on a proper Comparable implementation on the type.`
(outer-product a b)
generic outer-product
generic outer-product
(partial-derivative a b)
generic partial-derivative
generic partial-derivative
(remainder a b)
generic remainder.
Returns the remainder of dividing the dividend a
by divisor b
.
The contract satisfied by remainder
is:
(= a (+ (* b ([[quotient]] a b))
([[remainder]] a b)))
For numbers, this differs from the contract offered by modulo
because quotient
rounds toward 0, while ([[floor]] (/ a b))
rounds toward
negative infinity.
The result will be either 0
or of the same sign as the dividend a
.
generic remainder. Returns the remainder of dividing the dividend `a` by divisor `b`. The contract satisfied by [[remainder]] is: ```clojure (= a (+ (* b ([[quotient]] a b)) ([[remainder]] a b))) ``` For numbers, this differs from the contract offered by [[modulo]] because [[quotient]] rounds toward 0, while `([[floor]] (/ a b))` rounds toward negative infinity. The result will be either `0` or of the same sign as the dividend `a`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close