Commit dba1c4d0 authored by Mark Fishcler's avatar Mark Fishcler
Browse files

Repair problems exposed by running this test under VC++ 7.1.

parent bd0fd67c
2005-03-15 Mark Fischler <mf@fnal.gov>
* SymMatrix.cc, testBug7328.cc
Repair of bug 7328, a memory leak encountered when inverting symmetric
matrices above the size of 6x6.
2005-03-15 Mark Fischler <mf@fnal.gov>
* engineIDulong.cc, engineIDulong.h
......
2005-03-23 Mark Fischler <mf@fnal.gov>
* SymMatrix.cc, testBug7328.cc
Repair bug introduced into determinant of large matrices, and exposed
by testBug7328 when it is run on VC++ 7.1.
Also clean up the test program to avoid declaring loop indices
in the for loop statement when indices of the same name will be used
later -- VC++ still fouls up when this is done, though it is proper
C++.
2005-03-15 Mark Fischler <mf@fnal.gov>
* SymMatrix.cc, testBug7328.cc
......
// -*- C++ -*-
// $Id: SymMatrix.cc,v 1.3.2.7 2005/03/21 21:46:39 fischler Exp $
// $Id: SymMatrix.cc,v 1.3.2.8 2005/03/23 17:57:54 fischler Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -953,8 +953,9 @@ void HepSymMatrix::invert(int &ifail) {
double HepSymMatrix::determinant() const {
static const int max_array = 20;
static std::vector<int> ir_vec (max_array);
if (ir_vec.size() < static_cast<unsigned int>(nrow)) ir_vec.resize(nrow);
// ir must point to an array which is ***1 longer than*** nrow
static std::vector<int> ir_vec (max_array+1);
if (ir_vec.size() <= static_cast<unsigned int>(nrow)) ir_vec.resize(nrow+1);
int * ir = &ir_vec[0];
double det;
......
......@@ -20,6 +20,7 @@
int test_inversion (int N) {
int i,j;
HepSymMatrix S(N,0);
int i,j;
for(i=1;i<=N;++i) {
......@@ -65,11 +66,7 @@ int test_inversion (int N) {
#define DET_ALSO
#ifdef DET_ALSO
double detS = S.determinant();
// std::cout<<"Determinant N = " << N <<
// " = " << detS <<std::endl;
double detSS = SS.determinant();
// std::cout<<"Determinant Inverse N = " << N <<
// " = " << detSS <<std::endl;
if (fabs((detS-1.0/detSS)/detS) > 1.0e-6) {
std::cout<<"Determinant incorrect N = " << N <<
" error = " << fabs((detS-1.0/detSS)/detS) <<std::endl;
......@@ -130,18 +127,18 @@ int main(int, char **) {
int ret=0;
int rhp;
int i,j;
for ( i = 0; i < 50; i++) {
for ( i = 1; i <= 50; i++) {
ret = test_inversion(i);
if (ret) return ret;
}
double *hNew, *hMalloc, *hNew10000, *hMalloc80000;
double *xhNew, *xhMalloc, *xhNew10000, *xhMalloc80000;
int n1 = 4000;
int n1 = 400;
int n2 = 25;
heapAddresses ( hNew, hMalloc, hNew10000, hMalloc80000 );
for (i=0; i<n1; i++) {
for (j=1; j < n2; j++) {
for (j=1; j <= n2; j++) {
ret = test_inversion(j);
if (ret) return ret;
}
......@@ -154,7 +151,7 @@ int main(int, char **) {
ret |= rhp;
heapAddresses ( hNew, hMalloc, hNew10000, hMalloc80000 );
for (i=1; i<2; i++) {
for (i=0; i<2; i++) {
for (j=1; j < 20; j++) {
rhp = test_inversion(25+2*j);
if (rhp) return rhp;
......
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