1 #ifndef _FMATVEC_FUNCTION_H_ 2 #define _FMATVEC_FUNCTION_H_ 4 #include <fmatvec/fmatvec.h> 5 #include <fmatvec/atom.h> 14 #if !defined(SWIG) && !defined(MBSIM_COMPILE_SWIG) 20 throw std::runtime_error(
"Impossible type.");
35 enum { size1=1, size2=1 };
41 enum { size1=1, size2=1 };
45 template<
typename Shape,
typename AT>
47 enum { size1=0, size2=1 };
51 template<
typename Shape,
typename AT>
53 enum { size1=1, size2=0 };
57 template<
int N,
typename AT>
59 enum { size1=N, size2=1 };
63 template<
int N,
typename AT>
65 enum { size1=1, size2=N };
69 template<
typename Storage,
typename RowShape,
typename ColShape,
typename AT>
71 enum { size1=0, size2=0 };
75 template<
typename Storage,
int N,
int M,
typename AT>
77 enum { size1=N, size2=M };
81 template<
typename Storage,
int N,
typename ColShape,
typename AT>
83 enum { size1=N, size2=0 };
87 template<
typename Storage,
typename RowShape,
int M,
typename AT>
89 enum { size1=0, size2=M };
93 template<
int N,
typename AT>
95 enum { size1=N, size2=N };
99 template<
typename Shape,
typename AT>
101 enum { size1=0, size2=0 };
107 template<
typename Dep,
typename Indep>
115 template<
typename Dep>
125 template<
typename IndepVecShape>
135 template<
typename DepVecShape,
typename IndepVecShape>
169 template<
typename IndepVecShape>
177 template<
typename Dep,
typename Indep>
185 template<
typename Indep>
200 template<
typename Sig>
204 template<
typename Ret,
typename Arg>
210 using DRetDDir =
typename DirDer<Ret, Arg>::type;
220 virtual std::pair<int, int>
getRetSize()
const {
return std::make_pair(retSize1, retSize2); }
226 virtual Ret operator()(
const Arg &arg)=0;
229 virtual DRetDArg
parDer(
const Arg &arg) {
230 throw std::runtime_error(
"parDer must be overloaded by derived class.");
234 virtual DRetDDir
dirDer(
const Arg &argDir,
const Arg &arg) {
235 throw std::runtime_error(
"dirDer must be overloaded by derived class.");
240 throw std::runtime_error(
"parDerParDer must be overloaded by derived class.");
245 throw std::runtime_error(
"parDerDirDer must be overloaded by derived class.");
249 virtual DRetDDir
dirDerDirDer(
const Arg &argDir_1,
const Arg &argDir_2,
const Arg &arg) {
250 throw std::runtime_error(
"dirDerDirDer must be overloaded by derived class.");
259 template<
typename Ret,
typename Arg1,
typename Arg2>
265 using DRetDDir1 =
typename DirDer<Ret, Arg1>::type;
266 using DRetDDir2 =
typename DirDer<Ret, Arg2>::type;
281 virtual std::pair<int, int>
getRetSize()
const {
return std::make_pair(retSize1, retSize2); }
289 virtual Ret operator()(
const Arg1 &arg1,
const Arg2 &arg2)=0;
292 virtual DRetDArg1
parDer1(
const Arg1 &arg1,
const Arg2 &arg2) {
293 throw std::runtime_error(
"parDer1 must be overloaded by derived class.");
297 virtual DRetDDir1
dirDer1(
const Arg1 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
298 throw std::runtime_error(
"dirDer1 must be overloaded by derived class.");
302 virtual DRetDArg2
parDer2(
const Arg1 &arg1,
const Arg2 &arg2) {
303 throw std::runtime_error(
"parDer2 must be overloaded by derived class.");
307 virtual DRetDDir2
dirDer2(
const Arg2 &arg2Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
308 throw std::runtime_error(
"dirDer2 must be overloaded by derived class.");
313 throw std::runtime_error(
"parDer1ParDer1 must be overloaded by derived class.");
317 virtual DRetDArg1
parDer1DirDer1(
const Arg1 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
318 throw std::runtime_error(
"parDer1DirDer1 must be overloaded by derived class.");
322 virtual DRetDDir1
dirDer1DirDer1(
const Arg1 &arg1Dir_1,
const Arg1 &arg1Dir_2,
const Arg1 &arg1,
const Arg2 &arg2) {
323 throw std::runtime_error(
"dirDer1DirDer1 must be overloaded by derived class.");
328 throw std::runtime_error(
"parDer2ParDer2 must be overloaded by derived class.");
332 virtual DRetDArg2
parDer2DirDer2(
const Arg2 &arg2Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
333 throw std::runtime_error(
"parDer2DirDer2 must be overloaded by derived class.");
337 virtual DRetDDir2
dirDer2DirDer2(
const Arg2 &arg2Dir_1,
const Arg2 &arg2Dir_2,
const Arg1 &arg1,
const Arg2 &arg2) {
338 throw std::runtime_error(
"dirDer2DirDer2 must be overloaded by derived class.");
343 throw std::runtime_error(
"parDer1ParDer2 must be overloaded by derived class.");
347 virtual DRetDArg1
parDer1DirDer2(
const Arg2 &arg2Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
348 throw std::runtime_error(
"parDer1DirDer2 must be overloaded by derived class.");
352 virtual DRetDDir2
dirDer2DirDer1(
const Arg2 &arg2Dir,
const Arg1 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
353 throw std::runtime_error(
"dirDer2DirDer1 must be overloaded by derived class.");
357 virtual DRetDArg2
parDer2DirDer1(
const Arg1 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
358 throw std::runtime_error(
"parDer2DirDer1 must be overloaded by derived class.");
virtual DDRetDArg1DArg2 parDer1ParDer2(const Arg1 &arg1, const Arg2 &arg2)
Second mixed derivative: partial derivative of parDer1 with respect to the second argument.
Definition: function.h:342
virtual DRetDDir2 dirDer2DirDer2(const Arg2 &arg2Dir_1, const Arg2 &arg2Dir_2, const Arg1 &arg1, const Arg2 &arg2)
Second derivative: directional derivative of dirDer2 with respect to the first argument.
Definition: function.h:337
virtual std::pair< int, int > getRetSize() const
Return the size of the return value: =0 == unknown size.
Definition: function.h:220
virtual DDRetDDArg2 parDer2ParDer2(const Arg1 &arg1, const Arg2 &arg2)
Second derivative: partial derivative of parDer2 with respect to the first argument.
Definition: function.h:327
virtual DRetDArg parDer(const Arg &arg)
First derivative: partial derivative of the function value with respect to the argument.
Definition: function.h:229
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
virtual DRetDDir1 dirDer1(const Arg1 &arg1Dir, const Arg1 &arg1, const Arg2 &arg2)
First derivative: directional derivative of the function value with respect to the first argument.
Definition: function.h:297
virtual bool constParDer() const
Returns true, if the partial derivative of the function value with respect to the argument.
Definition: function.h:255
virtual DRetDArg1 parDer1DirDer1(const Arg1 &arg1Dir, const Arg1 &arg1, const Arg2 &arg2)
Second derivative: directional derivative of parDer1 with respect to the first argument.
Definition: function.h:317
virtual DRetDDir2 dirDer2DirDer1(const Arg2 &arg2Dir, const Arg1 &arg1Dir, const Arg1 &arg1, const Arg2 &arg2)
Second mixed derivative: directional derivative of dirDer2 with respect to the first argument.
Definition: function.h:352
virtual DRetDDir dirDer(const Arg &argDir, const Arg &arg)
First derivative: directional derivative of the function value with respect to the argument.
Definition: function.h:234
Shape class for rotation matrices.
Definition: types.h:156
Definition: function.h:201
Definition: function.h:13
Definition: function.h:108
virtual int getArgSize() const
Return the size of the argument: =1 == scalar; >1 == vector; =0 == unknown vector size.
Definition: function.h:223
virtual DRetDDir dirDerDirDer(const Arg &argDir_1, const Arg &argDir_2, const Arg &arg)
Second derivative: directional derivative of dirDer with respect to the argument.
Definition: function.h:249
virtual DRetDDir1 dirDer1DirDer1(const Arg1 &arg1Dir_1, const Arg1 &arg1Dir_2, const Arg1 &arg1, const Arg2 &arg2)
Second derivative: directional derivative of dirDer1 with respect to the first argument.
Definition: function.h:322
virtual int getArg2Size() const
Return the size of the second argument: =1 == scalar; >1 == vector; =0 == unknown vector size.
Definition: function.h:286
virtual DRetDArg1 parDer1DirDer2(const Arg2 &arg2Dir, const Arg1 &arg1, const Arg2 &arg2)
Second mixed derivative: directional derivative of parDer1 with respect to the second argument.
Definition: function.h:347
virtual DRetDArg2 parDer2DirDer2(const Arg2 &arg2Dir, const Arg1 &arg1, const Arg2 &arg2)
Second derivative: directional derivative of parDer2 with respect to the first argument.
Definition: function.h:332
virtual int getArg1Size() const
Return the size of the first argument: =1 == scalar; >1 == vector; =0 == unknown vector size.
Definition: function.h:284
Namespace fmatvec.
Definition: _memory.cc:28
virtual std::pair< int, int > getRetSize() const
Return the size of the return value: =0 == unknown size.
Definition: function.h:281
virtual DDRetDDArg1 parDer1ParDer1(const Arg1 &arg1, const Arg2 &arg2)
Second derivative: partial derivative of parDer1 with respect to the first argument.
Definition: function.h:312
Definition: function.h:30
virtual bool constParDer1() const
Returns true, if the partial derivative of the function value with respect to the first argument.
Definition: function.h:363
virtual DRetDArg parDerDirDer(const Arg &argDir, const Arg &arg)
Second derivative: directional derivative of parDer with respect to the argument.
Definition: function.h:244
virtual DRetDArg2 parDer2(const Arg1 &arg1, const Arg2 &arg2)
First derivative: partial derivative of the function value with respect to the second argument.
Definition: function.h:302
virtual DRetDDir2 dirDer2(const Arg2 &arg2Dir, const Arg1 &arg1, const Arg2 &arg2)
First derivative: directional derivative of the function value with respect to the second argument.
Definition: function.h:307
virtual DDRetDDArg parDerParDer(const Arg &arg)
Second derivative: partial derivative of parDer with respect to the argument.
Definition: function.h:239
virtual bool constParDer2() const
Returns true, if the partial derivative of the function value with respect to the second argument.
Definition: function.h:367
virtual DRetDArg1 parDer1(const Arg1 &arg1, const Arg2 &arg2)
First derivative: partial derivative of the function value with respect to the first argument.
Definition: function.h:292
Definition: function.h:178
virtual DRetDArg2 parDer2DirDer1(const Arg1 &arg1Dir, const Arg1 &arg1, const Arg2 &arg2)
Second mixed derivative: partial derivative of dirDer1 with respect to the second argument.
Definition: function.h:357