//
#include "MathOps.hxx"
+#include "MCIdType.hxx"
#include <algorithm>
#include <lapacke.h>
#include <cblas.h>
#include <iostream>
#include <cfloat>
+#include <cmath>
+#include <cstdlib>
using namespace MEDCoupling;
std::vector<double> &a,
const std::vector<double> &b)
{
- int m = b.size();
- int n = 3;
- int nrhs = 1;
- int ldb = std::max<int>(m, n);
- int lds = std::min<int>(m, n);
+ auto m = b.size();
+ std::size_t n = 3;
+ std::size_t nrhs = 1;
+ std::size_t ldb = std::max<std::size_t>(m, n);
+ std::size_t lds = std::min<std::size_t>(m, n);
std::vector<double> x(ldb, 0.0);
for (size_t i = 0; i < b.size(); ++i)
x[i] = b[i];
int rank = 0;
int info = LAPACKE_dgelsd(
LAPACK_ROW_MAJOR,
- m, n, nrhs,
- a.data(), n,
- x.data(), nrhs,
+ FromIdType<int>(m), FromIdType<int>(n), FromIdType<int>(nrhs),
+ a.data(), FromIdType<int>(n),
+ x.data(), FromIdType<int>(nrhs),
s.data(),
rcond,
&rank);
double mean = 0.0;
for (double value : values)
mean += value;
- return mean / values.size();
+ return mean / double( values.size() );
}
std::array<double, 3> MathOps::meanCoordinates(const std::vector<double> &coordinates)
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;
}
{
std::vector<double> 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<size_t>(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;
}
}
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);
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<mcIdType> 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;