Fixing compiler warnings, part 1

This commit is contained in:
Ray Speth 2012-01-17 04:10:08 +00:00
parent e960f715b7
commit 4babd5898b
43 changed files with 193 additions and 221 deletions

View file

@ -110,7 +110,7 @@ extern "C" {
return _mix(i)->nSpecies();
}
int DLL_EXPORT mix_speciesIndex(int i, int k, int p) {
size_t DLL_EXPORT mix_speciesIndex(int i, int k, int p) {
return _mix(i)->speciesIndex(k, p);
}

View file

@ -16,7 +16,7 @@ extern "C" {
EEXXTT int DLL_CPREFIX mix_init(int i);
EEXXTT int DLL_CPREFIX mix_nElements(int i);
EEXXTT int DLL_CPREFIX mix_elementIndex(int i, char* name);
EEXXTT int DLL_CPREFIX mix_speciesIndex(int i, int k, int p);
EEXXTT size_t DLL_CPREFIX mix_speciesIndex(int i, int k, int p);
EEXXTT int DLL_CPREFIX mix_nSpecies(int i);
EEXXTT int DLL_CPREFIX mix_setTemperature(int i, double t);
EEXXTT double DLL_CPREFIX mix_temperature(int i);

View file

@ -65,7 +65,7 @@ namespace Cantera {
* @param n Number of columns
* @param v Default fill value. The default is 0.0
*/
Array2D(const int m, const int n, const doublereal v = 0.0)
Array2D(const size_t m, const size_t n, const doublereal v = 0.0)
: m_data(0), m_nrows(m), m_ncols(n) {
m_data.resize(n*m);
std::fill(m_data.begin(), m_data.end(), v);
@ -105,7 +105,7 @@ namespace Cantera {
* @param m This is the number of columns in the new matrix
* @param v Default fill value -> defaults to zero.
*/
void resize(int n, int m, doublereal v = 0.0) {
void resize(size_t n, size_t m, doublereal v = 0.0) {
m_nrows = n;
m_ncols = m;
m_data.resize(n*m, v);
@ -122,7 +122,7 @@ namespace Cantera {
void appendColumn(const vector_fp& c) {
m_ncols++;
m_data.resize(m_nrows*m_ncols);
int m;
size_t m;
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
}
@ -137,7 +137,7 @@ namespace Cantera {
void appendColumn(const doublereal* const c) {
m_ncols++;
m_data.resize(m_nrows*m_ncols);
int m;
size_t m;
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
}
@ -146,8 +146,8 @@ namespace Cantera {
* @param n Index of the row to be changed
* @param rw Vector for the row. Must have a length of m_ncols.
*/
void setRow(int n, const doublereal* const rw) {
for (int j = 0; j < m_ncols; j++) {
void setRow(size_t n, const doublereal* const rw) {
for (size_t j = 0; j < m_ncols; j++) {
m_data[m_nrows*j + n] = rw[j];
}
}
@ -158,8 +158,8 @@ namespace Cantera {
* @param rw Return Vector for the operation.
* Must have a length of m_ncols.
*/
void getRow(int n, doublereal* const rw) {
for (int j = 0; j < m_ncols; j++) {
void getRow(size_t n, doublereal* const rw) {
for (size_t j = 0; j < m_ncols; j++) {
rw[j] = m_data[m_nrows*j + n];
}
}
@ -172,8 +172,8 @@ namespace Cantera {
* @param col pointer to a col vector. Vector
* must have a length of m_nrows.
*/
void setColumn(int m, doublereal* const col) {
for (int i = 0; i < m_nrows; i++) {
void setColumn(size_t m, doublereal* const col) {
for (size_t i = 0; i < m_nrows; i++) {
m_data[m_nrows*m + i] = col[i];
}
}
@ -185,8 +185,8 @@ namespace Cantera {
* @param m Column to set
* @param col pointer to a col vector that will be returned
*/
void getColumn(int m, doublereal* const col) {
for (int i = 0; i < m_nrows; i++) {
void getColumn(size_t m, doublereal* const col) {
for (size_t i = 0; i < m_nrows; i++) {
col[i] = m_data[m_nrows*m + i];
}
}
@ -224,7 +224,7 @@ namespace Cantera {
*
* @return Returns a reference to A(i,j) which may be assigned.
*/
doublereal& operator()( int i, int j) { return value(i,j); }
doublereal& operator()(size_t i, size_t j) { return value(i,j); }
//! Allows retrieving elements using the syntax x = A(i,j).
@ -234,7 +234,7 @@ namespace Cantera {
*
* @return Returns the value of the matrix entry
*/
doublereal operator() (int i, int j) const {
doublereal operator() (size_t i, size_t j) const {
return value(i,j);
}
@ -248,7 +248,7 @@ namespace Cantera {
*
* @return Returns a changeable reference to the matrix entry
*/
doublereal& value(int i, int j) {
doublereal& value(size_t i, size_t j) {
return m_data[m_nrows*j + i];
}
@ -260,7 +260,7 @@ namespace Cantera {
* @param i The row index
* @param j The column index
*/
doublereal value(int i, int j) const {
doublereal value(size_t i, size_t j) const {
return m_data[m_nrows*j + i];
}
@ -295,7 +295,7 @@ namespace Cantera {
*
* @return Returns a pointer to the top of the column
*/
doublereal * ptrColumn(int j) { return &(m_data[m_nrows*j]); }
doublereal * ptrColumn(size_t j) { return &(m_data[m_nrows*j]); }
//! Return a const pointer to the top of column j, columns are contiguous
//! in memory
@ -304,7 +304,7 @@ namespace Cantera {
*
* @return Returns a const pointer to the top of the column
*/
const doublereal * ptrColumn(int j) const {
const doublereal * ptrColumn(size_t j) const {
return &(m_data[m_nrows*j]);
}
@ -314,10 +314,10 @@ namespace Cantera {
vector_fp m_data;
//! Number of rows
int m_nrows;
size_t m_nrows;
//! Number of columns
int m_ncols;
size_t m_ncols;
};
//! Output the current contents of the Array2D object
@ -331,9 +331,9 @@ namespace Cantera {
* @return Returns a reference to the ostream.
*/
inline std::ostream& operator<<(std::ostream& s, const Array2D& m) {
int nr = static_cast<int>(m.nRows());
int nc = static_cast<int>(m.nColumns());
int i,j;
size_t nr = m.nRows();
size_t nc = m.nColumns();
size_t i,j;
for (i = 0; i < nr; i++) {
for (j = 0; j < nc; j++) {
s << m(i,j) << ", ";

View file

@ -110,8 +110,8 @@ namespace Cantera {
// Set to upper case and scientific notation
m_cout.setf(ios_base::scientific | ios_base::uppercase);
int wold = m_cout.width(wMin);
int pold = m_cout.precision(p);
int wold = (int) m_cout.width(wMin);
int pold = (int) m_cout.precision(p);
m_cout << d;
// Return the precision to the previous value;

View file

@ -113,7 +113,7 @@ namespace Cantera {
* @param sz This is the length supplied to Cantera.
* @param reqd This is the required length needed by Cantera
*/
ArraySizeError(std::string procedure, int sz, int reqd);
ArraySizeError(std::string procedure, size_t sz, size_t reqd);
};
//! An element index is out of range.
@ -133,7 +133,7 @@ namespace Cantera {
* @param mmax This is the maximum allowed value of the index. The
* minimum allowed value is assumed to be 0.
*/
ElementRangeError(std::string func, int m, int mmax);
ElementRangeError(std::string func, size_t m, size_t mmax);
};
//! Print a warning when a deprecated method is called.

View file

@ -878,9 +878,9 @@ namespace ctml {
*
* @return Returns the number of floats read
*/
int getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
const bool convert, const std::string unitsString,
const std::string nodeName) {
size_t getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
const bool convert, const std::string unitsString,
const std::string nodeName) {
string::size_type icom;
string numstr;
doublereal dtmp;
@ -938,8 +938,7 @@ namespace ctml {
* would appear to be odd. So, we keep the
* possibilty in for backwards compatibility.
*/
int nlen = strlen(val.c_str());
if (nlen > 0) {
if (!val.empty()) {
dtmp = atofCheck(val.c_str());
v.push_back(dtmp);
}
@ -955,8 +954,7 @@ namespace ctml {
" is above upper limit of " +fp2str(vmin)+".\n");
}
}
int nv = v.size();
for (int n = 0; n < nv; n++) {
for (size_t n = 0; n < v.size(); n++) {
v[n] *= funit;
}
return v.size();
@ -1094,10 +1092,10 @@ namespace ctml {
const std::vector<std::string>& keyStringCol,
Cantera::Array2D &retnValues, const bool convert,
const bool matrixSymmetric) {
int szKey1 = keyStringRow.size();
int szKey2 = keyStringCol.size();
int nrow = retnValues.nRows();
int ncol = retnValues.nColumns();
size_t szKey1 = keyStringRow.size();
size_t szKey2 = keyStringCol.size();
size_t nrow = retnValues.nRows();
size_t ncol = retnValues.nColumns();
if (szKey1 > nrow) {
throw CanteraError("getMatrixValues",
"size of key1 greater than numrows");

View file

@ -361,9 +361,9 @@ namespace ctml {
* The default value for the node name is floatArray
* @return Returns the number of floats read into v.
*/
int getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
const bool convert=true, const std::string unitsString="",
const std::string nodeName = "floatArray");
size_t getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
const bool convert=true, const std::string unitsString="",
const std::string nodeName = "floatArray");
//! This function interprets the value portion of an XML element
//! as a string. It then separates the string up into tokens

View file

@ -1522,13 +1522,13 @@ protected:
app()->addError(proc, msg);
}
ArraySizeError::ArraySizeError(std::string proc, int sz, int reqd) :
CanteraError(proc, "Array size ("+int2str(sz)+
") too small. Must be at least "+int2str(reqd)) {}
ArraySizeError::ArraySizeError(std::string proc, size_t sz, size_t reqd) :
CanteraError(proc, "Array size ("+int2str(int(sz))+
") too small. Must be at least "+int2str(int(reqd))) {}
ElementRangeError::ElementRangeError(std::string func, int m, int mmax) :
CanteraError(func, "Element index " + int2str(m) +
" outside valid range of 0 to " + int2str(mmax-1)) {}
ElementRangeError::ElementRangeError(std::string func, size_t m, size_t mmax) :
CanteraError(func, "Element index " + int2str(int(m)) +
" outside valid range of 0 to " + int2str(int(mmax-1))) {}

View file

@ -326,10 +326,9 @@ namespace Cantera {
* default is 70.
*/
std::string wrapString(const std::string& s, const int len) {
int nc = s.size();
int n, count=0;
int count=0;
std::string r;
for (n = 0; n < nc; n++) {
for (size_t n = 0; n < s.size(); n++) {
if (s[n] == '\n') count = 0;
else count++;
if (count > len && s[n] == ' ') {
@ -486,7 +485,7 @@ namespace Cantera {
std::vector<std::string> v;
tokenizeString(strSI, v);
doublereal fp = 1.0;
int n = v.size();
size_t n = v.size();
if (n > 2 || n < 1) {
throw CanteraError("strSItoDbl",
"number of tokens is too high");

View file

@ -1272,7 +1272,7 @@ namespace Cantera {
if (ieol == 0) {
s << endl << indent << " ";
} else {
int jf = ieol - 1;
size_t jf = ieol - 1;
for (int j = 0; j < (int) ieol; j++) {
if (! isspace(vv[j])) {
jf = j;

View file

@ -1063,15 +1063,13 @@ namespace Cantera {
double oldf, vector_fp& grad, vector_fp& step, vector_fp& x,
double& f, vector_fp& elmols, double xval, double yval )
{
int nvar = x.size();
int m;
double damp;
/*
* Carry out a delta damping approach on the dimensionless element potentials.
*/
damp = 1.0;
for (m = 0; m < m_mm; m++) {
for (size_t m = 0; m < m_mm; m++) {
if (m == m_eloc) {
if (step[m] > 1.25) {
damp = MIN(damp, 1.25 /step[m]);
@ -1092,7 +1090,7 @@ namespace Cantera {
/*
* Update the solution unknown
*/
for (m = 0; m < nvar; m++) {
for (size_t m = 0; m < x.size(); m++) {
x[m] = oldx[m] + damp * step[m];
}
#ifdef DEBUG_MODE
@ -1193,12 +1191,12 @@ namespace Cantera {
{
if (loglevel > 0)
beginLogGroup("equilJacobian");
int len = x.size();
vector_fp& r0 = m_jwork1;
vector_fp& r1 = m_jwork2;
size_t len = x.size();
r0.resize(len);
r1.resize(len);
int n, m;
size_t n, m;
doublereal rdx, dx, xsave, dx2;
doublereal atol = 1.e-10;
@ -1220,7 +1218,7 @@ namespace Cantera {
// compute nth column of Jacobian
for (m = 0; m < len; m++) {
for (m = 0; m < x.size(); m++) {
jac(m, n) = (r1[m] - r0[m])*rdx;
}
x[n] = xsave;

View file

@ -133,7 +133,7 @@ namespace Cantera {
thermo_t* m_phase;
/// number of atoms of element m in species k.
doublereal nAtoms(int k, int m) const { return m_comp[k*m_mm + m]; }
doublereal nAtoms(size_t k, size_t m) const { return m_comp[k*m_mm + m]; }
void initialize(thermo_t& s);
@ -227,7 +227,7 @@ namespace Cantera {
* pressure of the solution (the star standard state).
*/
vector_fp m_muSS_RT;
vector_int m_component;
std::vector<size_t> m_component;
/*
* element fractional cutoff, below which the element will be

View file

@ -242,7 +242,7 @@ namespace Cantera {
/// @param p index of the phase for which the charge is desired.
doublereal MultiPhase::phaseCharge(index_t p) const {
doublereal phasesum = 0.0;
int ik, k, nsp = m_phase[p]->nSpecies();
size_t ik, k, nsp = m_phase[p]->nSpecies();
for (ik = 0; ik < nsp; ik++) {
k = speciesIndex(ik, p);
phasesum += m_phase[p]->charge(ik)*m_moleFractions[k];
@ -501,7 +501,7 @@ namespace Cantera {
void MultiPhase::calcElemAbundances() const {
index_t loc = 0;
index_t eGlobal;
int ik, kGlobal;
index_t ik, kGlobal;
doublereal spMoles;
for (eGlobal = 0; eGlobal < m_nel; eGlobal++) {
m_elemAbundances[eGlobal] = 0.0;
@ -852,26 +852,26 @@ namespace Cantera {
}
// Name of element \a m.
std::string MultiPhase::elementName(int m) const {
std::string MultiPhase::elementName(size_t m) const {
return m_enames[m];
}
// Index of element with name \a name.
int MultiPhase::elementIndex(std::string name) const {
size_t MultiPhase::elementIndex(std::string name) const {
for (size_t e = 0; e < m_nel; e++) {
if (m_enames[e] == name) {
return (int) e;
return e;
}
}
return -1;
}
// Name of species with global index \a k.
std::string MultiPhase::speciesName(const int k) const {
std::string MultiPhase::speciesName(const size_t k) const {
return m_snames[k];
}
doublereal MultiPhase::nAtoms(const int kGlob, const int mGlob) const {
doublereal MultiPhase::nAtoms(const size_t kGlob, const size_t mGlob) const {
return m_atoms(mGlob, kGlob);
}

View file

@ -114,28 +114,28 @@ namespace Cantera {
void addPhase(phase_t* p, doublereal moles);
/// Number of elements.
int nElements() const { return int(m_nel); }
size_t nElements() const { return m_nel; }
//! Returns the string name of the global element \a m.
/*!
* @param m index of the global element
*/
std::string elementName(int m) const;
std::string elementName(size_t m) const;
//! Returns the index of the element with name \a name.
/*!
* @param name String name of the global element
*/
int elementIndex(std::string name) const;
size_t elementIndex(std::string name) const;
//! Number of species, summed over all phases.
int nSpecies() const { return int(m_nsp); }
size_t nSpecies() const { return m_nsp; }
//! Name of species with global index \a kGlob
/*!
* @param kGlob global species index
*/
std::string speciesName(const int kGlob) const;
std::string speciesName(const size_t kGlob) const;
//! Returns the Number of atoms of global element \a mGlob in
//! global species \a kGlob.
@ -144,7 +144,7 @@ namespace Cantera {
* @param mGlob global element index
* @return returns the number of atoms.
*/
doublereal nAtoms(const int kGlob, const int mGlob) const;
doublereal nAtoms(const size_t kGlob, const size_t mGlob) const;
/// Returns the global Species mole fractions.
/*!
@ -221,7 +221,7 @@ namespace Cantera {
* @param k local index of the species within the phase
* @param p index of the phase
*/
int speciesIndex(index_t k, index_t p) const {
size_t speciesIndex(index_t k, index_t p) const {
return m_spstart[p] + k;
}
@ -596,7 +596,7 @@ namespace Cantera {
* m_spphase[kGlobal] = iPhase
* Length = number of global species
*/
vector_int m_spphase;
std::vector<size_t> m_spphase;
//! Vector of ints containing of first species index in the global list of species
//! for each phase
@ -604,7 +604,7 @@ namespace Cantera {
* kfirst = m_spstart[ip], kfirst is the index of the first species in the ip'th
* phase.
*/
vector_int m_spstart;
std::vector<size_t> m_spstart;
//! String names of the global elements
/*!
@ -629,7 +629,7 @@ namespace Cantera {
/*!
* -> used in the construction. However, wonder if it needs to be global.
*/
std::map<std::string, int> m_enamemap;
std::map<std::string, size_t> m_enamemap;
/**
* Number of phases in the MultiPhase object
@ -658,7 +658,7 @@ namespace Cantera {
/*!
* If there is none, then this is equal to -1
*/
int m_eloc;
size_t m_eloc;
//! Vector of bools indicating whether temperatures are ok for phases.
/*!

View file

@ -373,9 +373,8 @@ namespace Cantera {
/// to be components in declaration order, beginning with the
/// first phase added.
///
void MultiPhaseEquil::getComponents(const vector_int& order) {
void MultiPhaseEquil::getComponents(const std::vector<size_t>& order) {
index_t m, k, j;
int n;
// if the input species array has the wrong size, ignore it
// and consider the species for components in declaration order.
@ -428,7 +427,7 @@ namespace Cantera {
// Now exchange the column with zero pivot with the
// column for this major species
for (n = 0; n < int(nRows); n++) {
for (size_t n = 0; n < nRows; n++) {
tmp = m_A(n,m);
m_A(n, m) = m_A(n, kmax);
m_A(n, kmax) = tmp;
@ -449,7 +448,7 @@ namespace Cantera {
// For all rows below the diagonal, subtract A(n,m)/A(m,m)
// * (row m) from row n, so that A(n,m) = 0.
for (n = int(m+1); n < int(m_nel); n++) {
for (size_t n = m+1; n < m_nel; n++) {
fctr = m_A(n,m)/m_A(m,m);
for (k = 0; k < m_nsp; k++) {
m_A(n,k) -= m_A(m,k)*fctr;
@ -461,7 +460,7 @@ namespace Cantera {
// The left m_nel columns of A are now upper-diagonal. Now
// reduce the m_nel columns to diagonal form by back-solving
for (m = nRows-1; m > 0; m--) {
for (n = m-1; n>= 0; n--) {
for (size_t n = m-1; n>= 0; n--) {
if (m_A(n,m) != 0.0) {
fctr = m_A(n,m);
for (k = m; k < m_nsp; k++) {
@ -472,8 +471,8 @@ namespace Cantera {
}
// create stoichometric coefficient matrix.
for (n = 0; n < int(m_nsp); n++) {
if (n < int(m_nel))
for (size_t n = 0; n < m_nsp; n++) {
if (n < m_nel)
for (k = 0; k < m_nsp - m_nel; k++)
m_N(n, k) = -m_A(n, k + m_nel);
else {
@ -879,13 +878,13 @@ namespace Cantera {
*
*/
void MultiPhaseEquil::reportCSV(const std::string &reportFile) {
int k;
int istart;
int nSpecies;
size_t k;
size_t istart;
size_t nSpecies;
double vol = 0.0;
string sName;
int nphase = m_np;
size_t nphase = m_np;
FILE * FP = fopen(reportFile.c_str(), "w");
if (!FP) {
@ -906,7 +905,7 @@ namespace Cantera {
vol = 0.0;
for (int iphase = 0; iphase < nphase; iphase++) {
for (size_t iphase = 0; iphase < nphase; iphase++) {
istart = m_mix->speciesIndex(0, iphase);
ThermoPhase &tref = m_mix->phase(iphase);
nSpecies = tref.nSpecies();
@ -931,7 +930,7 @@ namespace Cantera {
// fprintf(FP,"Number Basis optimizations = %d\n", m_vprob->m_NumBasisOptimizations);
// fprintf(FP,"Number VCS iterations = %d\n", m_vprob->m_Iterations);
for (int iphase = 0; iphase < nphase; iphase++) {
for (size_t iphase = 0; iphase < nphase; iphase++) {
istart = m_mix->speciesIndex(0, iphase);
ThermoPhase &tref = m_mix->phase(iphase);

View file

@ -81,7 +81,7 @@ namespace Cantera {
protected:
void getComponents(const vector_int& order);
void getComponents(const std::vector<size_t>& order);
int setInitialMoles(int loglevel = 0);
void computeN();
doublereal stepComposition(int loglevel = 0);
@ -93,12 +93,12 @@ namespace Cantera {
void finish();
// moles of the species with sorted index ns
double moles(int ns) const { return m_moles[m_order[ns]]; }
double& moles(int ns) { return m_moles[m_order[ns]]; }
int solutionSpecies(int n) const { return m_dsoln[m_order[n]]; }
bool isStoichPhase(int n) const { return (m_dsoln[m_order[n]] == 0); }
doublereal mu(int n) const { return m_mu[m_species[m_order[n]]]; }
std::string speciesName(int n) const { return
double moles(size_t ns) const { return m_moles[m_order[ns]]; }
double& moles(size_t ns) { return m_moles[m_order[ns]]; }
int solutionSpecies(size_t n) const { return m_dsoln[m_order[n]]; }
bool isStoichPhase(size_t n) const { return (m_dsoln[m_order[n]] == 0); }
doublereal mu(size_t n) const { return m_mu[m_species[m_order[n]]]; }
std::string speciesName(size_t n) const { return
m_mix->speciesName(m_species[m_order[n]]); }
index_t m_nel_mix, m_nsp_mix, m_np;
@ -107,13 +107,13 @@ namespace Cantera {
int m_iter;
mix_t* m_mix;
doublereal m_press, m_temp;
vector_int m_order;
std::vector<size_t> m_order;
matrix_t m_N, m_A;
vector_fp m_work, m_work2, m_work3;
vector_fp m_moles, m_lastmoles, m_dxi;
vector_fp m_deltaG_RT, m_mu;
std::vector<bool> m_majorsp;
vector_int m_sortindex;
std::vector<size_t> m_sortindex;
vector_int m_lastsort;
vector_int m_dsoln;
vector_int m_incl_element, m_incl_species;
@ -121,8 +121,8 @@ namespace Cantera {
// Vector of indices for species that are included in the
// calculation. This is used to exclude pure-phase species
// with invalid thermo data
vector_int m_species;
vector_int m_element;
std::vector<size_t> m_species;
std::vector<size_t> m_element;
std::vector<bool> m_solnrxn;
bool m_force;
};

View file

@ -736,9 +736,9 @@ namespace VCSnonideal {
*
*/
void vcs_MultiPhaseEquil::reportCSV(const std::string &reportFile) {
int k;
int istart;
int nSpecies;
size_t k;
size_t istart;
size_t nSpecies;
double vol = 0.0;
string sName;

View file

@ -20,22 +20,21 @@ namespace Cantera {
return *this;
}
void DenseMatrix::resize(int n, int m, doublereal v) {
void DenseMatrix::resize(size_t n, size_t m, doublereal v) {
Array2D::resize(n,m,v);
m_ipiv.resize( max(n,m) );
}
void DenseMatrix::mult(const double* b, double* prod) const {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose,
static_cast<int>(nRows()),
static_cast<int>(nRows()), 1.0, ptrColumn(0), //begin(),
static_cast<int>(nRows()), b, 1, 0.0, prod, 1);
int(nRows()), int(nRows()), 1.0, ptrColumn(0),
int(nRows()), b, 1, 0.0, prod, 1);
}
void DenseMatrix::leftMult(const double* b, double* prod) const {
int nc = static_cast<int>(nColumns());
int nr = static_cast<int>(nRows());
int n, i;
size_t nc = nColumns();
size_t nr = nRows();
size_t n, i;
double sum = 0.0;
for (n = 0; n < nc; n++) {
sum = 0.0;
@ -48,17 +47,13 @@ namespace Cantera {
int solve(DenseMatrix& A, double* b) {
int info=0;
ct_dgetrf(static_cast<int>(A.nRows()),
static_cast<int>(A.nColumns()), A.ptrColumn(0), //begin(),
static_cast<int>(A.nRows()), &A.ipiv()[0], info);
ct_dgetrf(int(A.nRows()), int(A.nColumns()), A.ptrColumn(0),
int(A.nRows()), &A.ipiv()[0], info);
if (info != 0)
throw CanteraError("DenseMatrix::solve",
"DGETRF returned INFO = "+int2str(info));
ct_dgetrs(ctlapack::NoTranspose,
static_cast<int>(A.nRows()), 1, A.ptrColumn(0), //begin(),
static_cast<int>(A.nRows()),
&A.ipiv()[0], b,
static_cast<int>(A.nColumns()), info);
ct_dgetrs(ctlapack::NoTranspose, int(A.nRows()), 1, A.ptrColumn(0),
int(A.nRows()), &A.ipiv()[0], b, int(A.nColumns()), info);
if (info != 0)
throw CanteraError("DenseMatrix::solve",
"DGETRS returned INFO = "+int2str(info));
@ -67,24 +62,20 @@ namespace Cantera {
int solve(DenseMatrix& A, DenseMatrix& b) {
int info=0;
ct_dgetrf(static_cast<int>(A.nRows()),
static_cast<int>(A.nColumns()), A.ptrColumn(0),
static_cast<int>(A.nRows()), &A.ipiv()[0], info);
if (info != 0)
ct_dgetrf(int(A.nRows()), int(A.nColumns()), A.ptrColumn(0),
int(A.nRows()), &A.ipiv()[0], info);
if (info != 0)
throw CanteraError("DenseMatrix::solve",
"DGETRF returned INFO = "+int2str(info));
ct_dgetrs(ctlapack::NoTranspose, static_cast<int>(A.nRows()),
static_cast<int>(b.nColumns()),
A.ptrColumn(0), static_cast<int>(A.nRows()),
&A.ipiv()[0], b.ptrColumn(0),
static_cast<int>(b.nRows()), info);
ct_dgetrs(ctlapack::NoTranspose, int(A.nRows()), int(b.nColumns()),
A.ptrColumn(0), int(A.nRows()), &A.ipiv()[0], b.ptrColumn(0),
int(b.nRows()), info);
if (info != 0)
throw CanteraError("DenseMatrix::solve",
"DGETRS returned INFO = "+int2str(info));
return 0;
}
#ifdef INCL_LEAST_SQUARES
/** @todo fix lwork */
int leastSquares(DenseMatrix& A, double* b) {
@ -94,13 +85,10 @@ namespace Cantera {
// fix this!
int lwork = 6000; // 2*(3*min(m,n) + max(2*min(m,n), max(m,n)));
vector_fp work(lwork);
vector_fp s(min(static_cast<int>(A.nRows()),
static_cast<int>(A.nColumns())));
ct_dgelss(static_cast<int>(A.nRows()),
static_cast<int>(A.nColumns()), 1, A.ptrColumn(0),
static_cast<int>(A.nRows()), b,
static_cast<int>(A.nColumns()), &s[0], //.begin(),
rcond, rank, &work[0], work.size(), info);
vector_fp s(min(A.nRows(), A.nColumns()));
ct_dgelss(int(A.nRows()), int(A.nColumns()), 1, A.ptrColumn(0),
int(A.nRows()), b, int(A.nColumns()), &s[0], rcond, rank,
&work[0], work.size(), info);
if (info != 0)
throw CanteraError("DenseMatrix::leaseSquares",
"DGELSS returned INFO = "+int2str(info));
@ -109,36 +97,31 @@ namespace Cantera {
#endif
void multiply(const DenseMatrix& A, const double* b, double* prod) {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose,
static_cast<int>(A.nRows()), static_cast<int>(A.nColumns()), 1.0,
A.ptrColumn(0), static_cast<int>(A.nRows()), b, 1, 0.0, prod, 1);
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, int(A.nRows()),
int(A.nColumns()), 1.0, A.ptrColumn(0), int(A.nRows()), b, 1,
0.0, prod, 1);
}
void increment(const DenseMatrix& A,
const double* b, double* prod) {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose,
static_cast<int>(A.nRows()), static_cast<int>(A.nRows()), 1.0,
A.ptrColumn(0), static_cast<int>(A.nRows()), b, 1, 1.0, prod, 1);
void increment(const DenseMatrix& A, const double* b, double* prod) {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, int(A.nRows()),
int(A.nRows()), 1.0, A.ptrColumn(0), int(A.nRows()), b, 1, 1.0,
prod, 1);
}
int invert(DenseMatrix& A, int nn) {
integer n = (nn > 0 ? nn : static_cast<int>(A.nRows()));
int invert(DenseMatrix& A, size_t nn) {
int n = int(nn > 0 ? nn : A.nRows());
int info=0;
ct_dgetrf(n, n, A.ptrColumn(0), static_cast<int>(A.nRows()),
&A.ipiv()[0], info);
if (info != 0)
ct_dgetrf(n, n, A.ptrColumn(0), int(A.nRows()), &A.ipiv()[0], info);
if (info != 0)
throw CanteraError("invert",
"DGETRF returned INFO="+int2str(info));
vector_fp work(n);
integer lwork = static_cast<int>(work.size());
ct_dgetri(n, A.ptrColumn(0), static_cast<int>(A.nRows()),
&A.ipiv()[0],
&work[0], lwork, info);
if (info != 0)
ct_dgetri(n, A.ptrColumn(0), int(A.nRows()), &A.ipiv()[0], &work[0],
int(work.size()), info);
if (info != 0)
throw CanteraError("invert",
"DGETRI returned INFO="+int2str(info));
return 0;
}
}

View file

@ -28,7 +28,7 @@ namespace Cantera {
* Constructor. Create an \c n by \c m matrix, and initialize
* all elements to \c v.
*/
DenseMatrix(int n, int m, doublereal v = 0.0) : Array2D(n,m,v) {
DenseMatrix(size_t n, size_t m, doublereal v = 0.0) : Array2D(n,m,v) {
m_ipiv.resize( max(n, m) );
}
@ -40,7 +40,7 @@ namespace Cantera {
/// assignment.
DenseMatrix& operator=(const DenseMatrix& y);
void resize(int n, int m, doublereal v = 0.0);
void resize(size_t n, size_t m, doublereal v = 0.0);
/// Destructor. Does nothing.
virtual ~DenseMatrix(){}
@ -90,7 +90,7 @@ namespace Cantera {
/**
* invert A. A is overwritten with A^-1.
*/
int invert(DenseMatrix& A, int nn=-1);
int invert(DenseMatrix& A, size_t nn=-1);
}

View file

@ -130,9 +130,9 @@ void cblas_dscal(const int N, const double alpha, double *X, const int incX);
namespace Cantera {
inline void ct_dgemv(ctlapack::storage_t storage,
ctlapack::transpose_t trans,
int m, int n, doublereal alpha, const doublereal* a, int lda,
inline void ct_dgemv(ctlapack::storage_t storage,
ctlapack::transpose_t trans,
int m, int n, doublereal alpha, const doublereal* a, int lda,
const doublereal* x, int incX, doublereal beta,
doublereal* y, int incY)
{

View file

@ -8,7 +8,7 @@ namespace Cantera {
// sort (x,y) pairs by x
void heapsort(vector_fp& x, vector_int& y) {
void heapsort(vector_fp& x, std::vector<size_t>& y) {
int n = x.size();
if (n < 2) return;
doublereal rra;

View file

@ -11,7 +11,7 @@ namespace Cantera {
/// Given two arrays x and y, sort the (x,y) pairs by the x
/// values. This version is for floating-point x, and integer y.
void heapsort(vector_fp& x, vector_int& y);
void heapsort(vector_fp& x, std::vector<size_t>& y);
/// Given two arrays x and y, sort the (x,y) pairs by the x
/// values. This version is for floating-point x, and

View file

@ -103,7 +103,7 @@ namespace Cantera {
/*
* Return the atomic number of element m.
*/
int Constituents::atomicNumber(int m) const {
int Constituents::atomicNumber(size_t m) const {
return m_Elements->atomicNumber(m);
}
@ -195,7 +195,7 @@ namespace Cantera {
* \exception If m < 0 or m >= nElements(), the
* exception, ElementRangeError, is thrown.
*/
string Constituents::elementName(int m) const {
string Constituents::elementName(size_t m) const {
return (m_Elements->elementName(m));
}
@ -252,7 +252,7 @@ namespace Cantera {
* Electrical charge of one species k molecule, divided by
* \f$ e = 1.602 \times 10^{-19}\f$ Coulombs.
*/
doublereal Constituents::charge(int k) const {
doublereal Constituents::charge(size_t k) const {
return m_speciesCharge[k];
}
@ -420,7 +420,7 @@ namespace Cantera {
*
* Name of the species with index k
*/
string Constituents::speciesName(int k) const {
string Constituents::speciesName(size_t k) const {
if (k < 0 || k >= nSpecies())
throw SpeciesRangeError("Constituents::speciesName",
k, nSpecies());

View file

@ -102,7 +102,7 @@ namespace Cantera {
/// \param m Element index.
/// \exception If m < 0 or m >= nElements(), the
/// exception, ElementRangeError, is thrown.
std::string elementName(int m) const;
std::string elementName(size_t m) const;
/// Index of element named 'name'.
@ -133,7 +133,7 @@ namespace Cantera {
/*!
* @param m Element index
*/
int atomicNumber(int m) const;
int atomicNumber(size_t m) const;
/// Return a read-only reference to the vector of element names.
const std::vector<std::string>& elementNames() const;
@ -213,7 +213,7 @@ namespace Cantera {
//@}
/// Returns the number of species in the phase
int nSpecies() const { return m_kk; }
size_t nSpecies() const { return m_kk; }
//! Molecular weight of species \c k.
/*!
@ -248,7 +248,7 @@ namespace Cantera {
*
* @param k species index
*/
doublereal charge(int k) const;
doublereal charge(size_t k) const;
/**
* @name Adding Species
@ -288,7 +288,7 @@ namespace Cantera {
/*!
* @param k index of the species
*/
std::string speciesName(int k) const;
std::string speciesName(size_t k) const;
/// Return a const referernce to the vector of species names
const std::vector<std::string>& speciesNames() const;
@ -336,7 +336,7 @@ namespace Cantera {
protected:
//! Number of species in the phase.
int m_kk;
size_t m_kk;
//! Vector of molecular weights of the species
/*!
* This vector has length m_kk.

View file

@ -1480,7 +1480,7 @@ namespace Cantera {
*/
std::vector<const XML_Node *> xspecies= speciesData();
std::string kname, jname;
int jj = xspecies.size();
size_t jj = xspecies.size();
for (k = 0; k < m_kk; k++) {
int jmap = -1;
kname = speciesName(k);

View file

@ -306,7 +306,7 @@ namespace Cantera {
* Name of the element with index \c m. @param m Element
* index. If m < 0 or m >= nElements() an exception is thrown.
*/
string Elements::elementName(int m) const {
string Elements::elementName(size_t m) const {
if (m < 0 || m >= nElements()) {
throw ElementRangeError("Elements::elementName", m, nElements());
}

View file

@ -103,7 +103,7 @@ namespace Cantera {
/*!
* @param m element index
*/
int atomicNumber(int m) const { return m_atomicNumbers[m]; }
int atomicNumber(size_t m) const { return m_atomicNumbers[m]; }
//! Entropy at 298.15 K and 1 bar of stable state
//! of the element
@ -141,7 +141,7 @@ namespace Cantera {
/*!
* @param m Element index. If m < 0 or m >= nElements() an exception is thrown.
*/
std::string elementName(int m) const;
std::string elementName(size_t m) const;
//! Returns a string vector containing the element names
/*!

View file

@ -68,7 +68,7 @@ namespace Cantera {
}
double *charge = DATA_PTR(m_speciesCharge);
string stemp;
int nParamsFound, i;
size_t nParamsFound, i;
vector_fp vParams;
string iName = BinSalt.attrib("cation");
if (iName == "") {
@ -269,7 +269,7 @@ namespace Cantera {
void HMWSoln::readXMLThetaAnion(XML_Node &BinSalt) {
string xname = BinSalt.name();
vector_fp vParams;
int nParamsFound = 0;
size_t nParamsFound = 0;
if (xname != "thetaAnion") {
throw CanteraError("HMWSoln::readXMLThetaAnion",
"Incorrect name for processing this routine: " + xname);
@ -356,7 +356,7 @@ namespace Cantera {
void HMWSoln::readXMLThetaCation(XML_Node &BinSalt) {
string xname = BinSalt.name();
vector_fp vParams;
int nParamsFound = 0;
size_t nParamsFound = 0;
if (xname != "thetaCation") {
throw CanteraError("HMWSoln::readXMLThetaCation",
"Incorrect name for processing this routine: " + xname);
@ -449,7 +449,7 @@ namespace Cantera {
double *charge = DATA_PTR(m_speciesCharge);
string stemp;
vector_fp vParams;
int nParamsFound = 0;
size_t nParamsFound = 0;
string kName = BinSalt.attrib("cation");
if (kName == "") {
throw CanteraError("HMWSoln::readXMLPsiCommonCation", "no cation attrib");
@ -595,7 +595,7 @@ namespace Cantera {
double *charge = DATA_PTR(m_speciesCharge);
string stemp;
vector_fp vParams;
int nParamsFound = 0;
size_t nParamsFound = 0;
string kName = BinSalt.attrib("anion");
if (kName == "") {
throw CanteraError("HMWSoln::readXMLPsiCommonAnion", "no anion attrib");
@ -739,7 +739,7 @@ namespace Cantera {
void HMWSoln::readXMLLambdaNeutral(XML_Node &BinSalt) {
string xname = BinSalt.name();
vector_fp vParams;
int nParamsFound;
size_t nParamsFound;
if (xname != "lambdaNeutral") {
throw CanteraError("HMWSoln::readXMLLanbdaNeutral",
"Incorrect name for processing this routine: " + xname);
@ -825,7 +825,7 @@ namespace Cantera {
void HMWSoln::readXMLMunnnNeutral(XML_Node &BinSalt) {
string xname = BinSalt.name();
vector_fp vParams;
int nParamsFound;
size_t nParamsFound;
if (xname != "MunnnNeutral") {
throw CanteraError("HMWSoln::readXMLMunnnNeutral",
"Incorrect name for processing this routine: " + xname);
@ -907,7 +907,7 @@ namespace Cantera {
double *charge = DATA_PTR(m_speciesCharge);
string stemp;
vector_fp vParams;
int nParamsFound = 0;
size_t nParamsFound = 0;
string iName = BinSalt.attrib("neutral");
if (iName == "") {
@ -1492,7 +1492,7 @@ namespace Cantera {
std::vector<const XML_Node *> xspecies = speciesData();
string kname, jname;
int jj = xspecies.size();
size_t jj = xspecies.size();
for (k = 0; k < m_kk; k++) {
int jmap = -1;
kname = speciesName(k);

View file

@ -268,10 +268,9 @@ namespace Cantera {
XML_Node& la = eosdata.child("LatticeArray");
vector<XML_Node*> lattices;
la.getChildren("phase",lattices);
int n;
int nl = lattices.size();
size_t nl = lattices.size();
m_nlattice = nl;
for (n = 0; n < nl; n++) {
for (size_t n = 0; n < nl; n++) {
XML_Node& i = *lattices[n];
m_lattice.push_back((LatticePhase*)newPhase(i));
}

View file

@ -146,10 +146,9 @@ namespace Cantera {
doublereal m_press;
doublereal m_molar_density;
int m_nlattice;
std::vector<LatticePhase*> m_lattice;
mutable vector_fp m_x;
size_t m_nlattice;
std::vector<LatticePhase*> m_lattice;
mutable vector_fp m_x;
private:

View file

@ -973,7 +973,7 @@ namespace Cantera {
}
double *charge = DATA_PTR(m_speciesCharge);
string stemp;
int nParamsFound;
size_t nParamsFound;
vector_fp vParams;
string iName = xmLBinarySpecies.attrib("speciesA");
if (iName == "") {

View file

@ -221,7 +221,7 @@ namespace Cantera {
if (uuu == "Dimensionless") {
dimensionlessMu0Values = true;
}
int ns = cValues.size();
size_t ns = cValues.size();
if (ns != numPoints) {
throw CanteraError("installMu0ThermoFromXML",
"numPoints inconsistent while processing "

View file

@ -342,7 +342,7 @@ namespace Cantera {
thigh = m_highT;
pref = m_Pref;
double ctmp[12];
coeffs[0] = m_numTempRegions;
coeffs[0] = double(m_numTempRegions);
int index = 1;
int n_tmp = 0;;
int type_tmp = 0;

View file

@ -224,7 +224,7 @@ namespace Cantera {
//! species index
int m_index;
//! Number of temperature regions
int m_numTempRegions;
size_t m_numTempRegions;
//! Lower boundaries of each temperature regions
vector_fp m_lowerTempBounds;

View file

@ -130,14 +130,14 @@ namespace Cantera {
m_constMolarVolume = getFloat(*ss, "molarVolume", "toSI");
} else if (model == "temperature_polynomial") {
volumeModel_ = cSSVOLUME_TPOLY;
int num = getFloatArray(*ss, TCoeff_, true, "toSI", "volumeTemperaturePolynomial");
size_t num = getFloatArray(*ss, TCoeff_, true, "toSI", "volumeTemperaturePolynomial");
if (num != 4) {
throw CanteraError("PDSS_SSVol::constructPDSSXML",
" Didn't get 4 density polynomial numbers for species " + speciesNode.name());
}
} else if (model == "density_temperature_polynomial") {
volumeModel_ = cSSVOLUME_DENSITY_TPOLY;
int num = getFloatArray(*ss, TCoeff_, true, "toSI", "densityTemperaturePolynomial");
size_t num = getFloatArray(*ss, TCoeff_, true, "toSI", "densityTemperaturePolynomial");
if (num != 4) {
throw CanteraError("PDSS_SSVol::constructPDSSXML",
" Didn't get 4 density polynomial numbers for species " + speciesNode.name());

View file

@ -136,7 +136,7 @@ namespace Cantera {
state.resize(nSpecies() + 2);
saveState(state.size(),&(state[0]));
}
void Phase::saveState(int lenstate, doublereal* state) const {
void Phase::saveState(size_t lenstate, doublereal* state) const {
state[0] = temperature();
state[1] = density();
getMassFractions(state + 2);
@ -146,7 +146,7 @@ namespace Cantera {
restoreState(state.size(),&state[0]);
}
void Phase::restoreState(int lenstate, const doublereal* state) {
void Phase::restoreState(size_t lenstate, const doublereal* state) {
if (int(lenstate) >= nSpecies() + 2) {
setMassFractions_NoNorm(state + 2);
setTemperature(state[0]);

View file

@ -245,7 +245,7 @@ namespace Cantera {
* @param state output vector. Must be of length nSpecies() + 2 or
* greater.
*/
void saveState(int lenstate, doublereal* state) const;
void saveState(size_t lenstate, doublereal* state) const;
//!Restore a state saved on a previous call to saveState.
/*!
@ -258,7 +258,7 @@ namespace Cantera {
* @param lenstate Length of the state vector
* @param state Vector of state conditions.
*/
void restoreState(int lenstate, const doublereal* state);
void restoreState(size_t lenstate, const doublereal* state);
/**
* Set the species mole fractions by name.

View file

@ -645,14 +645,13 @@ namespace Cantera {
const std::vector<XML_Node*>& tp)
{
const XML_Node * fptr = tp[0];
int nRegTmp = tp.size();
int nRegions = 0;
vector_fp cPoly;
Nasa9Poly1 *np_ptr = 0;
std::vector<Nasa9Poly1 *> regionPtrs;
doublereal tmin, tmax, pref = OneAtm;
// Loop over all of the possible temperature regions
for (int i = 0; i < nRegTmp; i++) {
for (int i = 0; i < tp.size(); i++) {
fptr = tp[i];
if (fptr) {
if (fptr->name() == "NASA9") {

View file

@ -239,7 +239,6 @@ namespace Cantera {
m_dens = molarDensity*meanMolecularWeight();
}
void State::init(const array_fp& mw) {
m_kk = mw.size();
m_molwts.resize(m_kk);

View file

@ -369,7 +369,7 @@ namespace Cantera {
/**
* m_kk is the number of species in the phase
*/
int m_kk;
size_t m_kk;
//! Set the molecular weight of a single species to a given value
/*!

View file

@ -291,11 +291,10 @@ namespace Cantera {
// used to check that each species is declared only once
std::map<std::string, bool> declared;
int nspa = spArray_dbases.size();
int nSpecies = 0;
bool skip;
for (int jsp = 0; jsp < nspa; jsp++) {
for (int jsp = 0; jsp < spArray_dbases.size(); jsp++) {
const XML_Node& speciesArray = *spArray_names[jsp];
// Get the top XML for the database
@ -593,11 +592,8 @@ namespace Cantera {
th->setSpeciesThermo(spth);
}
int k = 0;
int nsp = spDataNodeList.size();
for (int i = 0; i < nsp; i++) {
for (int i = 0; i < spDataNodeList.size(); i++) {
XML_Node *s = spDataNodeList[i];
AssertTrace(s != 0);
bool ok = installSpecies(k, *s, *th, spth, spRuleList[i],
@ -760,8 +756,7 @@ namespace Cantera {
}
vector<XML_Node*> xspecies;
phaseSpeciesData->getChildren("species", xspecies);
int jj = xspecies.size();
for (int j = 0; j < jj; j++) {
for (int j = 0; j < xspecies.size(); j++) {
const XML_Node& sp = *xspecies[j];
jname = sp["name"];
if (jname == kname) {

View file

@ -716,7 +716,7 @@ int CVReInit(void *cvode_mem, RhsFn f, real t0, N_Vector y0,
void *f_data, FILE *errfp, boole optIn, long int iopt[],
real ropt[], void *machEnv)
{
boole allocOK, ioptExists, roptExists, neg_abstol, ewtsetOK;
boole ioptExists, roptExists, neg_abstol, ewtsetOK;
int maxord;
CVodeMem cv_mem;
FILE *fp;
@ -1371,6 +1371,7 @@ static boole CVEwtSet(CVodeMem cv_mem, real *rtol, void *atol, int tol_type,
case SS: return(CVEwtSetSS(cv_mem, rtol, (real *)atol, ycur, neq));
case SV: return(CVEwtSetSV(cv_mem, rtol, (N_Vector)atol, ycur, neq));
}
return (FALSE);
}
/*********************** CVEwtSetSS *********************************
@ -2052,6 +2053,7 @@ static int CVnls(CVodeMem cv_mem, int nflag)
case FUNCTIONAL : return(CVnlsFunctional(cv_mem));
case NEWTON : return(CVnlsNewton(cv_mem, nflag));
}
return -1;
}
/***************** CVnlsFunctional ********************************
@ -2619,6 +2621,7 @@ static int CVHandleFailure(CVodeMem cv_mem, int kflag)
case SOLVE_FAILED: fprintf(errfp, MSG_SOLVE_FAILED, tn);
return(SOLVE_FAILURE);
}
return -1;
}
/*******************************************************************/

View file

@ -43,7 +43,8 @@ etime_(float *tarray)
#endif
double t = clock();
tarray[1] = 0;
return (float) (tarray[0] = t / CLOCKS_PER_SECOND);
tarray[0] = (float) (t / CLOCKS_PER_SECOND);
return tarray[0];
#else
struct tms t;