Shape class
Enhanced Shape class with N-dimensional support
Represents the shape of multi-dimensional data structures with support for:
- N-dimensional shapes (1D, 2D, 3D, 4D, ...)
- Strides calculation for efficient flat indexing
- Broadcasting compatibility checking
- Index conversion (multi-dimensional ↔ flat)
This class is used by NDArray, DataCube, and can enhance DataFrame/Series.
Constructors
Properties
- columns → int
-
The number of columns (second dimension) for 2D+ structures
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isEmpty → bool
-
Checks if any dimension has size 0 (empty structure)
no setter
- isHypercube → bool
-
Checks if all dimensions have the same size (hypercube)
no setter
- isMatrix → bool
-
Checks if this is a 2D shape (matrix/DataFrame)
no setter
- isNotEmpty → bool
-
Checks if all dimensions have size > 0 (non-empty structure)
no setter
- isSquare → bool
-
Checks if this is a 2D square shape (rows == columns)
no setter
- isTensor → bool
-
Checks if this is a 3D+ shape (tensor)
no setter
- isVector → bool
-
Checks if this is a 1D shape (vector)
no setter
- ndim → int
-
Number of dimensions
no setter
- rows → int
-
The number of rows (first dimension) for 2D+ structures
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Total number of elements (product of all dimensions)
no setter
-
strides
→ List<
int> -
Strides for row-major indexing
no setter
Methods
-
addDimension(
int size, {int axis = 0}) → Shape - Add a dimension at the specified axis
-
broadcastWith(
Shape other) → Shape - Get broadcast shape with another shape
-
canBroadcastWith(
Shape other) → bool - Check if two shapes are broadcastable
-
fromFlatIndex(
int flatIndex) → List< int> - Convert flat index to multi-dimensional indices
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeDimension(
int axis) → Shape - Remove a dimension at the specified axis
-
toFlatIndex(
List< int> indices) → int - Convert multi-dimensional indices to flat index
-
toList(
) → List< int> - Get all dimensions as list
-
toString(
) → String -
A string representation of this object.
override
-
transpose(
List< int> axes) → Shape - Transpose (reorder) dimensions
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator [](
int index) → int - Get dimension at index