Algosim documentation: ⋅

⋅ (dot operator)

The multiplication operator.

Syntax

Description and examples

Multiplying two numbers

If a and b are numbers (integers, rational numbers, real number, or complex numbers), a ⋅ b is the mathematical product of a and b. The type of the product is the most specific type possible.

Some examples:

√2⋅π
4.44288293816
3/7 ⋅ 2/5
6/35	(=0.171428571429)

Vector dot product

If u and v are two vectors of the same dimension, then u⋅v is their dot (inner, scalar) product. If both are real, then u⋅v is real. If any of u and v is complex, the complex inner inner product will be used and the result will be complex.

❨5, 0, 1❩ ⋅ ❨−2, 1, 0❩
−10
❨1, i, 3❩ ⋅ ❨2, 1, i❩
2 − 2⋅i

The vector dot product of u and v can also be written (u|v) or InnerProduct(u, v).

Matrix multiplication

If A and B are two matrices of compatible sizes, then A⋅B is their matrix product. The number of columns of A must equal the number of rows of B; the result will have the same number of rows as A and the same number of columns as B.

If any of the operands is complex, so is the product; otherwise, the product is a real matrix.

A ≔ ❨❨3, 0, 1❩, ❨5, 1, 0❩, ❨0, 2, 1❩❩
⎛3  0  1⎞
⎜5  1  0⎟
⎝0  2  1⎠
B ≔ ❨❨3, 1, i❩, ❨2, 0, 1❩, ❨4, 3, −1❩❩
⎛ 3   1   i⎞
⎜ 2   0   1⎟
⎝ 4   3  −1⎠
A⋅B
⎛      13         6  −1 + 3⋅i⎞
⎜      17         5   1 + 5⋅i⎟
⎝       8         3         1⎠

Multiplication by scalar

If v is a vector, A a matrix, and x a number, then x⋅v, v⋅x, x⋅A, and A⋅x are the results of the corresponding multiplication by scalar operations, that is, each vector component or matrix entry is multiplied by the scalar, thus forming a new vector or matrix.

The result is complex iff at least one operand is complex.

2⋅❨1, 0, 0❩ + 3⋅❨0, 1, 0❩ + 5⋅❨0, 0, 1❩
 ⎛2⎞
e⎜3⎟
 ⎝5⎠
5⋅IdentityMatrix(3)
⎛5  0  0⎞
⎜0  5  0⎟
⎝0  0  5⎠

Multiplication between matrix and vector

If A is a matrix and v a vector, with A having the same number of columns as the dimension of v, then A⋅v is the image of v under the linear transformation given by A. In other words, A⋅v = A⋅matrix(v) is the matrix product between A and v considered as a column vector (matrix).

The result is complex iff at least one operand is complex.

A ≔ ❨❨1, 0, 0❩, ❨0, 0, 1❩, ❨0, −1, 0❩❩
⎛ 1   0   0⎞
⎜ 0   0   1⎟
⎝ 0  −1   0⎠
A⋅❨1, 0, 2❩
 ⎛1⎞
e⎜2⎟
 ⎝0⎠

String repetition

If n is a non-negative integer and s a string, then n⋅s or s⋅n is the string s repeated n times.

10⋅"CTG"
CTGCTGCTGCTGCTGCTGCTGCTGCTGCTG
"━"⋅80
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Scaling a sound

If s is a sound and x ∈ [0, 1], then x⋅s is the sound obtained from s by scaling the samples by x. Hence, 1⋅s = s and 0⋅s is silence.

0.1 ⋅ SineTone(100, 1, 1)
A 1-second 32-bit 48000 Hz 1-channel sound.

Combining two sounds

If s and t are two sounds, then s ⋅ t is the same as 0.5⋅s + 0.5⋅t.

SineTone(100, 0.1, 1) ⋅ SineTone(400, 0.1, 1)
A 1-second 32-bit 48000 Hz 1-channel sound.

Notes

The binary operator is mapped to the multiply function.

See also