Skip to content

Math.Multiply

Name Mandatory Description Default Type
⬅️ Input The value or the sequence of values to multiply the value specified in the Operand parameter with. IntInt2Int3Int4Int8Int16FloatFloat2Float3Float4Color[Any]
Output ➡️ This shard outputs the result of the multiplication. IntInt2Int3Int4Int8Int16FloatFloat2Float3Float4Color[Any]
Operand No The value or sequence of values to multiply the input by. 0 IntVar(Int)Int2Var(Int2)Int3Var(Int3)Int4Var(Int4)Int8Var(Int8)Int16Var(Int16)FloatVar(Float)Float2Var(Float2)Float3Var(Float3)Float4Var(Float4)ColorVar(Color)[Any]Var([Any])

This shard multiplies the input value by the value provided in the Operand parameter.

Details

This shard can take an integer or a sequence of integers as input. However, depending on the type of input, the appropriate Operand needs to be provided:

For non-sequence inputs: The Operand must match the input type exactly (e.g., Int2 with Int2, Color with Color).

For sequence inputs: The Operand can be either: - A matching non-sequence type (e.g., sequence of Int2 with a single Int2 Operand). Each element of the input sequence is operated on by the Operand. - Another sequence of elements with the same types. Each element of the Operand sequence is applied to the corresponding element of the input sequence. If the input sequence is longer, the Operand sequence will loop over till all elements of the input sequence are operated on. If the Operand sequence is longer, the extra elements of the Operand sequence are ignored.

See also

Binary operations on sequences

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
; Multiply integers
5 | Log ; prints input => 5
  | Math.Multiply(2) | Log ; prints input * operand => 10
  | Assert.Is(10 Break: true) ; expect: (5 * 2) => 10

; Multiply floats
5.3 | Log ; prints input => 5.3
    | Math.Multiply(2.1) | Log ; prints input * operand => 11.13
    | Assert.Is(11.13 Break: true) ; expect: (5.3 * 2.1) => 11.13

; Multiply equal-sized sequences
[4 5.1 6.4] | Log ; prints input => [4 5.1 6.4]
            | Math.Multiply([3 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
            | Log ; prints input * operand => [12 20.4 14.08]
            | Assert.IsAlmost([12 20.4 14.08] Break: true) ; expect: [(4 * 3) (5.1 * 4.0) (6.4 * 2.2)] => [12 20.4 14.08]

; Multiply unequal-sized sequences (input size < operand size)
[4.0] | Log ; prints input => [4.0]
      | Math.Multiply([3.0 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
      | Log ; prints input * operand => [12.0]
      | Assert.Is([12.0] Break: true) ; expect: [(4.0 * 3.0) ... ...] => [12.0]

; Multiply unequal-sized sequences (input size > operand size)
[4 2 1 5 8] | Log ; prints input => [4 2 1 5 8]
            | Math.Multiply([6 4]) ; input seq elements compute with corresponding operand seq elements
            | Log ; prints input * operand => [24 8 6 20 48]
            | Assert.Is([24 8 6 20 48] Break: true) ; expect: [(4 * 6) (2 * 4) (1 * 6) (5 * 4) (8 * 6)] => [24 8 6 20 48]

[info] [sample-wire] 5
[info] [sample-wire] 10
[info] [sample-wire] 5.3
[info] [sample-wire] 11.13
[info] [sample-wire] [4 5.1 6.4]
[info] [sample-wire] [12 20.4 14.08]
[info] [sample-wire] [4]
[info] [sample-wire] [12]
[info] [sample-wire] [4 2 1 5 8]
[info] [sample-wire] [24 8 6 20 48]
 

1
2
3
4
; Multiply floats
5.3 | Log ; prints input => 5.3
    | Math.Multiply(2.1) | Log ; prints input * operand => 11.13
    | Assert.Is(11.13 Break: true) ; expect: (5.3 * 2.1) => 11.13

[info] [sample-wire] 5.3
[info] [sample-wire] 11.13
 

1
2
3
4
5
; Multiply equal-sized sequences
[4 5.1 6.4] | Log ; prints input => [4 5.1 6.4]
            | Math.Multiply([3 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
            | Log ; prints input * operand => [12 20.4 14.08]
            | Assert.IsAlmost([12 20.4 14.08] Break: true) ; expect: [(4 * 3) (5.1 * 4.0) (6.4 * 2.2)] => [12 20.4 14.08]

[info] [sample-wire] [4 5.1 6.4]
[info] [sample-wire] [12 20.4 14.08]
 

1
2
3
4
5
; Multiply unequal-sized sequences (input size < operand size)
[4.0] | Log ; prints input => [4.0]
      | Math.Multiply([3.0 4.0 2.2]) ; input seq elements compute with corresponding operand seq elements
      | Log ; prints input * operand => [12.0]
      | Assert.Is([12.0] Break: true) ; expect: [(4.0 * 3.0) ... ...] => [12.0]

[info] [sample-wire] [4]
[info] [sample-wire] [12]
 

1
2
3
4
5
; Multiply unequal-sized sequences (input size > operand size)
[4 2 1 5 8] | Log ; prints input => [4 2 1 5 8]
            | Math.Multiply([6 4]) ; input seq elements compute with corresponding operand seq elements
            | Log ; prints input * operand => [24 8 6 20 48]
            | Assert.Is([24 8 6 20 48] Break: true) ; expect: [(4 * 6) (2 * 4) (1 * 6) (5 * 4) (8 * 6)] => [24 8 6 20 48]

[info] [sample-wire] [4 2 1 5 8]
[info] [sample-wire] [24 8 6 20 48]