31 template <
class T1,
class T2>
34 return fabs(
a -
b) <= ((fabs(
a) > fabs(
b) ? fabs(
b) : fabs(
a)) * epsilon);
54 return lhs > rhs ? lhs - rhs : rhs - lhs;
73 const std::vector<double>& inV, std::vector<double>& outV,
74 const int& winSize,
const int& numberOfSigmas = 2);
79 template <
typename T,
typename VECTOR>
84 out_vector.assign(
count, last);
89 out_vector.resize(
count);
92 for (
size_t i = 0; i <
count; i++,
c += incr) out_vector[i] =
c;
98 template <
class T, T STEP>
101 std::vector<T> ret(
length);
115 template <
class VEC1,
class VEC2>
119 const size_t N =
v.size();
120 for (
size_t i = 0; i < N; i++) total +=
square(
v[i]);
121 total = std::sqrt(total);
124 out_v =
v * (1.0 / total);
127 out_v.assign(
v.size(), 0);
139 template <
class VECTOR_OF_VECTORS,
class VECTORLIKE>
141 const size_t colIndex,
const VECTOR_OF_VECTORS&
data,
142 VECTORLIKE& out_column)
144 const size_t N =
data.size();
145 out_column.resize(N);
146 for (
size_t i = 0; i < N; i++) out_column[i] =
data[i][colIndex];
186 const size_t& nEllipsePoints = 30);
201 const size_t& nEllipsePoints = 30);
212 template <
typename EIGEN_VECTOR,
typename At,
size_t N>
216 v.derived().resize(N);
217 for (
size_t i = 0; i < N; i++)
223 template <
typename T,
typename At,
size_t N>
228 for (
size_t i = 0; i < N; i++) v[i] = static_cast<T>(theArray[i]);
245 template <
class TRIPLET>
247 const std::string& sFile, std::vector<TRIPLET>& tri)
249 #if defined(_MSC_VER) && \
252 if (0 != ::fopen_s(&f, sFile.c_str(),
"wt")) f =
nullptr;
254 FILE* f =
::fopen(sFile.c_str(),
"wt");
257 if (!f)
return false;
259 for (
size_t i = 0; i < tri.size(); i++)
261 f,
"%u %u %e\n", 1 + tri[i].
row(), 1 + tri[i].col(),
This CStream derived class allow using a file as a read/write binary stream, creating it if the file ...
GLenum GLenum GLvoid * row
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLuint GLsizei GLsizei * length
GLuint GLuint GLsizei count
GLubyte GLubyte GLubyte a
GLsizei const GLfloat * value
GLsizei const GLchar ** string
bool loadVector(utils::CFileStream &f, std::vector< int > &d)
Loads one row of a text file as a numerical std::vector.
void extractColumnFromVectorOfVectors(const size_t colIndex, const VECTOR_OF_VECTORS &data, VECTORLIKE &out_column)
Extract a column from a vector of vectors, and store it in another vector.
std::vector< T > sequenceStdVec(T first, size_t length)
Generates a sequence of values [first,first+STEP,first+2*STEP,...].
void medianFilter(const std::vector< double > &inV, std::vector< double > &outV, const int &winSize, const int &numberOfSigmas=2)
void normalize(const VEC1 &v, VEC2 &out_v)
Normalize a vector, such as its norm is the unity.
void linspace(T first, T last, size_t count, VECTOR &out_vector)
Generates an equidistant sequence of numbers given the first one, the last one and the desired number...
double factorial(unsigned int n)
Computes the factorial of an integer number and returns it as a double value (internally it uses loga...
uint64_t factorial64(unsigned int n)
Computes the factorial of an integer number and returns it as a 64-bit integer number.
T round2up(T val)
Round up to the nearest power of two of a given number.
bool saveEigenSparseTripletsToFile(const std::string &sFile, std::vector< TRIPLET > &tri)
Saves to a plain-text file the nonzero entries of a Eigen sparse matrix, represented as a vector of t...
int void fclose(FILE *f)
An OS-independent version of fclose.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
std::string MATLAB_plotCovariance2D(const CMatrixFloat &cov22, const CVectorFloat &mean, const float &stdCount, const std::string &style=std::string("b"), const size_t &nEllipsePoints=30)
Generates a string with the MATLAB commands required to plot an confidence interval (ellipse) for a 2...
#define MRPT_COMPILE_TIME_ASSERT(f)
#define THROW_EXCEPTION(msg)
double mean(const CONTAINER &v)
Computes the mean value of a vector.
dynamic_vector< float > CVectorFloat
Column vector, like Eigen::MatrixXf, but automatically initialized to zeros since construction.
dynamic_vector< double > CVectorDouble
Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction.
CMatrixTemplateNumeric< float > CMatrixFloat
Declares a matrix of float numbers (non serializable).
CMatrixTemplateNumeric< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).
bool approximatelyEqual(T1 a, T1 b, T2 epsilon)
Compare 2 floats and determine whether they are equal.
T absDiff(const T &lhs, const T &rhs)
Absolute difference between two numbers.
T square(const T x)
Inline function for the square of a number.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
unsigned __int64 uint64_t