Пример #1
0
        public override void partialRollback(DiscretizedAsset asset, double to)
        {
            double from = asset.time();

            if (Utils.close(from, to))
            {
                return;
            }

            Utils.QL_REQUIRE(from > to, () => "cannot roll the asset back to" + to + " (it is already at t = " + from + ")");

            int iFrom = t_.index(from);
            int iTo   = t_.index(to);

            for (int i = iFrom - 1; i >= iTo; --i)
            {
                Vector newValues = new Vector(impl().size(i));
                impl().stepback(i, asset.values(), newValues);
                asset.setTime(t_[i]);
                asset.setValues(newValues);
                // skip the very last adjustment
                if (i != iTo)
                {
                    asset.adjustValues();
                }
            }
        }
Пример #2
0
        // Lattice interface
        public override void initialize(DiscretizedAsset asset, double t)
        {
            int i = t_.index(t);

            asset.setTime(t);
            asset.reset(impl().size(i));
        }