Liking cljdoc? Tell your friends :D

sicmutils.generic

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]].
raw docstring

*clj/s

(*)
(* 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"
```
sourceraw docstring

+clj/s

(+)
(+ 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])
;;=> (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])
;;=> (up 3 5 7)
```
sourceraw docstring

-clj/s

(-)
(- 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])
;;=> (up -1 -1 -1)

(- [1 10])
;;=> (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])
;;=> (up -1 -1 -1)

(- [1 10])
;;=> (up -1 -10)
```
sourceraw docstring

/clj/s

(/)
(/ 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)
;;=> (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)
;;=> (up 1 2 3)
```
sourceraw docstring

absclj/smultimethod

(abs a)

generic abs

generic abs
sourceraw docstring

acosclj/smultimethod

(acos a)

generic acos

generic acos
sourceraw docstring

acoshclj/smultimethod

(acosh a)

generic acosh

generic acosh
sourceraw docstring

angleclj/smultimethod

(angle a)

generic angle

generic angle
sourceraw docstring

asinclj/smultimethod

(asin a)

generic asin

generic asin
sourceraw docstring

asinhclj/smultimethod

(asinh a)

generic asinh

generic asinh
sourceraw docstring

atanclj/smultimethod

(atan a)
(atan a b)

generic atan

generic atan
sourceraw docstring

atanhclj/smultimethod

(atanh a)

generic atanh

generic atanh
sourceraw docstring

ceilingclj/smultimethod

(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.
sourceraw docstring

conjugateclj/smultimethod

(conjugate a)

generic conjugate

generic conjugate
sourceraw docstring

cosclj/smultimethod

(cos a)

generic cos

generic cos
sourceraw docstring

coshclj/smultimethod

(cosh a)

generic cosh

generic cosh
sourceraw docstring

cotclj/smultimethod

(cot a)

generic cot

generic cot
sourceraw docstring

cross-productclj/smultimethod

(cross-product a b)

generic cross-product

generic cross-product
sourceraw docstring

cscclj/smultimethod

(csc a)

generic csc

generic csc
sourceraw docstring

cschclj/smultimethod

(csch a)

generic csch

generic csch
sourceraw docstring

cubeclj/smultimethod

(cube a)

generic cube

generic cube
sourceraw docstring

determinantclj/smultimethod

(determinant a)

generic determinant

generic determinant
sourceraw docstring

dimensionclj/smultimethod

(dimension a)

generic dimension

generic dimension
sourceraw docstring

divclj/smultimethod

(div a b)

generic div.

Returns the result of dividing a and b.

Equivalent to (* a (negate b)).

See / for a variadic version of div.

generic div.

Returns the result of dividing `a` and `b`.

  Equivalent to `(* a (negate b))`.

  See [[/]] for a variadic version of [[div]].
sourceraw docstring

divideclj/s

Alias for /.

Alias for [[/]].
sourceraw docstring

dot-productclj/smultimethod

(dot-product a b)

generic dot-product

generic dot-product
sourceraw docstring

exact-divideclj/smultimethod

(exact-divide a b)

generic exact-divide.

Similar to the binary case of /, but throws if (v/exact? <result>) returns false.

generic exact-divide.

Similar to the binary case of [[/]], but throws if `(v/exact? <result>)`
  returns false.
sourceraw docstring

expclj/smultimethod

(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.
sourceraw docstring

exp10clj/smultimethod

(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)`.
sourceraw docstring

exp2clj/smultimethod

(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)`.
sourceraw docstring

exptclj/smultimethod

(expt a b)

generic expt

generic expt
sourceraw docstring

factorialclj/s

(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).
sourceraw docstring

floorclj/smultimethod

(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.
sourceraw docstring

fractional-partclj/smultimethod

(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 (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 (fractional-part -0.4))
```
sourceraw docstring

gcdclj/smultimethod

(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`.
sourceraw docstring

imag-partclj/smultimethod

(imag-part a)

generic imag-part

generic imag-part
sourceraw docstring

inner-productclj/smultimethod

(inner-product a b)

generic inner-product

generic inner-product
sourceraw docstring

integer-partclj/smultimethod

(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.
sourceraw docstring

invertclj/smultimethod

(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)`.
sourceraw docstring

lcmclj/smultimethod

(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`.
sourceraw docstring

Lie-derivativeclj/smultimethod

(Lie-derivative a)

generic Lie-derivative

generic Lie-derivative
sourceraw docstring

logclj/smultimethod

(log a)

generic log.

Returns the natural logarithm of x.

generic log.

Returns the natural logarithm of `x`.
sourceraw docstring

log10clj/smultimethod

(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)$.
sourceraw docstring

log2clj/smultimethod

(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)$.
sourceraw docstring

magnitudeclj/smultimethod

(magnitude a)

generic magnitude

generic magnitude
sourceraw docstring

make-polarclj/smultimethod

(make-polar a b)

generic make-polar

generic make-polar
sourceraw docstring

make-rectangularclj/smultimethod

(make-rectangular a b)

generic make-rectangular

generic make-rectangular
sourceraw docstring

moduloclj/smultimethod

(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`.
sourceraw docstring

negateclj/smultimethod

(negate a)

generic negate.

Returns the negation of a.

Equivalent to (- (v/zero-like a) a).

generic negate.

Returns the negation of `a`.

  Equivalent to `(- (v/zero-like a) a)`.
sourceraw docstring

negative?clj/smultimethod

(negative? a)

generic negative?.

Returns true if the argument a is less than (v/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 `(v/zero-like a)`,
  false otherwise. The default implementation depends on a proper Comparable
  implementation on the type.`
sourceraw docstring

outer-productclj/smultimethod

(outer-product a b)

generic outer-product

generic outer-product
sourceraw docstring

partial-derivativeclj/smultimethod

(partial-derivative a b)

generic partial-derivative

generic partial-derivative
sourceraw docstring

quotientclj/smultimethod

(quotient a b)

generic quotient

generic quotient
sourceraw docstring

real-partclj/smultimethod

(real-part a)

generic real-part

generic real-part
sourceraw docstring

remainderclj/smultimethod

(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`.
sourceraw docstring

secclj/smultimethod

(sec a)

generic sec

generic sec
sourceraw docstring

sechclj/smultimethod

(sech a)

generic sech

generic sech
sourceraw docstring

simplifyclj/smultimethod

(simplify a)

generic simplify

generic simplify
sourceraw docstring

sinclj/smultimethod

(sin a)

generic sin

generic sin
sourceraw docstring

sinhclj/smultimethod

(sinh a)

generic sinh

generic sinh
sourceraw docstring

solve-linearclj/smultimethod

(solve-linear a b)

generic solve-linear.

For a given a and b, returns x such that a*x = b.

Seesolve-linear-right for a similar function that solves for a = x*b.

generic solve-linear.

For a given `a` and `b`, returns `x` such that `a*x = b`.

  See[[solve-linear-right]] for a similar function that solves for `a = x*b`.
sourceraw docstring

solve-linear-leftclj/s

(solve-linear-left a b)

Alias for solve-linear; present for compatibility with the original scmutils codebase.

NOTE: In scmutils, solve-linear-left and solve-linear act identically in all cases except matrices. solve-linear-left only accepted a column matrix (or up structure) in the b position, while solve-linear accepted either a column or row (up or down structure).

In SICMUtils, both functions accept either type.

Alias for [[solve-linear]]; present for compatibility with the original
`scmutils` codebase.

NOTE: In `scmutils`, `solve-linear-left` and `solve-linear` act identically in
all cases except matrices. `solve-linear-left` only accepted a column
matrix (or up structure) in the `b` position, while `solve-linear` accepted
either a column or row (up or down structure).

In SICMUtils, both functions accept either type.
sourceraw docstring

solve-linear-rightclj/smultimethod

(solve-linear-right a b)

generic solve-linear-right.

For a given a and b, returns x such that a = x*b.

Seesolve-linear for a similar function that solves for a*x = b.

generic solve-linear-right.

For a given `a` and `b`, returns `x` such that `a = x*b`.

  See[[solve-linear]] for a similar function that solves for `a*x = b`.
sourceraw docstring

sqrtclj/smultimethod

(sqrt a)

generic sqrt

generic sqrt
sourceraw docstring

squareclj/smultimethod

(square a)

generic square

generic square
sourceraw docstring

tanclj/smultimethod

(tan a)

generic tan

generic tan
sourceraw docstring

tanhclj/smultimethod

(tanh a)

generic tanh

generic tanh
sourceraw docstring

traceclj/smultimethod

(trace a)

generic trace

generic trace
sourceraw docstring

transposeclj/smultimethod

(transpose a)

generic transpose

generic transpose
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close