예제 #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
 public override void rollback(DiscretizedAsset asset, double to)
 {
     partialRollback(asset, to);
     asset.adjustValues();
 }