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
86 template <class T> class SparseDiffRep {
87 public:
88 //# Typedefs
89 typedef T value_type;
93 typedef const value_type* const_iterator;
94
95 //# Constructors
96 // Construct a constant with a value of zero. Zero derivatives.
98
99 //# Operators
100 // Assignment operators
101 // <group>
103 SparseDiffRep<T> &operator=(const vector<pair<uInt, T> > &grad);
105 void operator*=(const T other);
106 void operator/=(const T other);
107 void operator+=(const T other);
108 void operator-=(const T other);
109 // </group>
110
111 //# Member functions
112
113 // Clear for reuse
114 void clear() { grad_p.clear(); }
115
116 //# Data
117 // The function value
119 // The derivatives
120 vector<pair<uInt, T> > grad_p;
121 // Link to indicate its status (1=linked in stack; 2=used in modules)
123 };
124
125
126} //# NAMESPACE CASACORE - END
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)
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49