Commit 46d3b4af authored by Mark Fishcler's avatar Mark Fishcler
Browse files

Accomodatoins for peculiarities of Visual C++ (the for loop declaration mess).

Also, suspenders-and-belt check when about to do resize, that it is indeed
needed -- VC++ appears to blow this as well.
parent 14ff12cd
// -*- C++ -*-
// $Id: SymMatrix.cc,v 1.3.2.6 2005/03/15 20:39:06 fischler Exp $
// $Id: SymMatrix.cc,v 1.3.2.7 2005/03/21 21:46:39 fischler Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -954,7 +954,7 @@ void HepSymMatrix::invert(int &ifail) {
double HepSymMatrix::determinant() const {
static const int max_array = 20;
static std::vector<int> ir_vec (max_array);
ir_vec.resize(nrow);
if (ir_vec.size() < static_cast<unsigned int>(nrow)) ir_vec.resize(nrow);
int * ir = &ir_vec[0];
double det;
......@@ -999,9 +999,10 @@ void HepSymMatrix::invertBunchKaufman(int &ifail) {
static std::vector<int, Alloc<int, 25> > pivv (max_array);
typedef std::vector<int,Alloc<int,25> >::iterator pivIter;
#endif
xvec.resize(nrow);
pivv.resize(nrow);
// Note - resize does nothing if the size is already larger than nrow.
if (xvec.size() < static_cast<unsigned int>(nrow)) xvec.resize(nrow);
if (pivv.size() < static_cast<unsigned int>(nrow)) pivv.resize(nrow);
// Note - resize shuld do nothing if the size is already larger than nrow,
// but on VC++ there are indications that it does so we check.
// Note - the data elements in a vector are guaranteed to be contiguous,
// so x[i] and piv[i] are optimally fast.
mIter x = xvec.begin();
......
......@@ -130,7 +130,8 @@ int checkHeap ( double * &hNew,
int main(int, char **) {
int ret=0;
int rhp;
for (int i = 1; i < 50; i++) {
int i,j;
for ( i = 0; i < 50; i++) {
ret = test_inversion(i);
if (ret) return ret;
}
......@@ -140,8 +141,8 @@ int main(int, char **) {
int n1 = 4000;
int n2 = 25;
heapAddresses ( hNew, hMalloc, hNew10000, hMalloc80000 );
for (int i=1; i<n1; i++) {
for (int j=1; j < n2; j++) {
for (i=0; i<n1; i++) {
for (j=1; j < n2; j++) {
ret = test_inversion(j);
if (ret) return ret;
}
......@@ -154,10 +155,10 @@ int main(int, char **) {
ret |= rhp;
heapAddresses ( hNew, hMalloc, hNew10000, hMalloc80000 );
for (int i=1; i<2; i++) {
for (int j=1; j < 20; j++) {
ret |= test_inversion(25+2*j);
if (ret) return ret;
for (i=1; i<2; i++) {
for (j=1; j < 20; j++) {
rhp = test_inversion(25+2*j);
if (rhp) return rhp;
}
}
heapAddresses ( xhNew, xhMalloc, xhNew10000, xhMalloc80000 );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment