22 template <
typename T, std::
size_t N>
33 template <
typename T1,
typename T2>
34 inline std::vector<T1>&
operator*=(std::vector<T1>&
a,
const std::vector<T2>&
b)
37 const size_t N =
a.size();
38 for (
size_t i = 0; i < N; i++)
a[i] *=
b[i];
43 template <
typename T1>
46 const size_t N =
a.size();
47 for (
size_t i = 0; i < N; i++)
a[i] *=
b;
52 template <
typename T1,
typename T2>
54 const std::vector<T1>&
a,
const std::vector<T2>&
b)
57 const size_t N =
a.size();
58 std::vector<T1> ret(N);
59 for (
size_t i = 0; i < N; i++) ret[i] =
a[i] *
b[i];
64 template <
typename T1,
typename T2>
65 inline std::vector<T1>&
operator+=(std::vector<T1>&
a,
const std::vector<T2>&
b)
68 const size_t N =
a.size();
69 for (
size_t i = 0; i < N; i++)
a[i] +=
b[i];
74 template <
typename T1>
77 const size_t N =
a.size();
78 for (
size_t i = 0; i < N; i++)
a[i] +=
b;
83 template <
typename T1,
typename T2>
85 const std::vector<T1>&
a,
const std::vector<T2>&
b)
88 const size_t N =
a.size();
89 std::vector<T1> ret(N);
90 for (
size_t i = 0; i < N; i++) ret[i] =
a[i] +
b[i];
94 template <
typename T1,
typename T2>
96 const std::vector<T1>&
v1,
const std::vector<T2>&
v2)
99 std::vector<T1>
res(
v1.size());
100 for (
size_t i = 0; i <
v1.size(); i++)
res[i] =
v1[i] -
v2[i];
109 std::ostream& operator<<(std::ostream& out, const std::vector<T>& d)
111 const std::streamsize old_pre = out.precision();
112 const std::ios_base::fmtflags old_flags = out.flags();
113 out <<
"[" << std::fixed << std::setprecision(4);
114 std::copy(d.begin(), d.end(), std::ostream_iterator<T>(out,
" "));
116 out.flags(old_flags);
117 out.precision(old_pre);
124 std::ostream& operator<<(std::ostream& out, std::vector<T>* d)
126 const std::streamsize old_pre = out.precision();
127 const std::ios_base::fmtflags old_flags = out.flags();
128 out <<
"[" << std::fixed << std::setprecision(4);
129 copy(d->begin(), d->end(), std::ostream_iterator<T>(out,
" "));
131 out.flags(old_flags);
132 out.precision(old_pre);
137 template <
typename T,
size_t N>
141 ostrm << mrpt::typemeta::TTypeName<CArrayNumeric<T, N>>::get();
147 template <
typename T,
size_t N>
157 "Error deserializing: expected '%s', got '%s'",
158 namExpect.c_str(), nam.c_str()));
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...
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually...
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::ostream & operator<<(std::ostream &o, const TPoint2D &p)
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.
GLsizei const GLchar ** string
Virtual base class for "archives": classes abstracting I/O streams.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLfloat GLfloat GLfloat v2
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...
GLubyte GLubyte GLubyte a
TPose3D operator-(const TPose3D &p)
Unary $$ operator: computes inverse SE(3) element.
std::vector< T1 > & operator*=(std::vector< T1 > &a, const std::vector< T2 > &b)
a*=b (element-wise multiplication)
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrix::Ptr &pObj)
std::vector< T1 > operator*(const std::vector< T1 > &a, const std::vector< T2 > &b)
a*b (element-wise multiplication)