dotMultiply

x .* y

dotMultiply(x, y)

Try it yourself:

See also:

dotMultiply(): Element-Wise Products

dotMultiply() multiplies corresponding entries of compatible arrays or matrices. dotMultiply([2, 3], [4, 5]) returns [8, 15]. It is ideal for applying per-item weights, masks, conversion factors, or gains.

Not matrix multiplication

This operation keeps matching positions independent. It differs from multiply(), where matrix multiplication combines rows and columns, and from dot(), which reduces two vectors to one scalar. Check array shapes first with size().

Element-wise multiplication is often paired with dotDivide() for normalization and with sum() for weighted totals. Make unit effects explicit: multiplying a quantity by a dimensionless weight differs from multiplying two physical measurements.

Practical example

Multiply a sales vector by a per-product commission vector, then sum the result. This keeps the calculation transparent and avoids accidental matrix-product semantics.

All functions