# SparsityPattern¶

class dolfin.cpp.la.SparsityPattern(*args)

Bases: object

This class implements a sparsity pattern data structure. It is used by most linear algebra backends.

• SparsityPattern(primary_dim)

Create empty sparsity pattern

• SparsityPattern(mpi_comm, index_maps, primary_dim)

Create sparsity pattern for a generic tensor

Type_sorted = 0
Type_unsorted = 1
apply()

Finalize sparsity pattern

init()

Initialize sparsity pattern for a generic tensor

insert_full_rows_local()

Insert full rows (or columns, according to primary dimension) using local (process-wise) indices. This must be called before any other sparse insertion occurs to avoid quadratic complexity of dense rows insertion

insert_global()

• insert_global(i, j)

Insert a global entry - will be fixed by apply()

• insert_global(entries)

Insert non-zero entries using global indices

insert_local()

Insert non-zero entries using local (process-wise) indices

local_range()

Return local range for dimension dim

mpi_comm()
num_local_nonzeros()

Fill vector with number of nonzeros in local_range for dimension 0

num_nonzeros()

Return number of local nonzeros

num_nonzeros_diagonal()

Fill array with number of nonzeros for diagonal block in local_range for dimension 0. For matrices, fill array with number of nonzeros per local row for diagonal block

num_nonzeros_off_diagonal()

Fill array with number of nonzeros for off-diagonal block in local_range for dimension 0. For matrices, fill array with number of nonzeros per local row for off-diagonal block. If there is no off-diagonal pattern, the vector is resized to zero-length

primary_dim()

Return primary dimension (e.g., 0=row partition, 1=column partition)

rank()

Return rank

str()

Return informal string representation (pretty-print)

thisown

The membership flag