casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef SCIMATH_SPARSEDIFFREP_H
27#define SCIMATH_SPARSEDIFFREP_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/vector.h>
32#include <utility>
33
34// Using
35using std::pair;
36
37namespace casacore { // # NAMESPACE CASACORE - BEGIN
38
39// # Forward declarations
40
41// <summary>
42// Representation of data for the spare automatic differentiation calss.
43// </summary>
44//
45// <use visibility=local>
46//
47// <reviewed reviewer="UNKNOWN" date="" tests="tSparseDiff.cc" demos="">
48// </reviewed>
49//
50// <prerequisite>
51// <li> <linkto class=SparseDiff>SparseDiff</linkto>
52// </prerequisite>
53//
54// <etymology>
55// Class that represents partial derivatives obtained by automatic
56// differentiation.
57// </etymology>
58//
59// <synopsis>
60// Class representing
61// the data necessary for automatic differentiation. The structure contains a
62// value, and the derivatives of the value with respect to a number of
63// dependent variables.
64//
65// The actual differentiation and access is done through the
66// <linkto class=SparseDiff>SparseDiff</linkto> class.
67//
68// <example>
69// See the example in <linkto class=SparseDiff>SparseDiff</linkto>
70// </example>
71//
72// <motivation>
73// To separate the data container from the actual calculations.
74// To be able to create special conatiners; constructors and destructors
75// (including memory allocation) to speed up processes.
76//
77// <templating arg=T>
78// <li> any class that has the standard mathematical and comparison
79// operators defined
80// </templating>
81//
82// <todo asof="2007/11/27">
83// <li> Nothing I know of
84// </todo>
85
86template <class T>
88 public:
89 // # Typedefs
90 typedef T value_type;
94 typedef const value_type *const_iterator;
95
96 // # Constructors
97 // Construct a constant with a value of zero. Zero derivatives.
99
100 // # Operators
101 // Assignment operators
102 // <group>
104 SparseDiffRep<T> &operator=(const vector<pair<uInt, T>> &grad);
106 void operator*=(const T other);
107 void operator/=(const T other);
108 void operator+=(const T other);
109 void operator-=(const T other);
110 // </group>
111
112 // # Member functions
113
114 // Clear for reuse
115 void clear() { grad_p.clear(); }
116
117 // # Data
118 // The function value
120 // The derivatives
121 vector<pair<uInt, T>> grad_p;
122 // Link to indicate its status (1=linked in stack; 2=used in modules)
124};
125
126} // namespace casacore
127
128#ifndef CASACORE_NO_AUTO_TEMPLATES
129#include <casacore/scimath/Mathematics/SparseDiffRep.tcc>
130#endif // # CASACORE_NO_AUTO_TEMPLATES
131#endif
uInt link_p
Link to indicate its status (1=linked in stack; 2=used in modules).
void clear()
Clear for reuse.
SparseDiffRep< T > & operator=(const SparseDiffRep< T > &other)
vector< pair< uInt, T > > grad_p
The derivatives.
void operator*=(const T other)
const value_type * const_iterator
SparseDiffRep()
Construct a constant with a value of zero.
void operator-=(const T other)
void operator/=(const T other)
const value_type & const_reference
SparseDiffRep< T > & operator=(const T &v)
Assignment operators.
SparseDiffRep< T > & operator=(const vector< pair< uInt, T > > &grad)
T val_p
The function value.
void operator+=(const T other)
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49