Skip to content

Main content

Matrix Lower To Upper Packed Diagonal Offset Tool

Compare diagonal offsets for row-major lower and row-major upper triangular packed storage.

Loading tool…

Description

For a zero-based diagonal index, return index × (index + 3) / 2 in row-wise lower storage and index × size - index × (index - 1) / 2 in row-wise upper storage.

Packed matrix storage omits a triangle and maps coordinates into a linear array. Row-wise versus column-wise order and diagonal inclusion change the offset formula.

For a zero-based diagonal index, return index × (index + 3) / 2 in row-wise lower storage and index × size - index × (index - 1) / 2 in row-wise upper storage.

When to use this tool

Use Matrix Lower To Upper Packed Diagonal Offset when you need an explicit packed or band-storage coordinate mapping.

How to use the tool and how it works

  1. Enter size, index. 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 lowerOffset, upperOffset. Use the output convention below.

For a zero-based diagonal index, return index × (index + 3) / 2 in row-wise lower storage and index × size - index × (index - 1) / 2 in row-wise upper storage.1

Input fieldMeaning and unitsAccepted input
sizeSizeRequired. Safe integer; minimum 1; maximum 1000000.
indexIndexRequired. Safe integer; minimum 0.
Output fieldInterpretationReturned shape
lowerOffsetLower OffsetRequired. Safe integer.
upperOffsetUpper OffsetRequired. Safe integer.
json
{
  "input": {
    "size": 4,
    "index": 2
  },
  "output": {
    "lowerOffset": 5,
    "upperOffset": 7
  }
}

Limitations and assumptions

  • Both conventions include the diagonal; these are offsets rather than a complete packed-array conversion.
  • 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

Check the consuming library's storage convention against several boundary coordinates before indexing its buffer.

References

  1. Calculation and input contract: matrix/matrix-lower-to-upper-packed-diagonal-offset — tool.io

Similar or alternative tools