@@ -500,11 +500,9 @@ extension Tensor: Codable where Scalar: Codable {
500
500
//===------------------------------------------------------------------------------------------===//
501
501
502
502
extension Tensor : AdditiveArithmetic where Scalar: Numeric {
503
- /// A scalar zero tensor.
503
+ /// The scalar zero tensor.
504
504
@inlinable
505
- public static var zero : Tensor {
506
- return Tensor ( 0 )
507
- }
505
+ public static var zero : Tensor { Tensor ( 0 ) }
508
506
509
507
/// Adds two tensors and produces their sum.
510
508
/// - Note: `+` supports broadcasting.
@@ -553,6 +551,26 @@ internal extension Tensor where Scalar: TensorFlowFloatingPoint {
553
551
}
554
552
}
555
553
554
+ //===------------------------------------------------------------------------------------------===//
555
+ // Multiplicative Group
556
+ //===------------------------------------------------------------------------------------------===//
557
+
558
+ extension Tensor : PointwiseMultiplicative where Scalar: Numeric {
559
+ /// The scalar one tensor.
560
+ @inlinable
561
+ public static var one : Tensor { Tensor ( 1 ) }
562
+
563
+ /// Returns the pointwise reciprocal of `self`.
564
+ @inlinable
565
+ public var reciprocal : Tensor { 1 / self }
566
+
567
+ /// Multiplies two tensors element-wise and produces their product.
568
+ /// - Note: `.*` supports broadcasting.
569
+ public static func .* ( lhs: Tensor , rhs: Tensor ) -> Tensor {
570
+ return lhs * rhs
571
+ }
572
+ }
573
+
556
574
//===------------------------------------------------------------------------------------------===//
557
575
// Differentiable
558
576
//===------------------------------------------------------------------------------------------===//
0 commit comments