shape

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 3 Imported by: 20

Documentation

Overview

Package shape defines the shape of an array.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Size

func Size(dims []int) int

Size returns the total number of elements given a slice of axis lengths.

Types

type ArrayI

type ArrayI[T dtype.GoDataType] interface {
	// Shape returns the size of all the axes of the array.
	Shape() []int

	// Flat returns the data stored by the array.
	// The length of the returned slice should match the size of the shape.
	Flat() []T
}

ArrayI is a minimum generic array interface.

type Shape

type Shape struct {
	DType       dtype.DataType
	AxisLengths []int
}

Shape represents the shape of an array, that is the datatype of the elements stored in the array and a list of axis lengths in major-to-minor order.

func (*Shape) ByteSize

func (s *Shape) ByteSize() int

ByteSize returns the size of the buffer, in bytes, to store the data specified by the shape.

func (*Shape) Equal

func (s *Shape) Equal(o *Shape) bool

Equal returns true if o represents the same shape.

func (*Shape) IsAtomic

func (s *Shape) IsAtomic() bool

IsAtomic returns true for the shape of an atomic value, that is a single value with no axis.

func (*Shape) OuterAxisLength

func (s *Shape) OuterAxisLength() int

OuterAxisLength returns the shape's outermost axis length, or 1 for rank-0 shapes.

func (*Shape) Size

func (s *Shape) Size() int

Size returns the number of elements of DType are needed for this shape. It's the product of all dimensions.

func (*Shape) String

func (s *Shape) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL