# loki.transformations.array_indexing.vector_notation

Utilities to manipulate vector notation in array expressions.

Functions

`add_explicit_array_dimensions`(routine) | Make dimensions of arrays explicit within `Subroutine` `routine`.
`remove_explicit_array_dimensions`(routine[, ...]) | Remove colon notation from array dimensions within `Subroutine` `routine`.
`resolve_vector_dimension`(routine, dimension) | Resolve vector notation for a given dimension only.
`resolve_vector_notation`(routine) | Resolve implicit vector notation by inserting explicit loops

Classes

`IterationRangeIndexMapper`(*args[, loop_map, ...]) | A mapper that replaces fully qualified `RangeIndex` symbols with discrete loop indices and collects the according `index_to_range_map`.
`IterationRangeShapeMapper`() | A mapper that derives the fully qualified iteration dimension for unbounded `RangeIndex` indices in array expressions.
`ResolveVectorNotationTransformer`(*args[, ...]) | A `Transformer` that resolves implicit vector notation by inserting explicit loops.

remove_explicit_array_dimensions(routine, calls_only=False)

  Remove colon notation from array dimensions within `Subroutine` `routine`. E.g., convert two-dimensional array `arr2d(:,:)` to `arr2d` or `arr3d(:,:,:)` to `arr3d`, but NOT e.g., `arr(1,:,:)`.

  Parameters:

    - routine (`Subroutine`) – The subroutine to check

    - calls_only (bool) – Whether to remove colon notation from array dimensions only from arrays within (inline) calls or all arrays (default: False)

add_explicit_array_dimensions(routine)

  Make dimensions of arrays explicit within `Subroutine` `routine`. E.g., convert two-dimensional array `arr2d` to `arr2d(:,:)` or `arr3d` to `arr3d(:,:,:)`.

  Parameters:

    routine (`Subroutine`) – The subroutine to check

resolve_vector_notation(routine)

  Resolve implicit vector notation by inserting explicit loops

resolve_vector_dimension(routine, dimension, derive_qualified_ranges=False)

  Resolve vector notation for a given dimension only. The dimension is defined by a loop variable and the bounds of the given range.

  Unliked the related `resolve_vector_notation()` utility, this will only resolve the defined dimension according to `bounds` and `loop_variable`.

  Parameters:

    - routine (`Subroutine`) – The subroutine in which to resolve vector notation usage.

    - dimension (`Dimension`) – Dimension object that defines the dimension to resolve

    - derive_qualified_ranges (bool) – Flag to enable the derivation of (all) range bounds from shape information.

class ResolveVectorNotationTransformer(*args, loop_map=None, scope=None, derive_qualified_ranges=True, map_unknown_ranges=True, **kwargs)

  Bases: `Transformer`

  A `Transformer` that resolves implicit vector notation by inserting explicit loops.

  Parameters:

    - loop_map (dict of tuple to `Variable`) – A dict mapping the tuple `(lower, upper, step)` to a known variable symbol to use as loop index.

    - scope (`Subroutine` or `Module`) – The scope in which to create new loop index variables

    - derive_qualified_ranges (bool) – Derive explicit bounds for all unqualified index ranges (`:`) before resolving them with loops.

    - map_unknown_ranges (bool) – Flag to indicate whether unknown, but fully qualified range indices are to be remapped to loops.

  visit_Assignment(stmt, **kwargs)
  visit_MaskedStatement(masked, **kwargs)