On this page:
7.1 Extended operators
+
d+
-
d-
*
d*
/
d/
expt
d-expt
exp
d-exp
log
d-log
abs
d-abs
sqrt
d-sqrt
sqr
d-sqr
sum
d-sum
sum-cols
d-sum-cols
*-2-1
d*-2-1
argmax
d-argmax
max
d-max
concat
d-concat
concat-n
d-concat-n
dot-product
dot-product-2-1
correlate
8.12

7 Differentiable extended numerical functions🔗ℹ

The gradients of functions constructed from the following functions as primitives can be computed using , ∇¹ or gradient-of.

7.1 Extended operators🔗ℹ

procedure

(+ t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
(d+ t0 t1)  tensor?
  t0 : tensor?
  t1 : tensor?
Adds t0 and t1 based on Binary function extension rules.

The same as (ext2 +-0-0 0 0).

When using malt/no-overrides, d+ should be used.

procedure

(- t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
(d- t0 t1)  tensor?
  t0 : tensor?
  t1 : tensor?
Subtracts t0 and t1 based on Binary function extension rules.

The same as (ext2 --0-0 0 0).

When using malt/no-overrides, d- should be used.

procedure

(* t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
(d* t0 t1)  tensor?
  t0 : tensor?
  t1 : tensor?
Multiplies t0 and t1 based on Binary function extension rules.

The same as (ext2 *-0-0 0 0).

When using malt/no-overrides, d-* should be used.

procedure

(/ t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
(d/ t0 t1)  tensor?
  t0 : tensor?
  t1 : tensor?
Divides t0 into t1 based on Binary function extension rules.

The same as (ext2 /-0-0 0 0).

When using malt/no-overrides, d-/ should be used.

procedure

(expt t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
(d-expt t0 t1)  tensor?
  t0 : tensor?
  t1 : tensor?
Computes t0 raised to the power of t1 based on Binary function extension rules.

The same as (ext2 expt-0-0 0 0).

When using malt/no-overrides, d-expt should be used.

procedure

(exp t)  tensor?

  t : tensor?
(d-exp t)  tensor?
  t : tensor?
Computes e raised to the power of t based on Unary function extension rules.

The same as (ext1 exp-0 0).

When using malt/no-overrides, d-exp should be used.

procedure

(log t)  tensor?

  t : tensor?
(d-log t)  tensor?
  t : tensor?
Computes logarithm of t based on Unary function extension rules.

The same as (ext1 log-0 0).

When using malt/no-overrides, d-log should be used.

procedure

(abs t)  tensor?

  t : tensor?
(d-abs t)  tensor?
  t : tensor?
Computes absolute value of t based on Unary function extension rules.

The same as (ext1 abs-0 0).

When using malt/no-overrides, d-abs should be used.

procedure

(sqrt t)  tensor?

  t : tensor?
(d-sqrt t)  tensor?
  t : tensor?
Computes the square root of t based on Unary function extension rules.

The same as (expt t 1/2).

When using malt/no-overrides, d-sqrt should be used.

procedure

(sqr t)  tensor?

  t : tensor?
(d-sqr t)  tensor?
  t : tensor?
Computes the square of t based on Unary function extension rules.

The same as (* t t).

When using malt/no-overrides, d-sqr should be used.

procedure

(sum t)  tensor?

  t : tensor?
(d-sum t)  tensor?
  t : tensor?
If t is a tensor of rank 1, return the sum of all the scalar? elements in t.

When t is of rank higher than 1, the Unary function extension rules apply.

The same as (ext1 sum-1 1).

When using malt/no-overrides, d-sum should be used.

procedure

(sum-cols t)  tensor?

  t : tensor?
(d-sum-cols t)  tensor?
  t : tensor?
If t is a tensor of rank 2, return the sum of all the scalar? elements in t, calculated using the extended addition function +.

When t is of rank higher than 2, the Unary function extension rules apply.

When t is of rank 1, this function is the same as sum.

The function is undefined if t is a scalar.

The same as (ext1 sum-1 2).

When using malt/no-overrides, d-sum-cols should be used.

procedure

(*-2-1 t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
(d*-2-1 t0 t1)  tensor?
  t0 : tensor?
  t1 : tensor?
When t0 is a tensor of shape (list m n) and t1 is a tensor of shape (list n), returns a tensor r of shape (list m n) where the m elements of r are formed by multiplying each element of t0 with t1 using the extended multiplication function *.

When the ranks of t0 and t1 are higher than 2 and 1 respectively, the Binary function extension rules apply.

The function is undefined if t0 has rank less than 2 and t1 has rank less than 1.

The same as (ext2 * 2 1).

When using malt/no-overrides, d*-2-1 should be used.

procedure

(argmax t)  tensor?

  t : tensor?
(d-argmax t)  tensor?
  t : tensor?
When t is a tensor of rank 1, returns the index of the highest element in t.

When t is of rank higher than 1, the Unary function extension rules apply.

The function is undefined when t is of rank less than 1.

The same as (ext1 argmax-1 1).

When using malt/no-overrides, d-argmax should be used.

procedure

(max t)  tensor?

  t : tensor?
(d-max t)  tensor?
  t : tensor?
When t is a tensor of rank 1, returns the highest element in t.

When t is of rank higher than 1, the Unary function extension rules apply.

The function is undefined when t is of rank less than 1.

The same as (ext1 max-1 1).

When using malt/no-overrides, d-max should be used.

procedure

(concat t u)  tensor?

  t : tensor?
  u : tensor?
(d-concat t u)  tensor?
  t : tensor?
  u : tensor?
When t and u are tensors of rank 1, returns a tensor that is the concatenation of t and u.

Otherwise, the Binary function extension rules apply.

The function is undefined when t or u is of rank less than 1.

The same as (ext2 concat-1-1 1 1).

When using malt/no-overrides, d-concat should be used.

procedure

(concat-n n)  (-> ([t tensor?] [u tensor?]) tensor?)

  n : positive-integer?
(d-concat-n n)  (-> ([t tensor?] [u tensor?]) tensor?)
  n : positive-integer?
When t and u are tensors of rank n, returns a tensor that is the concatenation of t and u.

Otherwise, the Binary function extension rules apply.

The function is undefined when t or u is of rank less than n.

When using malt/no-overrides, d-concat-n should be used.

procedure

(dot-product t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
When t0 and t1 are tensors of rank 1 and the same shape, returns a scalar s formed by multiplying each element of t0 with the corresponding element in t1 and summing the results.

When the ranks of t0 and t1 are higher than 2 and 1 respectively, the Binary function extension rules apply.

The function is undefined if t0 has rank less than 2 and t1 has rank less than 1.

The same as (sum (* t0 t1)).

procedure

(dot-product-2-1 t0 t1)  tensor?

  t0 : tensor?
  t1 : tensor?
When t0 is a tensor of shape (list m n) and t1 is a tensor of shape (list n), returns a tensor r of shape (list m) where the m elements of r are formed by the dot-product of each element of t0 with t1.

When the ranks of t0 and t1 are higher than 2 and 1 respectively, the Binary function extension rules apply.

The function is undefined if t0 has rank less than 2 and t1 has rank less than 1.

The same as (sum (*-2-1 t0 t1)).

procedure

(correlate filter-bank signal)  tensor?

  filter-bank : tensor?
  signal : tensor?
When filter-bank is a tensor of shape (list b m d) and signal is a tensor of shape (list n d), returns a tensor r of shape (list n b) which is the correlation of the filter-bank with the signal.

When the ranks of filter-bank and signal are higher than 3 and 2 respectively, the Binary function extension rules apply.