DOT_PRODUCT()
All functions > ARRAY > DOT_PRODUCT()
Calculates the dot product of two arrays.
Signatures
Returns: Dot product of the two vectors
DOT_PRODUCT(array1: ARRAY<DOUBLE>, array2: ARRAY<DOUBLE>) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array1 | ARRAY<DOUBLE> | Yes | First vector (array of doubles) |
array2 | ARRAY<DOUBLE> | Yes | Second vector (array of doubles) |
Notes
- Computes sum of element-wise products
- Formula: sum(x[i] * y[i])
- Arrays must be same length
- Used in linear algebra and vector operations
See also
Examples
FeatureQL
SELECT
-- Basic dot product: 1*4 + 2*5 + 3*6
f1 := DOT_PRODUCT(ARRAY(1.0e0, 2.0e0, 3.0e0), ARRAY(4.0e0, 5.0e0, 6.0e0)),
-- Orthogonal vectors yield zero
f2 := DOT_PRODUCT(ARRAY(1.0e0, 0.0e0, 0.0e0), ARRAY(0.0e0, 1.0e0, 0.0e0)),
-- Dot product with itself equals squared magnitude
f3 := DOT_PRODUCT(ARRAY(2.0e0, 3.0e0), ARRAY(2.0e0, 3.0e0))
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 32.0 | 0.0 | 13.0 |
On this page