1 core.vectors.VectorExpression
core.vectors.VectorExpression(expressions)A vector of expressions (result of vector arithmetic).
VectorExpression represents element-wise operations on vectors, such as x + y or 2 * x.
1.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| expressions | Sequence[Expression] | List of scalar expressions, one per element. | required |
1.2 Example
x = VectorVariable(“x”, 3) y = VectorVariable(“y”, 3) z = x + y # VectorExpression with 3 elements z[0].evaluate({“x[0]”: 1, “y[0]”: 2}) 3.0
1.3 Methods
| Name | Description |
|---|---|
| dot | Compute dot product with another vector. |
| eq | Element-wise == constraint. |
| evaluate | Evaluate all expressions and return as list. |
| get_variables | Return all variables these expressions depend on. |
1.3.1 dot
core.vectors.VectorExpression.dot(other)Compute dot product with another vector.
1.3.1.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| other | VectorExpression | VectorVariable | Vector to compute dot product with. | required |
1.3.1.2 Returns
| Name | Type | Description |
|---|---|---|
| DotProduct | DotProduct expression (scalar). |
1.3.1.3 Example
x = VectorVariable(“x”, 3) y = VectorVariable(“y”, 3) d = x.dot(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.2 eq
core.vectors.VectorExpression.eq(other)Element-wise == constraint.
1.3.2.1 Example
x = VectorVariable(“x”, 3) y = VectorVariable(“y”, 3) constraints = x.eq(y) # 3 constraints: x[i] == y[i]
1.3.3 evaluate
core.vectors.VectorExpression.evaluate(values)Evaluate all expressions and return as list.
1.3.4 get_variables
core.vectors.VectorExpression.get_variables()Return all variables these expressions depend on.