30 template <
typename T1,
typename T2>
31 inline std::vector<T1>&
operator*=(std::vector<T1>& a,
const std::vector<T2>& b)
34 const size_t N = a.size();
35 for (
size_t i = 0; i < N; i++) a[i] *= b[i];
40 template <
typename T1>
41 inline std::vector<T1>&
operator*=(std::vector<T1>& a,
const T1 b)
43 const size_t N = a.size();
44 for (
size_t i = 0; i < N; i++) a[i] *= b;
49 template <
typename T1,
typename T2>
51 const std::vector<T1>& a,
const std::vector<T2>& b)
54 const size_t N = a.size();
55 std::vector<T1> ret(N);
56 for (
size_t i = 0; i < N; i++) ret[i] = a[i] * b[i];
61 template <
typename T1,
typename T2>
62 inline std::vector<T1>&
operator+=(std::vector<T1>& a,
const std::vector<T2>& b)
65 const size_t N = a.size();
66 for (
size_t i = 0; i < N; i++) a[i] += b[i];
71 template <
typename T1>
72 inline std::vector<T1>&
operator+=(std::vector<T1>& a,
const T1 b)
74 const size_t N = a.size();
75 for (
size_t i = 0; i < N; i++) a[i] += b;
80 template <
typename T1,
typename T2>
82 const std::vector<T1>& a,
const std::vector<T2>& b)
85 const size_t N = a.size();
86 std::vector<T1> ret(N);
87 for (
size_t i = 0; i < N; i++) ret[i] = a[i] + b[i];
91 template <
typename T1,
typename T2>
93 const std::vector<T1>& v1,
const std::vector<T2>& v2)
96 std::vector<T1> res(v1.size());
97 for (
size_t i = 0; i < v1.size(); i++) res[i] = v1[i] - v2[i];
106 std::ostream& operator<<(std::ostream& out, const std::vector<T>& d)
108 const std::streamsize old_pre =
out.precision();
109 const std::ios_base::fmtflags old_flags =
out.flags();
110 out <<
"[" << std::fixed << std::setprecision(4);
111 std::copy(d.begin(), d.end(), std::ostream_iterator<T>(
out,
" "));
113 out.flags(old_flags);
114 out.precision(old_pre);
121 std::ostream& operator<<(std::ostream& out, std::vector<T>* d)
123 const std::streamsize old_pre =
out.precision();
124 const std::ios_base::fmtflags old_flags =
out.flags();
125 out <<
"[" << std::fixed << std::setprecision(4);
126 copy(d->begin(), d->end(), std::ostream_iterator<T>(
out,
" "));
128 out.flags(old_flags);
129 out.precision(old_pre);
134 template <
typename T,
size_t N>
138 ostrm << mrpt::typemeta::TTypeName<CVectorFixed<T, N>>::get();
144 template <
typename T,
size_t N>
148 static const std::string namExpect =
154 "Error deserializing: expected '%s', got '%s'",
155 namExpect.c_str(), nam.c_str()));
std::vector< T1 > operator-(const std::vector< T1 > &v1, const std::vector< T2 > &v2)
A compile-time fixed-size numeric matrix container.
std::string std::string format(std::string_view fmt, ARGS &&... args)
This file implements several operations that operate element-wise on individual or pairs of container...
void WriteBufferFixEndianness(const T *ptr, size_t ElementCount)
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running arch...
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrixD::Ptr &pObj)
std::vector< T1 > operator+(const std::vector< T1 > &a, const std::vector< T2 > &b)
a+b (element-wise sum)
This base provides a set of functions for maths stuff.
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Virtual base class for "archives": classes abstracting I/O streams.
mrpt::vision::TStereoCalibResults out
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &s, const CVectorFloat &a)
size_t ReadBufferFixEndianness(T *ptr, size_t ElementCount)
Reads a sequence of elemental datatypes, taking care of reordering their bytes from the MRPT stream s...
std::vector< T1 > & operator*=(std::vector< T1 > &a, const std::vector< T2 > &b)
a*=b (element-wise multiplication)
std::vector< T1 > operator*(const std::vector< T1 > &a, const std::vector< T2 > &b)
a*b (element-wise multiplication)