3.10. Matrix properties

3.10.1. igraph_matrix_empty — Check for an empty matrix.
3.10.2. igraph_matrix_isnull — Check for a null matrix.
3.10.3. igraph_matrix_size — The number of elements in a matrix.
3.10.4. igraph_matrix_nrow — The number of rows in a matrix.
3.10.5. igraph_matrix_ncol — The number of columns in a matrix.
3.10.6. igraph_matrix_is_symmetric — Check for symmetric matrix.
3.10.7. igraph_matrix_is_equal — Are two matrices equal?
3.10.8. igraph_matrix_maxdifference — Maximum difference

3.10.1. igraph_matrix_empty — Check for an empty matrix.

igraph_bool_t igraph_matrix_empty(const igraph_matrix_t *m);

It is possible to have a matrix with zero rows or zero columns, or even both. This functions checks for these.

Arguments: 

m:

The input matrix.

Returns: 

Boolean, TRUE if the matrix contains zero elements, and FALSE otherwise.

Time complexity: O(1).

3.10.2. igraph_matrix_isnull — Check for a null matrix.

igraph_bool_t igraph_matrix_isnull(const igraph_matrix_t *m);

Checks whether all elements are zero.

Arguments: 

m:

The input matrix.

Returns: 

Boolean, TRUE is m contains only zeros and FALSE otherwise.

Time complexity: O(mn), the number of elements.

3.10.3. igraph_matrix_size — The number of elements in a matrix.

long int igraph_matrix_size(const igraph_matrix_t *m);

Arguments: 

m:

Pointer to an initialized matrix object.

Returns: 

The size of the matrix.

Time complexity: O(1).

3.10.4. igraph_matrix_nrow — The number of rows in a matrix.

long int igraph_matrix_nrow(const igraph_matrix_t *m);

Arguments: 

m:

Pointer to an initialized matrix object.

Returns: 

The number of rows in the matrix.

Time complexity: O(1).

3.10.5. igraph_matrix_ncol — The number of columns in a matrix.

long int igraph_matrix_ncol(const igraph_matrix_t *m);

Arguments: 

m:

Pointer to an initialized matrix object.

Returns: 

The number of columns in the matrix.

Time complexity: O(1).

3.10.6. igraph_matrix_is_symmetric — Check for symmetric matrix.

igraph_bool_t igraph_matrix_is_symmetric(const igraph_matrix_t *m);

A non-square matrix is not symmetric by definition.

Arguments: 

m:

The input matrix.

Returns: 

Boolean, TRUE if the matrix is square and symmetric, FALSE otherwise.

Time complexity: O(mn), the number of elements. O(1) for non-square matrices.

3.10.7. igraph_matrix_is_equal — Are two matrices equal?

igraph_bool_t igraph_matrix_is_equal(const igraph_matrix_t *m1, 
					      const igraph_matrix_t *m2);

Decides whether two matrices are equal. Two matrices are equal if they have the same size and contain exactly the same elements.

Arguments: 

m1:

The first matrix.

m2:

The second matrix.

Returns: 

TRUE if they are equal, FALSE otherwise.

Time complexity: O(1) if the sizes are different, O(mn) otherwise.

3.10.8. igraph_matrix_maxdifference — Maximum difference

igraph_real_t igraph_matrix_maxdifference(const igraph_matrix_t *m1,
					   const igraph_matrix_t *m2);

Calculate the maximum difference of two matrices. Both matrices must be non-empty. If their size differs then a warning is given and the comparision is performed by vectors columnwise from both matrices, columnwise, the remaining elements in the larger vector are ignored.

Arguments: 

m1:

The first matrix.

m2:

The second matrix.

Returns: 

The maximum of m1 - m2.

Time complexity: O(mn), the elements in the smaller matrix.