casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseDiffRep.h
Go to the documentation of this file.
1 //# SparseDiffRep.h: Representation of an automatic differential class data
2 //# Copyright (C) 2007
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id: SparseDiffRep.h,v 1.1 2007/11/16 04:34:46 wbrouw Exp $
28 
29 #ifndef SCIMATH_SPARSEDIFFREP_H
30 #define SCIMATH_SPARSEDIFFREP_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/vector.h>
35 #include <utility>
36 
37 // Using
38 using std::pair;
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42  //# Forward declarations
43 
44  // <summary>
45  // Representation of data for the spare automatic differentiation calss.
46  // </summary>
47  //
48  // <use visibility=local>
49  //
50  // <reviewed reviewer="UNKNOWN" date="" tests="tSparseDiff.cc" demos="">
51  // </reviewed>
52  //
53  // <prerequisite>
54  // <li> <linkto class=SparseDiff>SparseDiff</linkto>
55  // </prerequisite>
56  //
57  // <etymology>
58  // Class that represents partial derivatives obtained by automatic
59  // differentiation.
60  // </etymology>
61  //
62  // <synopsis>
63  // Class representing
64  // the data necessary for automatic differentiation. The structure contains a
65  // value, and the derivatives of the value with respect to a number of
66  // dependent variables.
67  //
68  // The actual differentiation and access is done through the
69  // <linkto class=SparseDiff>SparseDiff</linkto> class.
70  //
71  // <example>
72  // See the example in <linkto class=SparseDiff>SparseDiff</linkto>
73  // </example>
74  //
75  // <motivation>
76  // To separate the data container from the actual calculations.
77  // To be able to create special conatiners; constructors and destructors
78  // (including memory allocation) to speed up processes.
79  //
80  // <templating arg=T>
81  // <li> any class that has the standard mathematical and comparison
82  // operators defined
83  // </templating>
84  //
85  // <todo asof="2007/11/27">
86  // <li> Nothing I know of
87  // </todo>
88 
89  template <class T> class SparseDiffRep {
90  public:
91  //# Typedefs
92  typedef T value_type;
94  typedef const value_type& const_reference;
95  typedef value_type* iterator;
96  typedef const value_type* const_iterator;
97 
98  //# Constructors
99  // Construct a constant with a value of zero. Zero derivatives.
100  SparseDiffRep();
101 
102  //# Operators
103  // Assignment operators
104  // <group>
105  SparseDiffRep<T> &operator=(const T &v);
106  SparseDiffRep<T> &operator=(const vector<pair<uInt, T> > &grad);
108  void operator*=(const T other);
109  void operator/=(const T other);
110  void operator+=(const T other);
111  void operator-=(const T other);
112  // </group>
113 
114  //# Member functions
115 
116  // Clear for reuse
117  void clear() { grad_p.clear(); }
118 
119  //# Data
120  // The function value
121  T val_p;
122  // The derivatives
123  vector<pair<uInt, T> > grad_p;
124  // Link to indicate its status (1=linked in stack; 2=used in modules)
126  };
127 
128 
129 } //# NAMESPACE CASACORE - END
130 
131 #ifndef CASACORE_NO_AUTO_TEMPLATES
132 #include <casacore/scimath/Mathematics/SparseDiffRep.tcc>
133 #endif //# CASACORE_NO_AUTO_TEMPLATES
134 #endif
void operator+=(const T other)
SparseDiffRep< T > & operator=(const T &v)
Assignment operators.
SparseDiffRep()
Construct a constant with a value of zero.
const value_type & const_reference
Definition: SparseDiffRep.h:94
uInt link_p
Link to indicate its status (1=linked in stack; 2=used in modules)
void clear()
Clear for reuse.
Representation of data for the spare automatic differentiation calss.
Definition: SparseDiffRep.h:89
const value_type * const_iterator
Definition: SparseDiffRep.h:96
void operator-=(const T other)
void operator/=(const T other)
T val_p
The function value.
void operator*=(const T other)
vector< pair< uInt, T > > grad_p
The derivatives.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42