-
#include "tensorstore/array.h"
-
template <ContainerKind LayoutCKind = view,
typename ElementTag,
DimensionIndex Rank,
ArrayOriginKind OriginKind,
ContainerKind SourceCKind,
typename Indices>
requires IsCompatiblePartialIndexVector<
RankConstraint::FromInlineRank(Rank),
Indices>
Array<
typename ElementTagTraits<ElementTag>::Element,
SubArrayStaticRank<RankConstraint::FromInlineRank(Rank), Indices>,
OriginKind,
LayoutCKind>
tensorstore::SubArray(
const Array<ElementTag, Rank, OriginKind, SourceCKind>& array,
const Indices& indices); -
template <ContainerKind LayoutCKind = view,
typename Element,
DimensionIndex Rank,
ArrayOriginKind OriginKind,
ContainerKind SourceCKind,
typename Indices>
SharedArray<
Element,
SubArrayStaticRank<RankConstraint::FromInlineRank(Rank), Indices>,
OriginKind,
LayoutCKind>
tensorstore::SharedSubArray(
const SharedArray<Element, Rank, OriginKind, SourceCKind>& array,
const Indices& indices); Returns a reference to the sub-array obtained by subscripting the first
tensorstore::span(indices).size()
dimensions ofarray
.SubArray
always returns an array with an unowned data pointer, whileSharedSubArray
returns an array that shares ownership of the data.- Template Parameters:¶
- ContainerKind LayoutCKind = view¶
Specifies whether to return a copy or view of the sub-array layout.
- Parameters:¶
- const Array<ElementTag, Rank, OriginKind, SourceCKind> &array¶
- const SharedArray<Element, Rank, OriginKind, SourceCKind> &array
The source array.
- const Indices &indices¶
A
span
-compatible index array. May be specified as a braced list, e.g.SubArray(array, {1, 2})
orSharedSubArray(array, {1, 2})
.
- Dchecks:¶
- Dchecks:¶
0 <= tensorstore::span(indices)[i] < array.shape()[i]
for0 <= i < tensorstore::span(indices).size()
.- Returns:¶
The sub array.