Skip to main content
The matrix dimensions endpoints let you programmatically inspect the size of a matrix. There are four endpoints in this group: a combined endpoint that accepts a type parameter to select the specific query, and three individual endpoints — nrows, ncols, and shape. All endpoints accept a single input matrix a and the full set of common request parameters. Consider the following sample matrix used throughout the examples on this page:
This is a 3 × 4 matrix: 3 rows and 4 columns.

Combined endpoint

Use this endpoint to query any dimension property by setting the type field. POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-dimensions

Parameters

number[][]
required
The input matrix, expressed as an array of row arrays.
string
required
The dimension property to compute. Accepted values:
  • "all" — compute and return all dimension properties
  • "nrows" — number of rows
  • "ncols" — number of columns
  • "shape" — both dimensions as a (rows, cols) tuple
string
default:"ans"
Name assigned to the computed result in the response.
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
boolean
default:"true"
Include background theory alongside solution steps.
string[]
default:"[\"\"]"
Format for step content: "html", "latex", or "speech".
integer | null
default:"null"
Decimal precision for rounding. Pass null for full precision.
boolean
default:"false"
Apply decimals rounding to intermediate step values.
boolean
default:"true"
Include normalized request parameters in the response.
boolean
default:"true"
Include curated learning resource links in the response.
Include links to related Stemfard endpoints in the response.
boolean
default:"true"
Include a description of the result object’s properties.

Example — query all dimension properties

200

Individual dimension endpoints

Each dimension query has its own focused endpoint. These do not accept a type field — the query is determined by the path.
Returns the number of rows in the input matrix.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-dimensions/nrows
number[][]
required
The input matrix.
string
default:"ans"
Name for the result in the response.
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
integer | null
default:"null"
Decimal precision for rounding.
Example
200
Returns the number of columns in the input matrix.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-dimensions/ncols
number[][]
required
The input matrix.
string
default:"ans"
Name for the result in the response.
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
integer | null
default:"null"
Decimal precision for rounding.
Example
200
Returns both dimensions as a (rows, cols) tuple. This is equivalent to querying nrows and ncols in a single request.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-dimensions/shape
number[][]
required
The input matrix.
string
default:"ans"
Name for the result in the response.
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
integer | null
default:"null"
Decimal precision for rounding.
Example
200
The response value is an array where the first element is the number of rows and the second element is the number of columns.