Scroll to navigation

MAT_CALCSINGLESUBSCRIPT(3) Library Functions Manual MAT_CALCSINGLESUBSCRIPT(3)

NAME

Mat_CalcSingleSubscript — Converts MATLAB-style subscripts to a 0-relative linear index.

SYNOPSIS

#include <matio.h>

int
Mat_CalcSingleSubscript(int rank, const int *dims, const int *subs);

DESCRIPTION

The () function converts a set of 1-relative MATLAB-style subscripts in subs for an array with dimensions dims and rank rank into a single 0-relative linear index. Each subscript must be in the range 1 through the corresponding dimension size.

RETURN VALUES

On success, the computed 0-relative linear index is returned. If any subscript is out of range, -1 is returned.

EXAMPLES

int dims[2] = {3, 4};
int subs[2] = {2, 3};
int index;

index = Mat_CalcSingleSubscript(2, dims, subs);

SEE ALSO

Mat_CalcSingleSubscript2(3)

April 23, 2026 Nixpkgs