1 core.vectors.DotProduct
core.vectors.DotProduct(left, right)Dot product of two vectors: x · y = x[0]y[0] + x[1]y[1] + … + x[n-1]*y[n-1].
This is a scalar expression representing the inner product.
1.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| left | VectorVariable | VectorExpression | First vector. | required |
| right | VectorVariable | VectorExpression | Second vector. | required |
1.2 Example
x = VectorVariable(“x”, 3) y = VectorVariable(“y”, 3) d = DotProduct(x, y) d.evaluate({“x[0]”: 1, “x[1]”: 2, “x[2]”: 3, “y[0]”: 4, “y[1]”: 5, “y[2]”: 6}) 32.0
1.3 Methods
| Name | Description |
|---|---|
| evaluate | Evaluate the dot product given variable values. |
| get_variables | Return all variables this expression depends on. |
| jacobian_row | Return Jacobian row in O(n) for special cases. |
1.3.1 evaluate
core.vectors.DotProduct.evaluate(values)Evaluate the dot product given variable values.
1.3.2 get_variables
core.vectors.DotProduct.get_variables()Return all variables this expression depends on.
1.3.3 jacobian_row
core.vectors.DotProduct.jacobian_row(variables)Return Jacobian row in O(n) for special cases.
For DotProduct(x, x) (same VectorVariable), gradient is 2*x[i]. For DotProduct(x, y) with two different VectorVariables, gradient is y[i] for x[i] and x[i] for y[i].
1.3.3.1 Returns
| Name | Type | Description |
|---|---|---|
| list[Expression] | None | List of expressions, or None if optimization not applicable. |