Skip to content

Main content

Sparse Coordinate Triplet Crop

Crop a COO matrix to a half-open coordinate rectangle and rebase retained entries, preserving duplicates and explicit zero observations.

Loading tool…

Description

Crop a COO matrix to a half-open coordinate rectangle and rebase retained entries, preserving duplicates and explicit zero observations.

A sparse matrix can be stored as coordinate triplets or as pointer/index/value arrays. Stored entries are not necessarily distinct numerical nonzeros: duplicates and explicit zeros can matter to representation checks. Row and column coordinates here are zero-based, and omitted entries are handled only as stated for the particular operation.

Crop a COO matrix to a half-open coordinate rectangle and rebase retained entries, preserving duplicates and explicit zero observations.

When to use this tool

Use this tool to crop a COO matrix to a half-open coordinate rectangle and rebase retained entries, preserving duplicates and explicit zero observations.

How to use the tool and how it works

  1. Enter tripletsJson, rows, columns, rowStart, rowEnd, columnStart, columnEnd using the field definitions below. For JSON text, serialize the explicit records in the shown shape.
  2. Run the operation. Correct input errors before interpreting an output.
  3. Read result.rows, result.columns, result.triplets. Use the ordering, boundary rules and absence conditions described below.

Keep triplets inside the supplied half-open row and column ranges, subtract their starting offsets, and return the cropped shape.1

Input fieldMeaning and unitsAccepted input
tripletsJsonJSON array of records with zero-based row, column and finite value fields.Text, at most 8,192 UTF-16 code units; the operation’s grammar also applies.
rowsDeclared row count; coordinate operations use 0–128, dense budgets allow larger integers.A finite safe integer within the operation’s stated bounds.
columnsDeclared column count; coordinate operations use 0–128, dense budgets allow larger integers.A finite safe integer within the operation’s stated bounds.
rowStartInclusive first row of a crop.A finite safe integer within the operation’s stated bounds.
rowEndExclusive row end of a crop.A finite safe integer within the operation’s stated bounds.
columnStartInclusive first column of a crop.A finite safe integer within the operation’s stated bounds.
columnEndExclusive column end of a crop.A finite safe integer within the operation’s stated bounds.

These are the decoded structures used in the example’s JSON text fields. Supply the corresponding serialized JSON strings as input.

json
{
  "tripletsJson": [
    {
      "row": 0,
      "column": 1,
      "value": 2
    },
    {
      "row": 0,
      "column": 1,
      "value": 3
    },
    {
      "row": 1,
      "column": 0,
      "value": 0
    }
  ]
}
Output fieldInterpretation
resultObject containing the named fields below.
result.rowsResulting row count.
result.columnsResulting column count.
result.tripletsStored {row, column, value} records under the operation’s stated ordering and duplicate policy.
json
{
  "input": {
    "tripletsJson": "[{\"row\":0,\"column\":1,\"value\":2},{\"row\":0,\"column\":1,\"value\":3},{\"row\":1,\"column\":0,\"value\":0}]",
    "rows": 2,
    "columns": 2,
    "rowStart": 0,
    "rowEnd": 1,
    "columnStart": 1,
    "columnEnd": 2
  },
  "output": {
    "result": {
      "rows": 1,
      "columns": 1,
      "triplets": [
        {
          "row": 0,
          "column": 0,
          "value": 2
        },
        {
          "row": 0,
          "column": 0,
          "value": 3
        }
      ]
    }
  }
}

Limitations and assumptions

  • Records retain source order, duplicates and explicit zeros; empty ranges are allowed.
  • Triplets are JSON records with row, column and value. Coordinate shapes are ordinarily bounded to 128 per axis; compressed major dimensions are limited to 127 for pointer-list capacity. The dense-budget operation has separate larger shape limits and returns exact counts as decimal text.
  • Every declared top-level input field is required and unexpected fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and no larger in absolute magnitude than the safe-integer limit; operations returning exact large integers use decimal text. Positions are zero-based and spans end exclusively unless the operation explicitly states a different convention.

Alternative or Complementary methods

Distinguish stored-record counts, coordinate-pattern checks and arithmetic matrix properties. Combine duplicates or prune zeros explicitly when required, and use a matrix library for numerical linear algebra.

References

  1. Tool behavior and example: Sparse Coordinate Triplet Crop — tool.io

Similar or alternative tools

  • Sparse Coordinate Axis Offset

    Translate bounded COO coordinates into explicitly supplied target dimensions; out-of-target entries are rejected rather than clipped.

  • Sparse Coordinate Column Counts

    Count COO entry occurrences per column, including duplicate coordinates and explicit zero values; not dense nonzero support.