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>
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>
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>
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.
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...
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.
GLsizei const GLchar ** string
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrixD::Ptr &pObj)
Virtual base class for "archives": classes abstracting I/O streams.
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &s, const CVectorFloat &a)
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
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)