Skip to content

Subtle bug in HHGate::tabFill function? #502

@subhacom

Description

@subhacom

This function seems to modify the table variable while using it for lookup:

void HHGate::tabFill(vector<double>& table, unsigned int newXdivs,
                     double newXmin, double newXmax)
{
    if(newXdivs < 3) {
        cout << "Error: tabFill: # divs must be >= 3. Not filling table.\n";
        return;
    }

    vector<double> old = table;
    double newDx = (newXmax - newXmin) / newXdivs;
    table.resize(newXdivs + 1);
    bool origLookupMode = lookupByInterpolation_;
    lookupByInterpolation_ = 1;

    for(unsigned int i = 0; i <= newXdivs; ++i) {
        table[i] = lookupTable(table, newXmin + i * newDx);
    }

    lookupByInterpolation_ = origLookupMode;
}

The call to lookupTable inside the last for loop is using the same table that it is trying to update. I am wondering if it should be passed the old table instead (which is defined but never used).

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions