Prev Next Index-> contents reference index search external Up-> CppAD utility sparse_rc CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix utility-> ErrorHandler NearEqual speed_test SpeedTest time_test test_boolofvoid NumericType CheckNumericType SimpleVector CheckSimpleVector nan pow_int Poly LuDetAndSolve RombergOne RombergMul Runge45 Rosen34 OdeErrControl OdeGear OdeGearControl CppAD_vector thread_alloc index_sort to_string set_union sparse_rc sparse_rcv sparse_rc-> sparse_rc.cpp Headings-> Syntax SizeVector empty pattern target nr nc nnz resize set ---..k ---..r ---..c row col row_major col_major Example

Row and Column Index Sparsity Patterns

Syntax
# include <cppad/utility/sparse_rc.hpp>  sparse_rc<SizeVector>  empty  sparse_rc<SizeVector>  pattern(nr, nc, nnz)  target = pattern  resize(nr, nc, nnz)  pattern.set(k, r, c)  pattern.nr()  pattern.nc()  pattern.nnz()  const SizeVector& row( pattern.row() )  const SizeVector& col( pattern.col() )  row_major = pattern.row_major()  col_major = pattern.col_major() 
SizeVector
We use SizeVector to denote SimpleVector class with elements of type size_t.

empty
This is an empty sparsity pattern. To be specific, the corresponding number of rows nr , number of columns nc , and number of possibly non-zero values nnz , are all zero.

pattern
This object is used to hold a sparsity pattern for a matrix. The sparsity pattern is const except during its constructor, resize, and set.

target
The target of the assignment statement must have prototype       sparse_rc<SizeVector>  target  After this assignment statement, target is an independent copy of pattern ; i.e. it has all the same values as pattern and changes to target do not affect pattern .

nr
This argument has prototype       size_t nr  It specifies the number of rows in the sparsity pattern. The function call nr() returns the value of nr .

nc
This argument has prototype       size_t nc  It specifies the number of columns in the sparsity pattern. The function call nc() returns the value of nc .

nnz
This argument has prototype       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 .

resize
The current sparsity pattern is lost and a new one is started with the specified parameters. The elements in the row and col vectors should be assigned using set.

set
This function sets the values       row[k] = r      col[k] = c 
k
This argument has type       size_t k  and must be less than nnz .

r
This argument has type       size_t r  It specifies the value assigned to row[k] and must be less than nr .

c
This argument has type       size_t c  It specifies the value assigned to col[k] and must be less than nc .

row
This vector has size nnz and row[k] is the row index of the k-th possibly non-zero index pair in the sparsity pattern.

col
This vector has size nnz and col[k] is the column index of the k-th possibly non-zero index pair in the sparsity pattern.

row_major
This vector has prototype       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).

col_major
This vector has prototype       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).

Example
The file sparse_rc.cpp contains an example and test of this class. It returns true if it succeeds and false otherwise.