Skip to main content

RealSparseMatrix

A RealSparseMatrix.

Factories

identity(const List<integer> shape, as_real | as_sparsematrix type) -> RealSparseMatrix

Creates an identity matrix (or array; possibly rectangular) with the specified shape and type.

Parameters

  • shape: The shape of the container to create.
  • type: The type of the container to create.

matrix(const RealMatrix array, as_sparsematrix type) -> RealSparseMatrix

Converts a container to a sparse matrix with the same elements.

Arrays support elementwise operations, matrices support matrix algebra (e.g., operator *).

Parameters

  • array: The input RealMatrix.
  • type: The type of the container to create (here, a sparse matrix).

matrix(const Operator operator, as_real | as_sparsematrix type_tag) -> RealSparseMatrix

Converts the operator to its sparse matrix representation.

Parameters

  • operator: The operator to convert.
  • type_tag: A global constant tagging the object type.

matrix(const RealArray array, as_sparsematrix type) -> RealSparseMatrix

Converts a container to a sparse matrix with the same elements.

Arrays support elementwise operations, matrices support matrix algebra (e.g., operator *).

Parameters

  • array: The input RealArray.
  • type: The type of the container to create (here, a sparse matrix).

matrix(const RealSparseMatrix array, as_sparsematrix type) -> RealSparseMatrix

Converts a container to a sparse matrix with the same elements.

Arrays support elementwise operations, matrices support matrix algebra (e.g., operator *).

Parameters

  • array: The input RealSparseMatrix.
  • type: The type of the container to create (here, a sparse matrix).

matrix(const List list, as_real | as_sparsematrix type) -> RealSparseMatrix

Converts a list or list of list to a sparse matrix.

Parameters

  • list: The list containing the values.
  • type: The type of the container to create.

uninitialized(const List<integer> shape, as_real | as_sparsematrix type) -> RealSparseMatrix

Creates a container with the specified shape and type.

Parameters

  • shape: The shape of the container to create.
  • type: The type of the container to create.

zeros(const List<integer> shape, as_real | as_sparsematrix type) -> RealSparseMatrix

Creates a container with the specified shape and type, filled with zeros.

Parameters

  • shape: The shape of the container to create.
  • type: The type of the container to create.

Constructors

RealSparseMatrix() -> RealSparseMatrix

Creates an empty RealSparseMatrix.

RealSparseMatrix(integer m) -> RealSparseMatrix

Creates an m x 1 RealSparseMatrix. The array comes out uninitialized.

Parameters

  • m: The number of rows.

RealSparseMatrix(integer m, integer n) -> RealSparseMatrix

Creates an m x n RealSparseMatrix. The array comes out uninitialized.

Parameters

  • m: The number of rows.
  • n: The number of columns.

Symbols

NameDescription
*Matrix multiplication operator.
*=Matrix-scalar multiplication-assignment compound operator.
+Matrix addition operator.
+=Matrix addition-assignment compound operator.
-Matrix subtraction operator.
-=Matrix subtraction-assignment compound operator.
/Matrix-scalar division operator.
/=Matrix-scalar division-assignment compound operator.
=Matrix assignment operator.
[]Gets or sets the element at row inds[0] and column inds[1] of the RealSparseMatrix.

Members

NameDescription
blockGet a block (sub-RealSparseMatrix) of the RealSparseMatrix.
bottom_left_cornerGet the bottom-left corner of the RealSparseMatrix.
bottom_right_cornerGet the bottom-right corner of the RealSparseMatrix.
bottom_rowsGet the bottom rows of the RealSparseMatrix.
colGet a column of the RealSparseMatrix.
colsReturns the number of columns of a RealSparseMatrix.
compressTurns the RealSparseMatrix into the compressed format.
container_typeReturns the underlying container type of the RealSparseMatrix.
diagonalReturns the diagonal elements of the RealSparseMatrix as a column-vector.
insertInserts values into a sparse matrix.
is_approxReturns true if the RealSparseMatrix lhs is approximately equal to the RealSparseMatrix rhs, within the specified tolerance.
is_arrayWhether the container is an array (which supports elementwise operations).
is_boolWhether the underlying scalar type of the RealSparseMatrix is bool.
is_column_vectorReturns true if the container is a column-vector.
is_complexWhether the underlying scalar type of the RealSparseMatrix is complex.
is_compressedChecks if the RealSparseMatrix is in compressed format.
is_denseWhether the container is dense.
is_integerWhether the underlying scalar type of the RealSparseMatrix is integer.
is_matrixWhether the container is a matrix (which supports matrix algebra).
is_realWhether the underlying scalar type of the RealSparseMatrix is real.
is_row_vectorReturns true if the container is a row-vector.
is_scalarReturns true if the container is a scalar (or a container containing a single element).
is_sparseWhether the container is sparse.
is_vectorReturns true if the container is a vector.
left_colsGet the left columns of the RealSparseMatrix.
middle_colsGet the middle columns of the RealSparseMatrix.
middle_rowsGet the middle rows of the RealSparseMatrix.
nonzerosReturns the number of non-zero elements in the RealSparseMatrix.
prunePrunes the RealSparseMatrix lhs.
realReturns the real component of a RealSparseMatrix.
right_colsGet the right columns of the RealSparseMatrix.
rowGet a row of the RealSparseMatrix.
rowsReturns the number of rows of a RealSparseMatrix.
scalar_typeReturns the underlying scalar type of the RealSparseMatrix.
set_identitySets the RealSparseMatrix lhs to the identity matrix.
set_zeroSets all elements of the RealSparseMatrix lhs to 0.
shapeReturns the shape of a RealSparseMatrix.
sizeReturns the number of elements of a RealSparseMatrix.
top_left_cornerGet the top-left corner of the RealSparseMatrix.
top_right_cornerGet the top-right corner of the RealSparseMatrix.
top_rowsGet the top rows of the RealSparseMatrix.