     mutating func multiplyUnit(at index: Int, by newValue: UnitType) {
         units[units.startIndex.advanced(by: index)] *= newValue
     }
-
 }
 
 public extension Tensor where UnitType : BinaryInteger {

    mutating func updateUnit(at index: Int, to newValue: UnitType) {
        units[units.startIndex.advanced(by: index)] = newValue
    }

}

public extension Tensor where UnitType : Numeric {

    mutating func incrementUnit(at index: Int, by newValue: UnitType) {
        units[units.startIndex.advanced(by: index)] += newValue
    }

    public func index(before i: Int) -> Int {
        return i - 1
    }
}

public extension Tensor {
    public func reshaped(as newShape: TensorShape) -> Tensor? {
        guard self.shape.contiguousSize == newShape.contiguousSize else {
            return nil
        }
        return Tensor(shape: newShape, units: units)
    }
}

public extension Tensor {
    func withUnsafeBufferPointer<Result>
        (_ body: (UnsafeBufferPointer<UnitType>) throws -> Result) rethrows -> Result {
        return try units.withUnsafeBufferPointer { ptr in
