### 4.3.  Accessing elements of a sparse matrix

4.3.1. `igraph_spmatrix_e` — Accessing an element of a sparse matrix.
4.3.2. `igraph_spmatrix_set` — Setting an element of a sparse matrix.
4.3.3. `igraph_spmatrix_add_e` — Adding a real value to an element of a sparse matrix.

#### 4.3.1. `igraph_spmatrix_e` — Accessing an element of a sparse matrix.

```igraph_real_t igraph_spmatrix_e(const igraph_spmatrix_t *m,
long int row, long int col);
```

Note that there are no range checks right now.

Arguments:

 `m`: The matrix object. `row`: The index of the row, starting with zero. `col`: The index of the column, starting with zero.

Time complexity: O(log n), where n is the number of nonzero elements in the requested column.

#### 4.3.2. `igraph_spmatrix_set` — Setting an element of a sparse matrix.

```int igraph_spmatrix_set(igraph_spmatrix_t *m, long int row, long int col,
igraph_real_t value);
```

Note that there are no range checks right now.

Arguments:

 `m`: The matrix object. `row`: The index of the row, starting with zero. `col`: The index of the column, starting with zero. `value`: The new value.

Time complexity: O(log n), where n is the number of nonzero elements in the requested column.

#### 4.3.3. `igraph_spmatrix_add_e` — Adding a real value to an element of a sparse matrix.

```int igraph_spmatrix_add_e(igraph_spmatrix_t *m, long int row, long int col,
igraph_real_t value);
```

Note that there are no range checks right now. This is implemented to avoid double lookup of a given element in the matrix by using `igraph_spmatrix_e()` and `igraph_spmatrix_set()` consecutively.

Arguments:

 `m`: The matrix object. `row`: The index of the row, starting with zero. `col`: The index of the column, starting with zero. `value`: The value to add.

Time complexity: O(log n), where n is the number of nonzero elements in the requested column.