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>
184 template<
typename Sig>
188 template<
typename Ret,
typename Arg>
203 virtual std::pair<int, int>
getRetSize()
const {
return std::make_pair(retSize1, retSize2); }
209 virtual Ret operator()(
const Arg &arg)=0;
212 virtual DRetDArg
parDer(
const Arg &arg) {
213 throw std::runtime_error(
"parDer must be overloaded by derived class.");
217 virtual Ret
dirDer(
const Arg &argDir,
const Arg &arg) {
218 throw std::runtime_error(
"dirDer must be overloaded by derived class.");
223 throw std::runtime_error(
"parDerParDer must be overloaded by derived class.");
228 throw std::runtime_error(
"parDerDirDer must be overloaded by derived class.");
232 virtual Ret
dirDerDirDer(
const Arg &argDir_1,
const Arg &argDir_2,
const Arg &arg) {
233 throw std::runtime_error(
"dirDerDirDer must be overloaded by derived class.");
242 template<
typename Ret,
typename Arg1,
typename Arg2>
263 virtual std::pair<int, int>
getRetSize()
const {
return std::make_pair(retSize1, retSize2); }
271 virtual Ret operator()(
const Arg1 &arg1,
const Arg2 &arg2)=0;
274 virtual DRetDArg1
parDer1(
const Arg1 &arg1,
const Arg2 &arg2) {
275 throw std::runtime_error(
"parDer1 must be overloaded by derived class.");
279 virtual Ret
dirDer1(
const Arg1 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
280 throw std::runtime_error(
"dirDer1 must be overloaded by derived class.");
284 virtual DRetDArg2
parDer2(
const Arg1 &arg1,
const Arg2 &arg2) {
285 throw std::runtime_error(
"parDer2 must be overloaded by derived class.");
289 virtual Ret
dirDer2(
const Arg2 &arg2Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
290 throw std::runtime_error(
"dirDer2 must be overloaded by derived class.");
295 throw std::runtime_error(
"parDer1ParDer1 must be overloaded by derived class.");
299 virtual DRetDArg1
parDer1DirDer1(
const Arg1 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
300 throw std::runtime_error(
"parDer1DirDer1 must be overloaded by derived class.");
304 virtual Ret
dirDer1DirDer1(
const Arg1 &arg1Dir_1,
const Arg1 &arg1Dir_2,
const Arg1 &arg1,
const Arg2 &arg2) {
305 throw std::runtime_error(
"dirDer1DirDer1 must be overloaded by derived class.");
310 throw std::runtime_error(
"parDer2ParDer2 must be overloaded by derived class.");
314 virtual DRetDArg2
parDer2DirDer2(
const Arg2 &arg2Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
315 throw std::runtime_error(
"parDer2DirDer2 must be overloaded by derived class.");
319 virtual Ret
dirDer2DirDer2(
const Arg2 &arg2Dir_1,
const Arg2 &arg2Dir_2,
const Arg1 &arg1,
const Arg2 &arg2) {
320 throw std::runtime_error(
"dirDer2DirDer2 must be overloaded by derived class.");
325 throw std::runtime_error(
"parDer1ParDer2 must be overloaded by derived class.");
329 virtual DRetDArg1
parDer1DirDer2(
const Arg2 &arg2Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
330 throw std::runtime_error(
"parDer1DirDer2 must be overloaded by derived class.");
334 virtual Ret
dirDer2DirDer1(
const Arg2 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
335 throw std::runtime_error(
"dirDer2DirDer1 must be overloaded by derived class.");
339 virtual DRetDArg2
parDer2DirDer1(
const Arg1 &arg1Dir,
const Arg1 &arg1,
const Arg2 &arg2) {
340 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:324
virtual DDRetDDArg2 parDer2ParDer2(const Arg1 &arg1, const Arg2 &arg2)
Second derivative: partial derivative of parDer2 with respect to the first argument.
Definition: function.h:309
virtual DRetDArg parDer(const Arg &arg)
First derivative: partial derivative of the function value with respect to the argument.
Definition: function.h:212
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
virtual Ret 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:232
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:299
virtual int getArg2Size() const
Return the size of the second argument: =1 == scalar; >1 == vector; =0 == unknown vector size...
Definition: function.h:268
virtual Ret dirDer(const Arg &argDir, const Arg &arg)
First derivative: directional derivative of the function value with respect to the argument...
Definition: function.h:217
Shape class for rotation matrices.
Definition: types.h:124
Definition: function.h:185
virtual int getArgSize() const
Return the size of the argument: =1 == scalar; >1 == vector; =0 == unknown vector size...
Definition: function.h:206
Definition: function.h:13
Definition: function.h:108
virtual int getArg1Size() const
Return the size of the first argument: =1 == scalar; >1 == vector; =0 == unknown vector size...
Definition: function.h:266
virtual Ret dirDer2DirDer1(const Arg2 &arg1Dir, const Arg1 &arg1, const Arg2 &arg2)
Second mixed derivative: directional derivative of dirDer2 with respect to the first argument...
Definition: function.h:334
virtual std::pair< int, int > getRetSize() const
Return the size of the return value: =0 == unknown size.
Definition: function.h:263
virtual Ret 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:289
virtual bool constParDer() const
Returns true, if the partial derivative of the function value with respect to the argument...
Definition: function.h:238
virtual Ret 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:279
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:329
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:314
virtual Ret 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:319
virtual Ret 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:304
virtual bool constParDer2() const
Returns true, if the partial derivative of the function value with respect to the second argument...
Definition: function.h:349
virtual DDRetDDArg1 parDer1ParDer1(const Arg1 &arg1, const Arg2 &arg2)
Second derivative: partial derivative of parDer1 with respect to the first argument.
Definition: function.h:294
Definition: function.h:30
virtual DRetDArg parDerDirDer(const Arg &argDir, const Arg &arg)
Second derivative: directional derivative of parDer with respect to the argument. ...
Definition: function.h:227
virtual std::pair< int, int > getRetSize() const
Return the size of the return value: =0 == unknown size.
Definition: function.h:203
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:284
virtual DDRetDDArg parDerParDer(const Arg &arg)
Second derivative: partial derivative of parDer with respect to the argument.
Definition: function.h:222
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:274
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:339
virtual bool constParDer1() const
Returns true, if the partial derivative of the function value with respect to the first argument...
Definition: function.h:345