Rigid Body Dynamics Library
MX_Xd_scalar.h
Go to the documentation of this file.
1/*
2 * RBDL - Rigid Body Dynamics Library
3 * Copyright (c) 2011-2018 Martin Felis <martin@fysx.org>
4 *
5 * Licensed under the zlib license. See LICENSE for more details.
6 */
7
8#ifndef MX_XD_SCALAR_H
9#define MX_XD_SCALAR_H
10
11#include <vector>
12#include <string>
13#include <memory>
14
15#include <casadi.hpp>
16
17namespace RBDLCasadiMath {
18
19class MX_Xd_scalar : public casadi::MX{
20public:
21 MX_Xd_scalar() : casadi::MX(1, 1){
22
23 }
24
25 virtual ~MX_Xd_scalar(){
26
27 }
28
29
30 MX_Xd_scalar(const double val) : casadi::MX(1, 1){
31 (*this)(0, 0) = val;
32 }
33
34 MX_Xd_scalar(const casadi::MX& m) : casadi::MX(m){
35
36 }
37
39 const MX_Xd_scalar& v0) :
40 casadi::MX(1, 1)
41 {
42 (*this)(0) = v0(0);
43 }
44
45 unsigned int rows() const {
46 return 1;
47 }
48
49 unsigned int cols() const {
50 return 1;
51 }
52
53 unsigned int size() const {
54 return 1;
55 }
56
57 MX_Xd_scalar operator[](unsigned int i) const{
58 return (*this)(i);
59 }
60
62 const MX_Xd_scalar& other) {
63 this->casadi::MX::operator+=(other);
64 }
66 const MX_Xd_scalar& other) const {
67 MX_Xd_scalar out(*this);
68 return out.casadi::MX::operator+=(other);
69 }
70
72 const MX_Xd_scalar& other) {
73 this->casadi::MX::operator-=(other);
74 }
76 const MX_Xd_scalar& other) const {
77 MX_Xd_scalar out(*this);
78 return out.casadi::MX::operator-=(other);
79 }
81 const double& other) const {
82 MX_Xd_scalar out(*this);
83 return out.casadi::MX::operator-=(other);
84 }
85
86 MX_Xd_scalar operator*(const MX_Xd_scalar& other) const{
87 return casadi::MX::times(*this, other);
88 }
90 double other) {
91 return casadi::MX::times(*this, other);
92 }
93
95 const MX_Xd_scalar& other
96 ){
97 this->casadi::MX::operator/=(other);
98 }
100 const MX_Xd_scalar& other) const {
101 MX_Xd_scalar out(*this);
102 return out.casadi::MX::operator/=(other);
103 }
104};
105
106}
107
108/* MX_XD_SCALAR_H */
109#endif
110
unsigned int rows() const
Definition: MX_Xd_scalar.h:45
unsigned int cols() const
Definition: MX_Xd_scalar.h:49
void operator-=(const MX_Xd_scalar &other)
Definition: MX_Xd_scalar.h:71
MX_Xd_scalar operator*(const MX_Xd_scalar &other) const
Definition: MX_Xd_scalar.h:86
void operator+=(const MX_Xd_scalar &other)
Definition: MX_Xd_scalar.h:61
MX_Xd_scalar operator[](unsigned int i) const
Definition: MX_Xd_scalar.h:57
unsigned int size() const
Definition: MX_Xd_scalar.h:53
MX_Xd_scalar operator/(const MX_Xd_scalar &other) const
Definition: MX_Xd_scalar.h:99
MX_Xd_scalar(const casadi::MX &m)
Definition: MX_Xd_scalar.h:34
MX_Xd_scalar(const MX_Xd_scalar &v0)
Definition: MX_Xd_scalar.h:38
MX_Xd_scalar operator-(const double &other) const
Definition: MX_Xd_scalar.h:80
MX_Xd_scalar operator*(double other)
Definition: MX_Xd_scalar.h:89
MX_Xd_scalar operator-(const MX_Xd_scalar &other) const
Definition: MX_Xd_scalar.h:75
void operator/=(const MX_Xd_scalar &other)
Definition: MX_Xd_scalar.h:94
MX_Xd_scalar operator+(const MX_Xd_scalar &other) const
Definition: MX_Xd_scalar.h:65
MX_Xd_scalar(const double val)
Definition: MX_Xd_scalar.h:30