(*) multiply operator and star operator

(number * number) -> number, const autodiff

The regular multiplication of two numbers.

x = 3
y = 2
show scalar "" with x * y

(i64 * i64) -> i64, const

Multiplies two i64 values, returning an i64.

x = to.i64(7) * to.i64(2)
show scalar "Product" with text(x) // 14

(f64 * f64) -> f64, const

Multiplies two f64 values, returning an f64.

x = to.f64(1.5) * to.f64(2.5)
show scalar "Product" with text(x) // 3.75

(ranvar * ranvar) -> ranvar

The multiplication of two random independent variables over $\mathbb{Z}$.

x1 = poisson(5)
x2 = poisson(3)
show scalar "" with x1 * x2

This operation is also known as the Dirichlet convolution. Under the hood, a convolution happens. The mean of the resulting ranvar is equal to the product of the means of the two ranvar operands.

(zedfunc * zedfunc) -> zedfunc

The multiplication of two zedfuncs, real functions over $\mathbb{Z}$..

Example:

f = linear(3)
g = linear(2)
show scalar "" with f * g

(embedding * embedding) -> embedding

Combines two embeddings into a new embedding.

a = embedding("price")
b = embedding("discount")
c = a * b
show scalar "Embedding product" with spark(c)

(number * embedding) or (embedding * number) -> embedding, autodiff

Multiplies every coordinate of an embedding by a scalar number. Both operand orders are supported.

e = embedding("inventory")
twice = 2 * e
half = e * 0.5

show summary "Scaled embeddings" with
  spark(twice) as "Twice"
  spark(half) as "Half"

Scalar multiplication is supported inside autodiff blocks.

(text * number) -> text

Repeats text a specified number of times. "ABC" * 3 is "ABCABCABC". An integer is expected.

Example:

show scalar "" with "ABC" * 3

Table.* -> boolean, star operator

The MyTable.* syntax is used as a syntactic sugar for true into MyTable.

table T = with
  [| as A  |]
  [| true  |]
  [| false |]
  [| true  |]
 
where T.A
  show scalar "Lines" with count(T.*) // '2'
  // 'T.*' is a syntactic sugar for 'true into T'
  show scalar "Lines" with count(true into T)  // '2'

The T.* syntactic sugar can be used in isolation, but this sugar is really intended for count(T.*), which is reminiscent of the SQL syntax SELECT COUNT(*) FROM myTbl.

Seelaso

User Contributed Notes
0 notes + add a note