Skip to content

Commit

Permalink
Apply misra c++ quality rules mainly to headers
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed May 13, 2024
1 parent f1df5cb commit 59e51bb
Show file tree
Hide file tree
Showing 31 changed files with 1,028 additions and 750 deletions.
191 changes: 108 additions & 83 deletions modules/core/include/visp3/core/vpArray2D.h

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions modules/core/include/visp3/core/vpColVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,25 +206,25 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* Constructor that initialize a column vector from a 3-dim (Euler or
* \f$\theta {\bf u}\f$) or 4-dim (quaternion) rotation vector.
*/
vpColVector(const vpRotationVector &v);
explicit vpColVector(const vpRotationVector &v);

/*!
* Constructor that initialize a column vector from a 6-dim pose vector.
*/
vpColVector(const vpPoseVector &p);
explicit vpColVector(const vpPoseVector &p);

/*!
* Constructor that initialize a column vector from a 3-dim translation vector.
*/
vpColVector(const vpTranslationVector &t);
explicit vpColVector(const vpTranslationVector &t);

/*!
* Constructor that creates a column vector from a m-by-1 matrix `M`.
*
* \exception vpException::dimensionError If the matrix is not a m-by-1
* matrix.
*/
vpColVector(const vpMatrix &M);
explicit vpColVector(const vpMatrix &M);

/*!
* Constructor that takes column `j` of matrix `M`.
Expand All @@ -234,12 +234,12 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
/*!
* Constructor that creates a column vector from a std vector of double.
*/
vpColVector(const std::vector<double> &v);
explicit vpColVector(const std::vector<double> &v);

/*!
* Constructor that creates a column vector from a std vector of float.
*/
vpColVector(const std::vector<float> &v);
explicit vpColVector(const std::vector<float> &v);

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
/*!
Expand Down Expand Up @@ -366,7 +366,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
*/
vpColVector extract(unsigned int r, unsigned int colsize) const
{
if (r >= rowNum || r + colsize > rowNum) {
if ((r >= rowNum) || ((r + colsize) > rowNum)) {
throw(vpException(vpException::fatalError,
"Cannot extract a (%dx1) column vector from a (%dx1) "
"column vector starting at index %d",
Expand Down
6 changes: 4 additions & 2 deletions modules/core/include/visp3/core/vpDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ class vpTraceOutput
va_list args;
va_start(args, format);

if (err)
if (err) {
std::cerr << "(L" << level << ") ";
else
}
else {
std::cout << "(L" << level << ") ";
}

// calls display with it
display(format, args);
Expand Down
4 changes: 2 additions & 2 deletions modules/core/include/visp3/core/vpForceTwistMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class VISP_EXPORT vpForceTwistMatrix : public vpArray2D<double>
vpForceTwistMatrix(const vpTranslationVector &t, const vpThetaUVector &thetau);
vpForceTwistMatrix(double tx, double ty, double tz, double tux, double tuy, double tuz);

vpForceTwistMatrix(const vpRotationMatrix &R);
vpForceTwistMatrix(const vpThetaUVector &thetau);
explicit vpForceTwistMatrix(const vpRotationMatrix &R);
explicit vpForceTwistMatrix(const vpThetaUVector &thetau);

vpForceTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R);
vpForceTwistMatrix buildFrom(const vpTranslationVector &t, const vpThetaUVector &thetau);
Expand Down
91 changes: 58 additions & 33 deletions modules/core/include/visp3/core/vpGEMM.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,52 +149,60 @@ template <>
inline void GEMM1<0>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[r][n] * B[n][c] * alpha;
}
D[r][c] = sum;
}
}
}

template <>
inline void GEMM1<1>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[n][r] * B[n][c] * alpha;
}
D[r][c] = sum;
}
}
}

template <>
inline void GEMM1<2>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[r][n] * B[c][n] * alpha;
}
D[r][c] = sum;
}
}
}

template <>
inline void GEMM1<3>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[n][r] * B[c][n] * alpha;
}
D[r][c] = sum;
}
}
}

template <unsigned int>
Expand All @@ -208,111 +216,127 @@ inline void GEMM2<0>(const unsigned int &Arows, const unsigned int &Brows, const
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[r][n] * B[n][c] * alpha;
D[r][c] = sum + C[r][c] * beta;
}
D[r][c] = sum + (C[r][c] * beta);
}
}
}

template <>
inline void GEMM2<1>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[n][r] * B[n][c] * alpha;
D[r][c] = sum + C[r][c] * beta;
}
D[r][c] = sum + (C[r][c] * beta);
}
}
}

template <>
inline void GEMM2<2>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[r][n] * B[c][n] * alpha;
D[r][c] = sum + C[r][c] * beta;
}
D[r][c] = sum + (C[r][c] * beta);
}
}
}

template <>
inline void GEMM2<3>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[n][r] * B[c][n] * alpha;
D[r][c] = sum + C[r][c] * beta;
}
D[r][c] = sum + (C[r][c] * beta);
}
}
}

template <>
inline void GEMM2<4>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[r][n] * B[n][c] * alpha;
D[r][c] = sum + C[c][r] * beta;
}
D[r][c] = sum + (C[c][r] * beta);
}
}
}

template <>
inline void GEMM2<5>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[n][r] * B[n][c] * alpha;
D[r][c] = sum + C[c][r] * beta;
}
D[r][c] = sum + (C[c][r] * beta);
}
}
}

template <>
inline void GEMM2<6>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[r][n] * B[c][n] * alpha;
D[r][c] = sum + C[c][r] * beta;
}
D[r][c] = sum + (C[c][r] * beta);
}
}
}

template <>
inline void GEMM2<7>(const unsigned int &Arows, const unsigned int &Brows, const unsigned int &Bcols,
const vpArray2D<double> &A, const vpArray2D<double> &B, const double &alpha,
const vpArray2D<double> &C, const double &beta, vpArray2D<double> &D)
{
for (unsigned int r = 0; r < Arows; ++r)
for (unsigned int r = 0; r < Arows; ++r) {
for (unsigned int c = 0; c < Bcols; ++c) {
double sum = 0;
for (unsigned int n = 0; n < Brows; ++n)
for (unsigned int n = 0; n < Brows; ++n) {
sum += A[n][r] * B[c][n] * alpha;
D[r][c] = sum + C[c][r] * beta;
}
D[r][c] = sum + (C[c][r] * beta);
}
}
}

template <unsigned int T>
Expand All @@ -327,8 +351,9 @@ inline void vpTGEMM(const vpArray2D<double> &A, const vpArray2D<double> &B, cons
GEMMsize<T>(A, B, Arows, Acols, Brows, Bcols);

try {
if ((Arows != D.getRows()) || (Bcols != D.getCols()))
if ((Arows != D.getRows()) || (Bcols != D.getCols())) {
D.resize(Arows, Bcols);
}
}
catch (...) {
throw;
Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/visp3/core/vpGaussianFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class VISP_EXPORT vpGaussianFilter
virtual ~vpGaussianFilter();

private:
vpGaussianFilter(const vpGaussianFilter &);
vpGaussianFilter(const vpGaussianFilter &gf);
vpGaussianFilter &operator=(const vpGaussianFilter &);

// PIMPL idiom
Expand Down
3 changes: 1 addition & 2 deletions modules/core/include/visp3/core/vpHomogeneousMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class vpPoint;
#include <visp3/core/vpArray2D.h>
#include <visp3/core/vpRotationMatrix.h>
#include <visp3/core/vpThetaUVector.h>
//#include <visp3/core/vpTranslationVector.h>
#include <visp3/core/vpPoseVector.h>

#ifdef VISP_HAVE_NLOHMANN_JSON
Expand Down Expand Up @@ -208,7 +207,7 @@ class VISP_EXPORT vpHomogeneousMatrix : public vpArray2D<double>
explicit vpHomogeneousMatrix(const std::vector<double> &v);
vpHomogeneousMatrix(double tx, double ty, double tz, double tux, double tuy, double tuz);
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
vpHomogeneousMatrix(const std::initializer_list<double> &list);
explicit vpHomogeneousMatrix(const std::initializer_list<double> &list);
#endif

void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R);
Expand Down
Loading

0 comments on commit 59e51bb

Please sign in to comment.