MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
GiNaCDriveCaller Class Reference

#include <ginacdrive.h>

Inheritance diagram for GiNaCDriveCaller:
Collaboration diagram for GiNaCDriveCaller:

Public Member Functions

 GiNaCDriveCaller (const DriveHandler *pDH, const std::string &var, const std::string &expression)
 
virtual ~GiNaCDriveCaller (void)
 
virtual DriveCallerpCopy (void) const
 
virtual std::ostream & Restart (std::ostream &out) const
 
doublereal dGet (const doublereal &dVar) const
 
virtual bool bIsDifferentiable (void) const
 
virtual doublereal dGetP (const doublereal &dVar) const
 
- Public Member Functions inherited from DriveCaller
 DriveCaller (const DriveHandler *pDH)
 
virtual ~DriveCaller (void)
 
virtual doublereal dGet (void) const
 
virtual doublereal dGetP (void) const
 
virtual void SetDrvHdl (const DriveHandler *pDH)
 
virtual const DriveHandlerpGetDrvHdl (void) const
 
virtual void Output (OutputHandler &OH) const
 
virtual void Trace (OutputHandler &OH) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from Traceable
 Traceable (flag fTrace=0)
 
virtual ~Traceable (void)
 
virtual flag fToBeTraced (void) const
 
virtual void SetTraceFlag (flag f=TRACE)
 

Private Attributes

GiNaC::symbol * gVar
 
GiNaC::ex gExpr
 
GiNaC::ex gExprDVar
 

Additional Inherited Members

- Public Types inherited from DriveCaller
enum  OutputFlags { OUTPUT_VALUE = OUTPUT_PRIVATE << 0, OUTPUT_DERIVATIVE = OUTPUT_PRIVATE << 1 }
 
enum  TraceFlags { TRACE_VALUE = TRACE_PRIVATE << 0, TRACE_DERIVATIVE = TRACE_PRIVATE << 1 }
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from Traceable
enum  { TRACE = 0x01U, TRACE_PUBLIC_MASK = 0x0FU, TRACE_PRIVATE = 0x10U, TRACE_PRIVATE_MASK = ~TRACE_PUBLIC_MASK }
 
- Protected Attributes inherited from DriveCaller
DriveHandlerpDrvHdl
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 

Detailed Description

Definition at line 48 of file ginacdrive.h.

Constructor & Destructor Documentation

GiNaCDriveCaller::GiNaCDriveCaller ( const DriveHandler pDH,
const std::string &  var,
const std::string &  expression 
)

Definition at line 39 of file ginacdrive.cc.

References gExpr, gExprDVar, and gVar.

Referenced by pCopy().

41 : DriveCaller(pDH)
42 {
43  GiNaC::lst l;
44 
45  gVar = new GiNaC::symbol(var);
46  l.append(*gVar);
47 
48  try {
49  gExpr = GiNaC::ex(expression, l);
50 
51  } catch (std::exception& e) {
52  silent_cerr("GiNaCDriveCaller: "
53  "expression \"" << expression << "\" parsing failed: " << e.what()
54  << std::endl);
55  throw e;
56  }
57 
58  try {
59  gExprDVar = gExpr.diff(*gVar);
60 
61  } catch (std::exception& e) {
62  silent_cerr("GiNaCDriveCaller: "
63  "expression \"" << expression << "\" differentiation wrt/ \"Var\" failed: " << e.what()
64  << std::endl);
65  throw e;
66  }
67 
68  pedantic_cout("GiNacDriveCaller: symbol=\"" << *gVar << "\" expression=\"" << gExpr << "\" derivative=\"" << gExprDVar << "\"" << std::endl);
69 }
GiNaC::ex gExpr
Definition: ginacdrive.h:55
DriveCaller(const DriveHandler *pDH)
Definition: drive.cc:475
GiNaC::symbol * gVar
Definition: ginacdrive.h:52
GiNaC::ex gExprDVar
Definition: ginacdrive.h:58
GiNaCDriveCaller::~GiNaCDriveCaller ( void  )
virtual

Definition at line 71 of file ginacdrive.cc.

References NO_OP.

72 {
73  NO_OP;
74 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

bool GiNaCDriveCaller::bIsDifferentiable ( void  ) const
virtual

Reimplemented from DriveCaller.

Definition at line 103 of file ginacdrive.cc.

104 {
105  return true;
106 }
doublereal GiNaCDriveCaller::dGet ( const doublereal dVar) const
inlinevirtual

Implements DriveCaller.

Definition at line 78 of file ginacdrive.h.

References gExpr, and gVar.

79 {
80  GiNaC::lst l;
81 
82  l.append(*gVar == dVar);
83 
84  GiNaC::ex f_expr = gExpr.subs(l);
85 
86  return GiNaC::ex_to<GiNaC::numeric>(f_expr).to_double();
87 }
GiNaC::ex gExpr
Definition: ginacdrive.h:55
GiNaC::symbol * gVar
Definition: ginacdrive.h:52
doublereal GiNaCDriveCaller::dGetP ( const doublereal dVar) const
virtual

Reimplemented from DriveCaller.

Definition at line 109 of file ginacdrive.cc.

References gExprDVar, and gVar.

110 {
111  GiNaC::lst l;
112 
113  l.append(*gVar == dVar);
114 
115  GiNaC::ex f_expr = gExprDVar.subs(l);
116 
117  return GiNaC::ex_to<GiNaC::numeric>(f_expr).to_double();
118 }
GiNaC::symbol * gVar
Definition: ginacdrive.h:52
GiNaC::ex gExprDVar
Definition: ginacdrive.h:58
DriveCaller * GiNaCDriveCaller::pCopy ( void  ) const
virtual

Implements DriveCaller.

Definition at line 78 of file ginacdrive.cc.

References gExpr, GiNaCDriveCaller(), gVar, DriveCaller::pDrvHdl, and SAFENEWWITHCONSTRUCTOR.

79 {
80  DriveCaller* pDC = 0;
81 
82  std::ostringstream var, expr;
83  var << gVar;
84  expr << gExpr;
85 
88  GiNaCDriveCaller(pDrvHdl, var.str(), expr.str()));
89 
90  return pDC;
91 }
GiNaCDriveCaller(const DriveHandler *pDH, const std::string &var, const std::string &expression)
Definition: ginacdrive.cc:39
GiNaC::ex gExpr
Definition: ginacdrive.h:55
GiNaC::symbol * gVar
Definition: ginacdrive.h:52
DriveHandler * pDrvHdl
Definition: drive.h:444
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698

Here is the call graph for this function:

std::ostream & GiNaCDriveCaller::Restart ( std::ostream &  out) const
virtual

Implements DriveCaller.

Definition at line 95 of file ginacdrive.cc.

References gExpr, and gVar.

96 {
97  out << " ginac, symbol, \"" << *gVar << "\", \"" << gExpr << "\"";
98 
99  return out;
100 }
GiNaC::ex gExpr
Definition: ginacdrive.h:55
GiNaC::symbol * gVar
Definition: ginacdrive.h:52

Member Data Documentation

GiNaC::ex GiNaCDriveCaller::gExpr
private

Definition at line 55 of file ginacdrive.h.

Referenced by dGet(), GiNaCDriveCaller(), pCopy(), and Restart().

GiNaC::ex GiNaCDriveCaller::gExprDVar
private

Definition at line 58 of file ginacdrive.h.

Referenced by dGetP(), and GiNaCDriveCaller().

GiNaC::symbol* GiNaCDriveCaller::gVar
private

Definition at line 52 of file ginacdrive.h.

Referenced by dGet(), dGetP(), GiNaCDriveCaller(), pCopy(), and Restart().


The documentation for this class was generated from the following files: