CppAD: A C++ Algorithmic Differentiation Package  20130918
template<class VectorSet , class VectorSize >
void CppAD::color_general_cppad ( VectorSet &  pattern,
const VectorSize &  row,
const VectorSize &  col,
CppAD::vector< size_t > &  color 
)

Determine which rows of a general sparse matrix can be computed together; i.e., do not have non-zero overlapping values.

Template Parameters:
VectorSizeis a simple vector class with elements of type size_t.
VectorSetis an unspecified type with the exception that it must support the operations under pattern and the following operations where p is a VectorSet object:
VectorSet p Constructs a new vector of sets object.
p.resize(ns, ne) resizes to ns sets with elements between zero ne. All of the ns sets are initially empty.
p.add_element(s, e) add element e to set with index s.
Parameters:
pattern[in] Is a representation of the sparsity pattern for the matrix. Note that color_general does not change the values in pattern, but it is not const because its iterator facility modifies some of its internal data.
m = pattern.n_set()
sets m to the number of rows in the sparse matrix. All of the row indices are less than this value.
n = pattern.end()
sets n to the number of columns in the sparse matrix. All of the column indices are less than this value.
pattern.begin(i) instructs the iterator facility to start iterating over columns in the i-th row of the sparsity pattern.
j = pattern.next_element() Sets j to the next possibly non-zero column in the row specified by the previous call to pattern.begin. If there are no more such columns, the value pattern.end() is returned.
row[in] is a vector specifying which row indices to compute.
col[in] is a vector, with the same size as row, that specifies which column indices to compute. For each valid index k, the index pair (row[k], col[k]) must be present in the sparsity pattern. It may be that some entries in the sparsity pattern do not need to be computed; i.e, do not appear in the set of (row[k], col[k]) entries.
color[out] is a vector with size m. The input value of its elements does not matter. Upon return, it is a coloring for the rows of the sparse matrix.

If for come i, color[i] == m, then the i-th row does not appear in the vector row. Otherwise, color[i] < m.

Suppose two differen rows, i != r have the same color and column index j is such that both of the pairs (i, j) and (r, j) appear in the sparsity pattern. It follows that neither of these pairs appear in the set of (row[k], col[k]) entries.

This routine tries to minimize, with respect to the choice of colors, the maximum, with respct to k, of color[ row[k] ].

Definition at line 105 of file color_general.hpp.

Referenced by CppAD::ADFun< Base >::SparseHessianCompute(), CppAD::ADFun< Base >::SparseJacobianFor(), and CppAD::ADFun< Base >::SparseJacobianRev().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines