Skip to content

Main content

Matrix: Matrix Diagonal Offset Length Tool

Compute the number of entries on one rectangular matrix diagonal with column-minus-row signed offset, without allocating a matrix.

Loading tool…

Description

For signed offset, skip max(0, -offset) rows and max(0, offset) columns.

A matrix coordinate, a storage offset, and a block-local coordinate are different representations. Shape, stride, origin, and transpose conventions determine the correct mapping.

For signed offset, skip max(0, -offset) rows and max(0, offset) columns.

When to use this tool

Use Matrix: Matrix Diagonal Offset Length when you need one explicit matrix-coordinate or address conversion.

How to use the tool and how it works

  1. Enter rows, columns, offset. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read result. Expand result to inspect the returned fields.

For signed offset, skip max(0, -offset) rows and max(0, offset) columns. Return the nonnegative minimum remaining dimension as length.1

Input fieldMeaning and unitsAccepted input
rowsRowsRequired. Safe integer.
columnsColumnsRequired. Safe integer.
offsetOffsetRequired. Safe integer.
Output fieldInterpretationReturned shape
resultResultRequired. Object.
result.lengthLengthCalculated result member: number.
json
{
  "input": {
    "rows": 3,
    "columns": 5,
    "offset": 2
  },
  "output": {
    "result": {
      "length": 3
    }
  }
}

Limitations and assumptions

  • Positive offsets lie above the main diagonal; empty dimensions or out-of-shape diagonals return length zero.
  • Outputs are nested inside result. Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Validate the full shape, memory span, and storage convention before using the resulting index.

References

  1. Calculation and input contract: matrix/matrix-diagonal-offset-length — tool.io

Similar or alternative tools