From 05fa0b24b9493edc9a0cc95fdec5068793c10398 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 29 Aug 2024 09:52:51 +0200 Subject: [PATCH] [EDF30834] : warning hunting --- CMakeLists.txt | 2 +- src/ShapeRecogn/MathOps.cxx | 35 +++++++++++++++++--------------- src/ShapeRecogn/NodesBuilder.cxx | 6 +++--- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbc37f053..1c36a9189 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,7 +205,7 @@ ENDIF(MEDCOUPLING_ENABLE_RENUMBER) IF(MEDCOUPLING_ENABLE_SHAPERECOGN) FIND_PACKAGE(BLAS REQUIRED) FIND_PACKAGE(LAPACK REQUIRED) - FIND_LIBRARY(LAPACKE_LIB NAMES lapacke64 REQUIRED) + FIND_LIBRARY(LAPACKE_LIB NAMES lapacke REQUIRED) SET(LAPACK_LIBRARIES ${LAPACKE_LIB} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) FIND_PATH(LAPACKE_INCLUDE_DIRS NAMES lapacke.h HINTS ${LAPACK_LIBRARIES}) IF(LAPACK_FOUND) diff --git a/src/ShapeRecogn/MathOps.cxx b/src/ShapeRecogn/MathOps.cxx index 8f1705ace..2e5994792 100644 --- a/src/ShapeRecogn/MathOps.cxx +++ b/src/ShapeRecogn/MathOps.cxx @@ -18,12 +18,15 @@ // #include "MathOps.hxx" +#include "MCIdType.hxx" #include #include #include #include #include +#include +#include using namespace MEDCoupling; @@ -64,11 +67,11 @@ std::vector MathOps::lstsqRow( std::vector &a, const std::vector &b) { - int m = b.size(); - int n = 3; - int nrhs = 1; - int ldb = std::max(m, n); - int lds = std::min(m, n); + auto m = b.size(); + std::size_t n = 3; + std::size_t nrhs = 1; + std::size_t ldb = std::max(m, n); + std::size_t lds = std::min(m, n); std::vector x(ldb, 0.0); for (size_t i = 0; i < b.size(); ++i) x[i] = b[i]; @@ -77,9 +80,9 @@ std::vector MathOps::lstsqRow( int rank = 0; int info = LAPACKE_dgelsd( LAPACK_ROW_MAJOR, - m, n, nrhs, - a.data(), n, - x.data(), nrhs, + FromIdType(m), FromIdType(n), FromIdType(nrhs), + a.data(), FromIdType(n), + x.data(), FromIdType(nrhs), s.data(), rcond, &rank); @@ -152,7 +155,7 @@ double MathOps::mean(const std::vector &values) double mean = 0.0; for (double value : values) mean += value; - return mean / values.size(); + return mean / double( values.size() ); } std::array MathOps::meanCoordinates(const std::vector &coordinates) @@ -165,9 +168,9 @@ std::array MathOps::meanCoordinates(const std::vector &coordi coordsMean[1] += coordinates[3 * nodeId + 1]; coordsMean[2] += coordinates[3 * nodeId + 2]; } - coordsMean[0] /= nbNodes; - coordsMean[1] /= nbNodes; - coordsMean[2] /= nbNodes; + coordsMean[0] /= double( nbNodes ); + coordsMean[1] /= double( nbNodes ); + coordsMean[2] /= double( nbNodes ); return coordsMean; } @@ -234,13 +237,13 @@ double MathOps::computeQuantile(const std::vector &values, double q) { std::vector sortedValues(values); std::sort(sortedValues.begin(), sortedValues.end()); - double pos = q * (sortedValues.size() - 1); + double pos = q * double(sortedValues.size() - 1); size_t index = static_cast(pos); - if (pos == index) + if ( std::abs( pos - double(index) ) < 1e-12 ) return sortedValues[index]; else { - double frac = pos - index; + double frac = pos - double(index); return sortedValues[index] * (1 - frac) + sortedValues[index + 1] * frac; } } @@ -265,7 +268,7 @@ std::vector MathOps::computeAngles( cblas_dgemv( CBLAS_LAYOUT::CblasRowMajor, CBLAS_TRANSPOSE::CblasNoTrans, - nbDirections, 3, 1.0, + int(nbDirections), 3, 1.0, directions.data(), 3, axis.data(), 1, 0.0, angles.data(), 1); diff --git a/src/ShapeRecogn/NodesBuilder.cxx b/src/ShapeRecogn/NodesBuilder.cxx index 1302d3203..206c97387 100644 --- a/src/ShapeRecogn/NodesBuilder.cxx +++ b/src/ShapeRecogn/NodesBuilder.cxx @@ -46,10 +46,10 @@ void NodesBuilder::computeNormals() mesh->getReverseNodalConnectivity(revNodal, revNodalIdx); for (size_t nodeId = 0; nodeId < (size_t)nbNodes; nodeId++) { - int nbCells = revNodalIdx->getIJ(nodeId + 1, 0) - - revNodalIdx->getIJ(nodeId, 0); + mcIdType nbCells = revNodalIdx->getIJ(nodeId + 1, 0) - + revNodalIdx->getIJ(nodeId, 0); std::vector cellIds(nbCells, 0); - int start = revNodalIdx->getIJ(nodeId, 0); + mcIdType start = revNodalIdx->getIJ(nodeId, 0); for (size_t i = 0; i < cellIds.size(); ++i) cellIds[i] = revNodal->getIJ(start + i, 0); double normal = 0.0; -- 2.39.2