Skip to content

Commit

Permalink
Introduce new quality rules fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Apr 10, 2024
1 parent 7254ec5 commit ed78d68
Show file tree
Hide file tree
Showing 120 changed files with 3,893 additions and 3,440 deletions.
60 changes: 30 additions & 30 deletions modules/core/include/visp3/core/vpArray2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
* a[1][0] = 4; a[1][1] = 5.5; a[1][2] = 6;
*
* std::cout << "a:" << std::endl;
* for (unsigned int i = 0; i < a.getRows(); i++) {
* for (unsigned int j = 0; j < a.getCols(); j++) {
* for (unsigned int i = 0; i < a.getRows(); ++i) {
* for (unsigned int j = 0; j < a.getCols(); ++j) {
* std::cout << a[i][j] << " ";
* }
* std::cout << std::endl;
Expand Down Expand Up @@ -475,7 +475,7 @@ template <class Type> class vpArray2D
memcpy(data + r * colNum, A.data, sizeof(Type) * A.size());
}
else if (data != nullptr && A.data != nullptr && A.data != data) {
for (unsigned int i = r; i < (r + A.getRows()); i++) {
for (unsigned int i = r; i < (r + A.getRows()); ++i) {
memcpy(data + i * colNum + c, A.data + (i - r) * A.colNum, sizeof(Type) * A.colNum);
}
}
Expand Down Expand Up @@ -592,8 +592,8 @@ template <class Type> class vpArray2D
std::ios_base::fmtflags original_flags = s.flags();

s.precision(10);
for (unsigned int i = 0; i < A.getRows(); i++) {
for (unsigned int j = 0; j < A.getCols() - 1; j++) {
for (unsigned int i = 0; i < A.getRows(); ++i) {
for (unsigned int j = 0; j < A.getCols() - 1; ++j) {
s << A[i][j] << " ";
}
// We don't add " " after the last row element
Expand Down Expand Up @@ -698,8 +698,8 @@ template <class Type> class vpArray2D
A.resize(rows, cols);

Type value;
for (unsigned int i = 0; i < rows; i++) {
for (unsigned int j = 0; j < cols; j++) {
for (unsigned int i = 0; i < rows; ++i) {
for (unsigned int j = 0; j < cols; ++j) {
file >> value;
A[i][j] = value;
}
Expand Down Expand Up @@ -728,8 +728,8 @@ template <class Type> class vpArray2D
A.resize(rows, cols);

Type value;
for (unsigned int i = 0; i < rows; i++) {
for (unsigned int j = 0; j < cols; j++) {
for (unsigned int i = 0; i < rows; ++i) {
for (unsigned int j = 0; j < cols; ++j) {
file.read((char *)&value, sizeof(Type));
A[i][j] = value;
}
Expand Down Expand Up @@ -881,8 +881,8 @@ template <class Type> class vpArray2D
matrixSize = A.getCols();
file.write((char *)&matrixSize, sizeof(unsigned int));
Type value;
for (unsigned int i = 0; i < A.getRows(); i++) {
for (unsigned int j = 0; j < A.getCols(); j++) {
for (unsigned int i = 0; i < A.getRows(); ++i) {
for (unsigned int j = 0; j < A.getCols(); ++j) {
value = A[i][j];
file.write((char *)&value, sizeof(Type));
}
Expand Down Expand Up @@ -1068,7 +1068,7 @@ template <class Type> Type vpArray2D<Type>::getMinValue() const
Type *dataptr = data;
Type min = *dataptr;
dataptr++;
for (unsigned int i = 0; i < dsize - 1; i++) {
for (unsigned int i = 0; i < dsize - 1; ++i) {
if (*dataptr < min) {
min = *dataptr;
}
Expand All @@ -1085,7 +1085,7 @@ template <class Type> Type vpArray2D<Type>::getMaxValue() const
Type *dataptr = data;
Type max = *dataptr;
dataptr++;
for (unsigned int i = 0; i < dsize - 1; i++) {
for (unsigned int i = 0; i < dsize - 1; ++i) {
if (*dataptr > max) {
max = *dataptr;
}
Expand All @@ -1109,7 +1109,7 @@ template <class Type> vpArray2D<Type> vpArray2D<Type>::hadamard(const vpArray2D<
vpArray2D<Type> out;
out.resize(rowNum, colNum, false);

for (unsigned int i = 0; i < dsize; i++) {
for (unsigned int i = 0; i < dsize; ++i) {
out.data[i] = data[i] * m.data[i];
}

Expand All @@ -1119,8 +1119,8 @@ template <class Type> vpArray2D<Type> vpArray2D<Type>::hadamard(const vpArray2D<
template <class Type> vpArray2D<Type> vpArray2D<Type>::t() const
{
vpArray2D<Type> At(colNum, rowNum);
for (unsigned int i = 0; i < rowNum; i++) {
for (unsigned int j = 0; j < colNum; j++) {
for (unsigned int i = 0; i < rowNum; ++i) {
for (unsigned int j = 0; j < colNum; ++j) {
At[j][i] = (*this)[i][j];
}
}
Expand Down Expand Up @@ -1169,10 +1169,10 @@ template <class Type> void vpArray2D<Type>::conv2(const vpArray2D<Type> &M, cons
}

if (mode == "same") {
for (unsigned int i = 0; i < res_same.getRows(); i++) {
for (unsigned int j = 0; j < res_same.getCols(); j++) {
for (unsigned int k = 0; k < kernel.getRows(); k++) {
for (unsigned int l = 0; l < kernel.getCols(); l++) {
for (unsigned int i = 0; i < res_same.getRows(); ++i) {
for (unsigned int j = 0; j < res_same.getCols(); ++j) {
for (unsigned int k = 0; k < kernel.getRows(); ++k) {
for (unsigned int l = 0; l < kernel.getCols(); ++l) {
res_same[i][j] += M_padded[i + k][j + l] * kernel[kernel.getRows() - k - 1][kernel.getCols() - l - 1];
}
}
Expand All @@ -1181,16 +1181,16 @@ template <class Type> void vpArray2D<Type>::conv2(const vpArray2D<Type> &M, cons

const unsigned int start_i = kernel.getRows() / 2;
const unsigned int start_j = kernel.getCols() / 2;
for (unsigned int i = 0; i < M.getRows(); i++) {
for (unsigned int i = 0; i < M.getRows(); ++i) {
memcpy(res.data + i * M.getCols(), res_same.data + (i + start_i) * res_same.getCols() + start_j,
sizeof(Type) * M.getCols());
}
}
else {
for (unsigned int i = 0; i < res.getRows(); i++) {
for (unsigned int j = 0; j < res.getCols(); j++) {
for (unsigned int k = 0; k < kernel.getRows(); k++) {
for (unsigned int l = 0; l < kernel.getCols(); l++) {
for (unsigned int i = 0; i < res.getRows(); ++i) {
for (unsigned int j = 0; j < res.getCols(); ++j) {
for (unsigned int k = 0; k < kernel.getRows(); ++k) {
for (unsigned int l = 0; l < kernel.getCols(); ++l) {
res[i][j] += M_padded[i + k][j + l] * kernel[kernel.getRows() - k - 1][kernel.getCols() - l - 1];
}
}
Expand All @@ -1213,8 +1213,8 @@ template<class Type> void vpArray2D<Type>::insert(const vpArray2D<Type> &A, cons
if (((r + B.getRows()) <= A.getRows()) && ((c + B.getCols()) <= A.getCols())) {
C.resize(A.getRows(), A.getCols(), false, false);

for (unsigned int i = 0; i < A.getRows(); i++) {
for (unsigned int j = 0; j < A.getCols(); j++) {
for (unsigned int i = 0; i < A.getRows(); ++i) {
for (unsigned int j = 0; j < A.getCols(); ++j) {
if (i >= r && i < (r + B.getRows()) && j >= c && j < (c + B.getCols())) {
C[i][j] = B[i - r][j - c];
}
Expand All @@ -1236,7 +1236,7 @@ template <class Type> bool vpArray2D<Type>::operator==(const vpArray2D<Type> &A)
return false;
}

for (unsigned int i = 0; i < A.size(); i++) {
for (unsigned int i = 0; i < A.size(); ++i) {
if (data[i] != A.data[i]) {
return false;
}
Expand All @@ -1254,7 +1254,7 @@ template <> inline bool vpArray2D<double>::operator==(const vpArray2D<double> &A
return false;
}

for (unsigned int i = 0; i < A.size(); i++) {
for (unsigned int i = 0; i < A.size(); ++i) {
if (fabs(data[i] - A.data[i]) > std::numeric_limits<double>::epsilon()) {
return false;
}
Expand All @@ -1272,7 +1272,7 @@ template <> inline bool vpArray2D<float>::operator==(const vpArray2D<float> &A)
return false;
}

for (unsigned int i = 0; i < A.size(); i++) {
for (unsigned int i = 0; i < A.size(); ++i) {
if (fabsf(data[i] - A.data[i]) > std::numeric_limits<float>::epsilon()) {
return false;
}
Expand Down
30 changes: 15 additions & 15 deletions modules/core/include/visp3/core/vpColVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class vpPoseVector;
* v[0] = -1; v[1] = -2.1; v[2] = -3;
*
* std::cout << "v:" << std::endl;
* for (unsigned int i = 0; i < v.size(); i++) {
* for (unsigned int i = 0; i < v.size(); ++i) {
* std::cout << v[i] << std::endl;
* }
* }
Expand Down Expand Up @@ -288,7 +288,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* int main()
* {
* vpColVector v(3);
* for (unsigned int i=0; i<v.size(); i++)
* for (unsigned int i=0; i<v.size(); ++i)
* v[i] = i;
* v.cppPrint(std::cout, "v");
* }
Expand Down Expand Up @@ -316,7 +316,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* {
* std::ofstream ofs("log.csv", std::ofstream::out);
* vpColVector v(3);
* for (unsigned int i=0; i<v.size(); i++)
* for (unsigned int i=0; i<v.size(); ++i)
* v[i] = i;
*
* v.csvPrint(ofs);
Expand Down Expand Up @@ -357,7 +357,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
*
* \code
* vpColVector v1;
* for (unsigned int i=0; i<4; i++)
* for (unsigned int i=0; i<4; ++i)
* v1.stack(i);
* // v1 is equal to [0 1 2 3]^T
* vpColVector v2 = v1.extract(1, 3);
Expand Down Expand Up @@ -429,7 +429,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* {
* vpColVector v(4);
* int val = 0;
* for(size_t i=0; i<v.getRows(); i++) {
* for(size_t i=0; i<v.getRows(); ++i) {
* v[i] = val++;
* }
* std::cout << "v: " << v.t() << std::endl;
Expand Down Expand Up @@ -459,12 +459,12 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* int main()
* {
* vpColVector v(4);
* for (unsigned int i=0; i < v.size(); i++)
* for (unsigned int i=0; i < v.size(); ++i)
* v[i] = i;
* std::cout << "v: " << v.t() << std::endl;
*
* vpColVector w(2);
* for (unsigned int i=0; i < w.size(); i++)
* for (unsigned int i=0; i < w.size(); ++i)
* w[i] = i+10;
* std::cout << "w: " << w.t() << std::endl;
*
Expand All @@ -491,7 +491,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* int main()
* {
* vpColVector v(3);
* for (unsigned int i=0; i<v.size(); i++)
* for (unsigned int i=0; i<v.size(); ++i)
* v[i] = i;
* std::cout << "v = "; v.maplePrint(std::cout);
* }
Expand Down Expand Up @@ -520,7 +520,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* int main()
* {
* vpColVector v(3);
* for (unsigned int i=0; i<v.size(); i++)
* for (unsigned int i=0; i<v.size(); ++i)
* v[i] = i;
* std::cout << "v = "; v.matlabPrint(std::cout);
* }
Expand Down Expand Up @@ -862,7 +862,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* int main()
* {
* vpColVector A, B(5);
* for (unsigned int i=0; i<B.size(); i++)
* for (unsigned int i=0; i<B.size(); ++i)
* B[i] = i;
* A << B;
* std::cout << "A: " << A.t() << std::endl;
Expand All @@ -887,7 +887,7 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* size_t n = 5;
* vpColVector A(n);
* double *B = new double [n];
* for (unsigned int i = 0; i < n; i++)
* for (unsigned int i = 0; i < n; ++i)
* B[i] = i;
* A << B;
* std::cout << "A: " << A.t() << std::endl;
Expand Down Expand Up @@ -993,8 +993,8 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* {
* int var=0;
* vpMatrix mat(3, 4);
* for (int i = 0; i < 3; i++)
* for (int j = 0; j < 4; j++)
* for (int i = 0; i < 3; ++i)
* for (int j = 0; j < 4; ++j)
* mat[i][j] = ++var;
* std::cout << "mat: \n" << mat << std::endl;
*
Expand Down Expand Up @@ -1369,12 +1369,12 @@ class VISP_EXPORT vpColVector : public vpArray2D<double>
* int main()
* {
* vpColVector v(4);
* for (unsigned int i=0; i < v.size(); i++)
* for (unsigned int i=0; i < v.size(); ++i)
* v[i] = i;
* std::cout << "v: " << v.t() << std::endl;
*
* vpColVector w(2);
* for (unsigned int i=0; i < w.size(); i++)
* for (unsigned int i=0; i < w.size(); ++i)
* w[i] = i+10;
* std::cout << "w: " << w.t() << std::endl;
*
Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/visp3/core/vpDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
* std::cout << "Check keyboard events..." << std::endl;
* char key[10]; sprintf(key, "\0");
* bool ret;
* for (int i=0; i< 200; i++) {
* for (int i=0; i< 200; ++i) {
* bool ret = vpDisplay::getKeyboardEvent(I, key, false);
* if (ret)
* std::cout << "keyboard event: key: " << "\"" << key
Expand Down
Loading

0 comments on commit ed78d68

Please sign in to comment.