CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cppad_colpack.hpp
Go to the documentation of this file.
1 // $Id: cppad_colpack.hpp 3845 2016-11-19 01:50:47Z bradbell $
2 /* --------------------------------------------------------------------------
3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
4 
5 CppAD is distributed under multiple licenses. This distribution is under
6 the terms of the
7  Eclipse Public License Version 1.0.
8 
9 A copy of this license is included in the COPYING file of this distribution.
10 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11 -------------------------------------------------------------------------- */
12 # ifndef CPPAD_LOCAL_CPPAD_COLPACK_HPP
13 # define CPPAD_LOCAL_CPPAD_COLPACK_HPP
14 # if CPPAD_HAS_COLPACK
15 
16 namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE
17 /*!
18 \file cppad_colpack.hpp
19 External interface to Colpack routines used by cppad.
20 */
21 // ---------------------------------------------------------------------------
22 /*!
23 Link from CppAD to ColPack used for general sparse matrices.
24 
25 This CppAD library routine is necessary because
26 <code>ColPack/ColPackHeaders.h</code> has a
27 <code>using namespace std</code> at the global level.
28 
29 \param m [in]
30 is the number of rows in the sparse matrix
31 
32 \param n [in]
33 is the nubmer of columns in the sparse matrix.
34 
35 \param adolc_pattern [in]
36 This vector has size \c m,
37 <code>adolc_pattern[i][0]</code> is the number of non-zeros in row \c i.
38 For <code>j = 1 , ... , adolc_sparsity[i]<code>,
39 <code>adolc_pattern[i][j]</code> is the column index (base zero) for the
40 non-zeros in row \c i.
41 
42 \param color [out]
43 is a vector with size \c m.
44 The input value of its elements does not matter.
45 Upon return, it is a coloring for the rows of the sparse matrix.
46 \n
47 \n
48 If for some \c i, <code>color[i] == m</code>, then
49 <code>adolc_pattern[i][0] == 0</code>.
50 Otherwise, <code>color[i] < m</code>.
51 \n
52 \n
53 Suppose two differen rows, <code>i != r</code> have the same color.
54 It follows that for all column indices \c j;
55 it is not the case that both
56 <code>(i, j)</code> and <code>(r, j)</code> appear in the sparsity pattern.
57 \n
58 \n
59 This routine tries to minimize, with respect to the choice of colors,
60 the number of colors.
61 */
62 extern void cppad_colpack_general(
63  CppAD::vector<size_t>& color ,
64  size_t m ,
65  size_t n ,
66  const CppAD::vector<unsigned int*>& adolc_pattern
67 );
68 
69 /*!
70 Link from CppAD to ColPack used for symmetric sparse matrices
71 (not yet used or tested).
72 
73 This CppAD library routine is necessary because
74 <code>ColPack/ColPackHeaders.h</code> has a
75 <code>using namespace std</code> at the global level.
76 
77 \param n [in]
78 is the nubmer of rows and columns in the symmetric sparse matrix.
79 
80 \param adolc_pattern [in]
81 This vector has size \c n,
82 <code>adolc_pattern[i][0]</code> is the number of non-zeros in row \c i.
83 For <code>j = 1 , ... , adolc_sparsity[i]<code>,
84 <code>adolc_pattern[i][j]</code> is the column index (base zero) for the
85 non-zeros in row \c i.
86 
87 \param color [out]
88 The input value of its elements does not matter.
89 Upon return, it is a coloring for the rows of the sparse matrix.
90 The properties of this coloring have not yet been determined; see
91 Efficient Computation of Sparse Hessians Using Coloring
92 and Automatic Differentiation (pdf/ad/gebemedhin14.pdf)
93 */
94 extern void cppad_colpack_symmetric(
95  CppAD::vector<size_t>& color ,
96  size_t n ,
97  const CppAD::vector<unsigned int*>& adolc_pattern
98 );
99 
100 } } // END_CPPAD_LOCAL_NAMESPACE
101 
102 # endif
103 # endif
104