public struct ShapedArray<Scalar> : _ShapedArrayProtocol

ShapedArray is a multi-dimensional array. It has a shape, which has type [Int] and defines the array dimensions, and uses a TensorBuffer internally as storage.

  • The dimensions of the array.

    Declaration

    public private(set) var shape: [Int]
  • Declaration

    var rank: Int { get }
  • Declaration

    var scalarCount: Int { get }
  • Declaration

    init(_ other: ShapedArray)
  • Declaration

    init(shape: [Int], scalars: [Scalar])
  • Declaration

    init<S>(shape: [Int], scalars: S) where Scalar == S.Element, S : Sequence
  • Creates a ShapedArray from a scalar value.

    Declaration

    init(_ scalar: Scalar)
  • Creates a ShapedArray with the specified shape and a single, repeated value.

    Declaration

    init(shape: [Int], repeating repeatedValue: Scalar)

    Parameters

    shape

    The dimensions of the array.

    repeatedValue

    The scalar value to repeat.

  • Declaration

    public typealias Index = Int
  • Declaration

    public typealias Element = ShapedArraySlice<Scalar>
  • Declaration

    public typealias SubSequence = ShapedArraySlice<Scalar>
  • Declaration

    public var indices: Range<Int> { get }
  • Declaration

    public var startIndex: Int { get }
  • Declaration

    public var endIndex: Int { get }
  • Access the element array specified by an index in the leading dimension.

    Declaration

    public subscript(index: Int) -> Element { get set }

    Parameters

    index

    Index of the element array.

  • Access the subarray specified by a contiguous range of indices.

    Declaration

    public subscript(bounds: Range<Int>) -> SubSequence { get set }

    Parameters

    bounds

    Contiguous range of indices.

  • Declaration

    func withUnsafeBufferPointer<Result>(
      _ body: (UnsafeBufferPointer<Scalar>) throws -> Result
    ) rethrows -> Result
  • Declaration

    mutating func withUnsafeMutableBufferPointer<Result>(
      _ body: (inout UnsafeMutableBufferPointer<Scalar>) throws -> Result
    ) rethrows -> Result
  • Declaration

    public static func == (lhs: ShapedArray, rhs: ShapedArray) -> Bool
  • A textual representation of this ShapedArray.

    Declaration

    public var description: String { get }
  • Declaration

    public var customMirror: Mirror { get }