| igraph Reference Manual |
|---|
igraph_matrix_add_constant — Add a constant to every element.igraph_matrix_scale — Multiplies each element of the matrix by a constant.igraph_matrix_add — Add two matrices.igraph_matrix_sub — Difference of two matrices.igraph_matrix_mul_elements — Elementwise multiplication.igraph_matrix_div_elements — Elementwise division.igraph_matrix_sum — Sum of elementsigraph_matrix_prod — Product of the elements.igraph_matrix_rowsum — Rowwise sumigraph_matrix_colsum — Columnise sumigraph_matrix_transpose — Transpose
void igraph_matrix_add_constant(igraph_matrix_t *m, igraph_real_t plus);
Arguments:
|
The input matrix. |
|
The constant to add. |
Time complexity: O(mn), the number of elements.
void igraph_matrix_scale(igraph_matrix_t *m, igraph_real_t by);
Arguments:
|
The matrix. |
|
The constant. |
Added in version 0.2.
Time complexity: O(n), the number of elements in the matrix.
int igraph_matrix_add(igraph_matrix_t *m1, const igraph_matrix_t *m2);
Add m2 to m1, and store the result in m1. The size of the
matrices must match.
Arguments:
|
The first matrix, the result will be stored here. |
|
The second matrix, it is left unchanged. |
Returns:
Error code. |
Time complexity: O(mn), the number of elements.
int igraph_matrix_sub(igraph_matrix_t *m1, const igraph_matrix_t *m2);
Subtract m2 from m1 and store the result in m1.
The size of the two matrices must match.
Arguments:
|
The first matrix, the result is stored here. |
|
The second matrix, it is left unchanged. |
Returns:
Error code. |
Time complexity: O(mn), the number of elements.
int igraph_matrix_mul_elements(igraph_matrix_t *m1, const igraph_matrix_t *m2);
Multiply m1 by m2 elementwise and store the result in m1.
The size of the two matrices must match.
Arguments:
|
The first matrix, the result is stored here. |
|
The second matrix, it is left unchanged. |
Returns:
Error code. |
Time complexity: O(mn), the number of elements.
int igraph_matrix_div_elements(igraph_matrix_t *m1, const igraph_matrix_t *m2);
Divide m1 by m2 elementwise and store the result in m1.
The size of the two matrices must match.
Arguments:
|
The divident. The result is store here. |
|
The divisor. It is left unchanged. |
Returns:
Error code. |
Time complexity: O(mn), the number of elements.
igraph_real_t igraph_matrix_sum(const igraph_matrix_t *m);
Returns the sum of the elements of a matrix.
Arguments:
|
The input matrix. |
Returns:
The sum of the elements. |
Time complexity: O(mn), the number of elements in the matrix.
igraph_real_t igraph_matrix_prod(const igraph_matrix_t *m);
Note this function can result an overflow easily, even for not too big matrices.
Arguments:
|
input matrix. |
Returns:
The product of the elements. |
Time complexity: O(mn), the number of elements.
int igraph_matrix_rowsum(const igraph_matrix_t *m, igraph_vector_t *res);
Calculate the sum of the elements in each row.
Arguments:
|
The input matrix. |
|
Pointer to an initialized vector, the result is stored here. It will be resized if necessary. |
Returns:
Error code. |
Time complexity: O(mn), the number of elements in the matrix.
int igraph_matrix_colsum(const igraph_matrix_t *m, igraph_vector_t *res);
Calculate the sum of the elements in each column.
Arguments:
|
The input matrix. |
|
Pointer to an initialized vector, the result is stored here. It will be resized if necessary. |
Returns:
Error code. |
Time complexity: O(mn), the number of elements in the matrix.
| << 3.6. Operations on rows and columns | 3.8. Combining matrices >> |