Login  Register

Possible Time Series Bug

Posted by marco.tarenghi@libero.it on Aug 30, 2006; 10:02am
URL: http://quantlib.414.s1.nabble.com/Possible-Time-Series-Bug-tp5005.html

Hi all,
I think I've found a bug in the TimeSeries class.
There it is implemented the [] operator in two different ways, I think the second one is wrong: more in detail, according to me the operator returning a reference contains an error in the "if" condition

T& operator[](const Date& d) {
    if (values_.find(d) != values_.end())
        values_[d] = Null<T>();
        return values_[d];
    }
}

it should be "==" and not "!=", otherwise in the case it finds the date it returns a Null<T> value.
Probably it has been mis-specified because it replicates the implementation of the alternative [] operator, but in that case the output is different and the operator works fine.

By the way, if I instantiate a TimeSeries object and then I use the [] operator, how does the object know which is implementation to choose?

Thanks,
Marco


___________________________________________________________________
Prestiti da 15 istituti. Tan dal 5,90% per richieste entro il 15 Settembre. Servizio gratuito.
http://click.libero.it/mutuionline3