| igraph Reference Manual |
|---|
igraph_matrix_get_row — Extract a rowigraph_matrix_get_col — Select a columnigraph_matrix_set_row — Set a row from a vector.igraph_matrix_set_col — Set a column from a vector.igraph_matrix_swap_rows — Swap two rowsigraph_matrix_swap_cols — Swap two columnsigraph_matrix_select_rows — Select some rows of a matrixigraph_matrix_select_cols — Select some columns of a matrix
int igraph_matrix_get_row(const igraph_matrix_t *m, igraph_vector_t *res, long int index);
Extract a row from a matrix and return it as a vector.
Arguments:
m: |
The input matrix. |
res: |
Pointer to an initialized vector, it will be resized if needed. |
index: |
The index of the row to select. |
Returns:
|
Error code. |
Time complexity: O(n), the number of columns in the matrix.
int igraph_matrix_get_col(const igraph_matrix_t *m, igraph_vector_t *res, long int index);
Extract a column of a matrix and return it in a vector.
Arguments:
m: |
The input matrix. |
res: |
The result will we stored in this vector. It should be initialized and will be resized as needed. |
index: |
The index of the solumn to select. |
Returns:
|
Error code. |
Time complexity: O(n), the number of rows in the matrix.
int igraph_matrix_set_row(igraph_matrix_t *m, const igraph_vector_t *v, long int index);
Sets the elements of a row, from the given vector. The length of the vector and the number of columns in the matrix must match, otherwise and error is triggered.
Arguments:
m: |
The input matrix. |
v: |
The vector containing the new elements of the row. |
index: |
Index of the row to set. |
Returns:
|
Error code. |
Time complexity: O(n), the number of columns in the matrix.
int igraph_matrix_set_col(igraph_matrix_t *m, const igraph_vector_t *v, long int index);
Sets the elements of a column, from the given vector. The length of the vector and the number of rows in the matrix must match, otherwise and error is triggered.
Arguments:
m: |
The input matrix. |
v: |
The vector containing the new elements of the column. |
index: |
Index of the column to set. |
Returns:
|
Error code. |
Time complexity: O(m), the number of rows in the matrix.
int igraph_matrix_swap_rows(igraph_matrix_t *m, long int i, long int j);
Swap two rows in the matrix.
Arguments:
m: |
The input matrix. |
i: |
The index of the first row. |
j: |
The index of the second row. |
Returns:
|
Error code. |
Time complexity: O(n), the number of columns.
int igraph_matrix_swap_cols(igraph_matrix_t *m, long int i, long int j);
Swap two columns in the matrix.
Arguments:
m: |
The input matrix. |
i: |
The index of the first column. |
j: |
The index of the second column. |
Returns:
|
Error code. |
Time complexity: O(m), the number of rows.
int igraph_matrix_select_rows(const igraph_matrix_t *m, igraph_matrix_t *res, const igraph_vector_t *rows);
This function selects some rows of a matrix and returns them in a new matrix. The result matrix should be initialized before calling the function.
Arguments:
m: |
The input matrix. |
res: |
The result matrix. It should be initialized and will be resized as needed. |
rows: |
Vector, it contains the row indices (starting with zero) to extract. Note that no range checking is performed. |
Returns:
|
Error code. |
Time complexity: O(nm), n is the number of rows, m the number of columns of the result matrix.
int igraph_matrix_select_cols(const igraph_matrix_t *m, igraph_matrix_t *res, const igraph_vector_t *cols);
This function selects some columns of a matrix and returns them in a new matrix. The result matrix should be initialized before calling the function.
Arguments:
m: |
The input matrix. |
res: |
The result matrix. It should be initialized and will be resized as needed. |
cols: |
Vector, it contains the column indices (starting with zero) to extract. Note that no range checking is performed. |
Returns:
|
Error code. |
Time complexity: O(nm), n is the number of rows, m the number of columns of the result matrix.
| << 3.5. Accessing elements of a matrix | 3.7. Matrix operations >> |