### 4.5. Matrix operations

4.5.1. `igraph_spmatrix_scale` — Multiplies each element of the sparse matrix by a constant.
4.5.2. `igraph_spmatrix_add_rows` — Adds rows to a sparse matrix.
4.5.3. `igraph_spmatrix_add_cols` — Adds columns to a sparse matrix.
4.5.4. `igraph_spmatrix_resize` — Resizes a sparse matrix.

#### 4.5.1. `igraph_spmatrix_scale` — Multiplies each element of the sparse matrix by a constant.

```void igraph_spmatrix_scale(igraph_spmatrix_t *m, igraph_real_t by);
```

Arguments:

 `m`: The matrix. `by`: The constant.

Time complexity: O(n), the number of elements in the matrix.

#### 4.5.2. `igraph_spmatrix_add_rows` — Adds rows to a sparse matrix.

```int igraph_spmatrix_add_rows(igraph_spmatrix_t *m, long int n);
```

Arguments:

 `m`: The sparse matrix object. `n`: The number of rows to add.

Returns:

 Error code.

Time complexity: O(1).

#### 4.5.3. `igraph_spmatrix_add_cols` — Adds columns to a sparse matrix.

```int igraph_spmatrix_add_cols(igraph_spmatrix_t *m, long int n);
```

Arguments:

 `m`: The sparse matrix object. `n`: The number of columns to add.

Returns:

 Error code.

Time complexity: O(1).

#### 4.5.4. `igraph_spmatrix_resize` — Resizes a sparse matrix.

```int igraph_spmatrix_resize(igraph_spmatrix_t *m, long int nrow, long int ncol);
```

This function resizes a sparse matrix by adding more elements to it. The matrix retains its data even after resizing it, except for the data which lies outside the new boundaries (if the new size is smaller).

Arguments:

 `m`: Pointer to an already initialized sparse matrix object. `nrow`: The number of rows in the resized matrix. `ncol`: The number of columns in the resized matrix.

Returns:

 Error code.

Time complexity: O(n). n is the number of elements in the old matrix.