gtsam
Loading...
Searching...
No Matches
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
17
18#pragma once
19
20#include <gtsam/config.h>
21
22#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V43
23
24#include <stdarg.h>
25#include <gtsam/base/Vector.h>
26
27namespace gtsam {
28
34template<size_t N>
35class FixedVector : public Eigen::Matrix<double, N, 1> {
36public:
37 typedef Eigen::Matrix<double, N, 1> Base;
38
40 FixedVector() {}
41
43 FixedVector(const FixedVector& v) : Base(v) {}
44
45 FixedVector& operator=(const FixedVector& other) = default;
46
48 FixedVector(const Vector& v) : Base(v) {}
49
51 FixedVector(const double* values) {
52 std::copy(values, values+N, this->data());
53 }
54
59 inline static FixedVector repeat(double value) {
60 return FixedVector(Base::Constant(value));
61 }
62
70 inline static FixedVector delta(size_t i, double value) {
71 return FixedVector(Base::Unit(i) * value);
72 }
73
80 inline static FixedVector basis(size_t i) { return FixedVector(Base::Unit(i)); }
81
85 inline static FixedVector zero() { return FixedVector(Base::Zero());}
86
90 inline static FixedVector ones() { return FixedVector(FixedVector::Ones());}
91
92 static size_t dim() { return Base::max_size; }
93
94 void print(const std::string& name="") const { gtsam::print(Vector(*this), name); }
95
96 template<size_t M>
97 bool equals(const FixedVector<M>& other, double tol=1e-9) const {
98 return false;
99 }
100
101 bool equals(const FixedVector& other, double tol=1e-9) const {
102 return equal_with_abs_tol(*this,other,tol);
103 }
104
105};
106
107
108} // \namespace
109
110#endif // GTSAM_ALLOW_DEPRECATED_SINCE_V43
typedef and functions to augment Eigen's VectorXd
Global functions in a separate testing namespace.
Definition chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
equals with a tolerance
Definition Matrix.h:81