FixedVector.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 #pragma once
19 
20 #include <stdarg.h>
21 #include <gtsam/base/Vector.h>
22 
23 namespace gtsam {
24 
29 template<size_t N>
30 class FixedVector : public Eigen::Matrix<double, N, 1> {
31 public:
33 
36 
38  FixedVector(const FixedVector& v) : Base(v) {}
39 
41  FixedVector(const Vector& v) : Base(v) {}
42 
44  FixedVector(const double* values) {
45  std::copy(values, values+N, this->data());
46  }
47 
52  inline static FixedVector repeat(double value) {
53  return FixedVector(Base::Constant(value));
54  }
55 
63  inline static FixedVector delta(size_t i, double value) {
64  return FixedVector(Base::Unit(i) * value);
65  }
66 
73  inline static FixedVector basis(size_t i) { return FixedVector(Base::Unit(i)); }
74 
78  inline static FixedVector zero() { return FixedVector(Base::Zero());}
79 
83  inline static FixedVector ones() { return FixedVector(FixedVector::Ones());}
84 
85  static size_t dim() { return Base::max_size; }
86 
87  void print(const std::string& name="") const { gtsam::print(Vector(*this), name); }
88 
89  template<size_t M>
90  bool equals(const FixedVector<M>& other, double tol=1e-9) const {
91  return false;
92  }
93 
94  bool equals(const FixedVector& other, double tol=1e-9) const {
95  return equal_with_abs_tol(*this,other,tol);
96  }
97 
98 };
99 
100 
101 } // \namespace
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
FixedVector(const double *values)
Definition: FixedVector.h:44
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
static FixedVector ones()
Definition: FixedVector.h:83
bool equals(const FixedVector &other, double tol=1e-9) const
Definition: FixedVector.h:94
leaf::MyValues values
void print(const std::string &name="") const
Definition: FixedVector.h:87
FixedVector(const Vector &v)
Definition: FixedVector.h:41
#define N
Definition: gksort.c:12
static FixedVector repeat(double value)
Definition: FixedVector.h:52
bool equals(const FixedVector< M > &other, double tol=1e-9) const
Definition: FixedVector.h:90
static size_t dim()
Definition: FixedVector.h:85
Eigen::VectorXd Vector
Definition: Vector.h:38
Array< int, Dynamic, 1 > v
Array< double, 1, 3 > e(1./3., 0.5, 2.)
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
Definition: base/Matrix.h:80
Eigen::Matrix< double, N, 1 > Base
Definition: FixedVector.h:32
traits
Definition: chartTesting.h:28
typedef and functions to augment Eigen&#39;s VectorXd
FixedVector(const FixedVector &v)
Definition: FixedVector.h:38
Annotation for function names.
Definition: attr.h:48
const G double tol
Definition: Group.h:86
The matrix class, also used for vectors and row-vectors.
static FixedVector basis(size_t i)
Definition: FixedVector.h:73
static FixedVector zero()
Definition: FixedVector.h:78
static FixedVector delta(size_t i, double value)
Definition: FixedVector.h:63


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:13