示例#1
0
        /// <summary>
        /// Applies a perturbation to the specified underlying.
        /// <para>
        /// This should be invoked once for each of the underlying instances.
        /// It is intended to be used to pass the result of each invocation to the
        /// constructor of the combined instance.
        ///
        /// </para>
        /// </summary>
        /// @param <R>  the type of the underlying </param>
        /// <param name="underlyingIndex">  the index of the underlying instance </param>
        /// <param name="underlyingType">  the type of the parameterized data at the specified index </param>
        /// <param name="perturbation">  the perturbation to apply </param>
        /// <returns> a parameterized data instance based on this with the specified perturbation applied </returns>
        public R underlyingWithPerturbation <R>(int underlyingIndex, Type <R> underlyingType, ParameterPerturbation perturbation) where R : ParameterizedData
        {
            ParameterizedData underlying = underlyings[underlyingIndex];
            // perturb using a derived perturbation that adjusts the index
            int adjustment = lookup[underlyingIndex];
            ParameterizedData perturbed = underlying.withPerturbation((idx, value, meta) => perturbation(idx + adjustment, value, meta));

            return(underlyingType.cast(perturbed));
        }
 public virtual void test_withPerturbation()
 {
     assertSame(CURVE.withPerturbation((i, v, m) => v), CURVE);
     assertEquals(CURVE.withPerturbation((i, v, m) => v + 2d).getParameter(0), 3d);
 }