mapToParent

abstract fun mapToParent(childIndices: IntArray): IntArray(source)

Maps child (view) coordinates to parent tensor coordinates.

This method performs the core coordinate transformation, converting indices from the view's coordinate system to the parent tensor's coordinate system. The transformation must handle:

  • Dimensional mapping (view dimensions to parent dimensions)

  • Offset calculations (handling slice starting positions)

  • Stride transformations (handling step sizes and memory layout)

Coordinate Validation

Implementations should validate that:

  • childIndices.size matches the expected view dimensionality

  • All child indices are within valid bounds for the view

  • The resulting parent indices are within parent tensor bounds

Performance Requirements

This method is called for every element access operation, so implementations must be highly optimized. Consider:

  • Pre-computing stride multipliers

  • Using lookup tables for common patterns

  • Minimizing array allocations

Return

the corresponding coordinates in the parent tensor's coordinate system

Parameters

childIndices

the coordinates in the view's coordinate system

Throws

if childIndices are invalid or out of bounds

if childIndices has incorrect dimensionality