Examples of Interpolation


Examples of org.jquantlib.math.interpolations.Interpolation

        QL.info("Testing forward-flat interpolation...");

        final Array x = new Array(new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 });
        final Array y = new Array(new double[] { 5.0, 4.0, 3.0, 2.0, 1.0 });

        final Interpolation f = new ForwardFlatInterpolation(x, y);
        f.update();

        final int N = x.size();
        final double tolerance = 1.0e-12;

        // at original points
        for (int i=0; i<N; i++) {
            final double p = x.get(i);
            final double calculated = f.op(p);
            final double expected = y.get(i);
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
                    +"\n    error:              "+Math.abs(calculated-expected),
                    Math.abs(calculated - expected) > tolerance);
        }

        // at middle points
        for (int i=0; i<N-1; i++) {
            final double p = (x.get(i) + x.get(i+1))/2;
            final double calculated = f.op(p);
            final double expected = y.get(i);
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
                    +"\n    error:              "+Math.abs(calculated-expected),
                    Math.abs(calculated - expected) > tolerance);
        }

        // outside the original range
        f.enableExtrapolation();

        {
            double p = x.get(0) - 0.5;
            double calculated = f.op(p);
            double expected = y.get(0);
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
                    +"\n    error:              "+Math.abs(calculated-expected),
                    Math.abs(calculated - expected) > tolerance);

            p = x.get(N-1) + 0.5;
            calculated = f.op(p);
            expected = y.get(N-1);
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
                    +"\n    error:              "+Math.abs(calculated-expected),
                    Math.abs(calculated - expected) > tolerance);

            // primitive at original points
            calculated = f.primitive(x.get(0));
            expected = 0.0;
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
                    +"\n    error:              "+Math.abs(calculated-expected),
                    Math.abs(calculated - expected) > tolerance);
        }

        double sum = 0.0;
        for (int i=1; i<N; i++) {
            sum += (x.get(i) - x.get(i-1)) * y.get(i-1);
            final double calculated = f.primitive(x.get(i));
            final double expected = sum;
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
                    +"\n    error:              "+Math.abs(calculated-expected),
                    Math.abs(calculated - expected) > tolerance);
        }

        // primitive at middle points
        sum = 0.0;
        for (int i=0; i<N-1; i++) {
            final double p = (x.get(i) + x.get(i+1))/2;
            sum += (x.get(i+1) - x.get(i)) * y.get(i)/2;
            final double calculated = f.primitive(p);
            final double expected = sum;
            sum += (x.get(i+1) - x.get(i)) * y.get(i)/2;
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
View Full Code Here

Examples of org.openpixi.pixi.physics.grid.Interpolation

    sharedDataManager =  createSharedDataManager();
    ParticleBoundaries particleBoundaries = createParticleBoundaries(sharedDataManager);
    sharedDataManager.setParticleBoundaries(particleBoundaries);

    Grid grid = createGrid(sharedDataManager);
    Interpolation interpolation = createInterpolationIterator(sharedDataManager);
    sharedDataManager.setGrid(grid);

    sharedDataManager.initializeCommunication();

    this.simulation = new Simulation(
View Full Code Here

Examples of ptolemy.backtrack.automatic.ptolemy.math.Interpolation

     * @exception NameDuplicationException If the container already has an
     * actor with this name.
     */
    public Interpolator(CompositeEntity container, String name) throws NameDuplicationException, IllegalActionException  {
        super(container, name);
        $ASSIGN$_interpolation(new Interpolation());
        indexes = new Parameter(this, "indexes");
        indexes.setExpression("{0, 1}");
        indexes.setTypeEquals(new ArrayType(BaseType.INT));
        attributeChanged(indexes);
        values = new Parameter(this, "values");
View Full Code Here

Examples of ptolemy.math.Interpolation

     */
    public Interpolator(CompositeEntity container, String name)
            throws NameDuplicationException, IllegalActionException {
        super(container, name);

        _interpolation = new Interpolation();

        // Initialize the parameters with the default settings of the
        // Interpolation class. This is not required for this class to
        // function. But since these parameters are public, other objects
        // in the system may use them.
View Full Code Here

Examples of railo.runtime.img.interpolation.Interpolation

      if (columns == 0 || rows == 0)
        throw new ExpressionException("invalid size for image");
   
      BufferedImage resizeImage = ImageUtil.createBufferedImage(image, columns, rows);
   
    Interpolation inter = getInterpolation(interpolation);
    double xFactor = (double) columns / (double) image.getWidth();
    double scale = blur * Math.max(1.0 / xFactor, 1.0);
    double xSupport = Math.max(scale * inter.getSupport(), 0.5);
    double yFactor = (double) rows / (double) image.getHeight();
    scale = blur * Math.max(1.0 / yFactor, 1.0);
    double ySupport = Math.max(scale * inter.getSupport(), 0.5);
    double support = Math.max(xSupport, ySupport);
    if (support < inter.getSupport())
        support = inter.getSupport();
    ContributionInfo[] contribution = new ContributionInfo[(int) support * 2 + 3];
   
    for (int cloop = 0; cloop < (int) support * 2 + 3; cloop++)
        contribution[cloop] = new ContributionInfo();
   
View Full Code Here

Examples of webit.script.core.ast.statements.Interpolation

            throw new ParseException("No a static field: ".concat(path), line, column);
        }
    }

    Statement createInterpolation(final Expression expr) {
        return new Interpolation(expr);
    }
View Full Code Here

Examples of wpn.hdri.ss.data.Interpolation

        if (!devices.contains(deviceName)) {
            addDevice(deviceName);
        }

        Method method = Method.valueOf(methodAlias.toUpperCase());
        Interpolation interpolation = Interpolation.valueOf(interpolationAlias.toUpperCase());


        DeviceAttribute attribute = new DeviceAttribute();
        attribute.setName(attrName);
        attribute.setAlias(null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.