Prev | Next |
# include <cppad/utility/sparse_rc.hpp>
sparse_rc<SizeVector> empty
sparse_rc<SizeVector> pattern(nr, nc, nnz)
sparse_rc<SizeVector> pattern(other)
pattern = other
pattern.swap(other)
equal = pattern == other
.
resize(nr, nc, nnz)
pattern.set(k, r, c)
pattern.push_back(r, c)
pattern.set_row_major()
pattern.set_col_major()
pattern.nr()
pattern.nc()
pattern.nnz()
const SizeVector& row( pattern.row() )
const SizeVector& col( pattern.col() )
const SizeVector& row_major( pattern.get_row_major() )
const SizeVector& col_major( pattern.get_col_major() )
row_major = pattern.row_major()
col_major = pattern.col_major()
os << pattern
SizeVector
to denote SimpleVector
class
with elements of type
size_t
.
In addition,
SimpleVector
must support the swap
operation
between two of its vectors.
nr
,
number of columns
nc
,
and number of possibly non-zero values
nnz
,
are all zero.
pattern
is const
except during its constructor, resize
, and set
.
other
has prototype
const sparse_rc<SizeVector>& other
After the assignment and constructor,
pattern
is an independent copy
of
other
; i.e. it has all the same values as
other
and changes to
pattern
do not affect
other
.
other
has prototype
sparse_rc<SizeVector>&& other
A move semantics version of the assignment or constructor is used; e.g.,
when
other
is a function return value.
other
has prototype
sparse_rc<SizeVector>& other
After the swap operation
other
(
pattern
) is equivalent
to
pattern
(
other
) before the operation.
other
has prototype
const sparse_rc<SizeVector>& other
The two sparsity patterns are equal if the following conditions hold:
pattern.nr()
and
other.nr()
are equal.
pattern.nc()
and
other.nc()
are equal.
pattern.nnz()
and
other.nnz()
are equal.
pattern
and
other
, are equal.
size_t nr
It specifies the number of rows in the sparsity pattern.
The function call nr()
returns the value of
nr
.
size_t nc
It specifies the number of columns in the sparsity pattern.
The function call nc()
returns the value of
nc
.
size_t nnz
It specifies the number of possibly non-zero
index pairs in the sparsity pattern.
The function call nnz()
returns the value of
nnz
.
row
and
col
vectors should be assigned using set
.
row[k] = r
col[k] = c
r
to the back of
row
,
the value
c
to the back of
col
,
and increases
nnz
by one.
This operation requires
SizeVector
to support the
push_back
operation
(which is not part of the SimpleVector requirements).
size_t k
and must be less than
nnz
.
size_t r
It specifies the value assigned to
row[k]
and must
be less than
nr
.
size_t c
It specifies the value assigned to
col[k]
and must
be less than
nc
.
nnz
and
row[k]
is the row index of the k
-th possibly non-zero
index pair in the sparsity pattern.
nnz
and
col[k]
is the column index of the k
-th possibly non-zero
index pair in the sparsity pattern.
SizeVector row_major
and its size
nnz
.
It sorts the sparsity pattern in row-major order.
To be specific,
col[ row_major[k] ] <= col[ row_major[k+1] ]
and if
col[ row_major[k] ] == col[ row_major[k+1] ]
,
row[ row_major[k] ] < row[ row_major[k+1] ]
This routine generates an assert if there are two entries with the same
row and column values (if NDEBUG
is not defined).
pattern
.
This can be used by the row_major function and the equality function
to avoid re-sorting the pattern each time.
pattern
by the previous set_row_major
.
If this order is no longer valid, the return value
row_major
has size zero.
SizeVector col_major
and its size
nnz
.
It sorts the sparsity pattern in column-major order.
To be specific,
row[ col_major[k] ] <= row[ col_major[k+1] ]
and if
row[ col_major[k] ] == row[ col_major[k+1] ]
,
col[ col_major[k] ] < col[ col_major[k+1] ]
This routine generates an assert if there are two entries with the same
row and column values (if NDEBUG
is not defined).
pattern
.
This can be used by the col_major function and the equality function
to avoid re-sorting the pattern each time.
pattern
by the previous set_col_major
.
If this order is no longer valid, the return value
col_major
has size zero.
os
is an std::ostream
, the operation
os << pattern
outputs
pattern
to the
os
stream.
The output begins with a left brace {
and ends with a right brace }
.
The output is in row major order and has one line for each row.
The row index is output at the beginning of a line
and the column indices follow.