TypeTensor - v0.1.0
    Preparing search index...

    Type Alias ValidateDim<Dim, S>

    ValidateDim: S extends Shape
        ? NormalizeDim<Dim, S["length"]>
        : DimensionError<"Cannot validate dimension for non-shape type">

    Validate a dimension index for a given tensor rank Returns the normalized dimension or a DimensionError

    Type Parameters

    • Dim extends number
    • S extends Shape
    type Valid1 = ValidateDim<-1, [2, 3, 4]> // 2 (valid negative index)
    type Valid2 = ValidateDim<1, [2, 3, 4]> // 1 (valid positive index)
    type Invalid1 = ValidateDim<-5, [2, 3, 4]> // DimensionError (out of bounds)
    type Invalid2 = ValidateDim<3, [2, 3, 4]> // DimensionError (out of bounds)