*
Overloads
| Name | Description |
|---|---|
(const Object lhs * const ComplexTensor rhs) -> ComplexTensor | Element-wise multiplication of Complex tensors or tensor-scalar multiplication. |
(const Object lhs * const RealTensor rhs) -> RealTensor | Element-wise multiplication of Real tensors or tensor-scalar multiplication. |
(const Object lhs * const ComplexTensor rhs) -> ComplexTensor
Element-wise multiplication of Complex tensors or tensor-scalar multiplication.
Multiplies two tensors element-wise, or multiplies a tensor by a scalar.
For tensor-tensor multiplication:
- Both tensors must have the same shape
- Result[i,j,k,...] = A[i,j,k,...] * B[i,j,k,...]
For tensor-scalar multiplication:
- Every element of the tensor is multiplied by the scalar
- Result[i,j,k,...] = A[i,j,k,...] * s
This operation is commutative: A * B = B * A, and scalar * tensor = tensor * scalar.
Parameters
- rhs: Second operand: complex tensor or scalar.
Returns
A new complex tensor containing the element-wise product.
Example
// Tensor-tensor multiplication
var A = filled_tensor([2, 3], 2.0, as_complex)
var B = filled_tensor([2, 3], 3.0, as_complex)
var C = A * B // Each element is 2.0 * 3.0 = 6.0
print(C[0, 0]) // 6.0
// Tensor-scalar multiplication
var D = filled_tensor([2, 2], 5.0, as_complex)
var E = D * 2.0 // Each element is 5.0 * 2.0 = 10.0
print(E[1, 1]) // 10.0
// Scalar-tensor multiplication (commutative)
var F = 3.0 * D // Same as D * 3.0
print(F[0, 0]) // 15.0
(const Object lhs * const RealTensor rhs) -> RealTensor
Element-wise multiplication of Real tensors or tensor-scalar multiplication.
Multiplies two tensors element-wise, or multiplies a tensor by a scalar.
For tensor-tensor multiplication:
- Both tensors must have the same shape
- Result[i,j,k,...] = A[i,j,k,...] * B[i,j,k,...]
For tensor-scalar multiplication:
- Every element of the tensor is multiplied by the scalar
- Result[i,j,k,...] = A[i,j,k,...] * s
This operation is commutative: A * B = B * A, and scalar * tensor = tensor * scalar.
Parameters
- rhs: Second operand: real tensor or scalar.
Returns
A new real tensor containing the element-wise product.
Example
// Tensor-tensor multiplication
var A = filled_tensor([2, 3], 2.0, as_real)
var B = filled_tensor([2, 3], 3.0, as_real)
var C = A * B // Each element is 2.0 * 3.0 = 6.0
print(C[0, 0]) // 6.0
// Tensor-scalar multiplication
var D = filled_tensor([2, 2], 5.0, as_real)
var E = D * 2.0 // Each element is 5.0 * 2.0 = 10.0
print(E[1, 1]) // 10.0
// Scalar-tensor multiplication (commutative)
var F = 3.0 * D // Same as D * 3.0
print(F[0, 0]) // 15.0