Examples of Interpolation


Examples of javax.media.jai.Interpolation

        RenderableImage source = paramBlock.getRenderableSource(0);
        Object arg0 = paramBlock.getObjectParameter(0);
        AffineTransform forward_tr = (AffineTransform)arg0;

        Object arg1 = paramBlock.getObjectParameter(1);
        Interpolation interp = (Interpolation)arg1;

        // Get the affine transform
        double tr[];
        tr = new double[6];
        forward_tr.getMatrix(tr);
View Full Code Here

Examples of javax.media.jai.Interpolation

        // Get BorderExtender from renderHints if any.
        BorderExtender extender = RIFUtil.getBorderExtenderHint(renderHints);

        RenderedImage source = paramBlock.getRenderedSource(0);
        Warp warp = (Warp)paramBlock.getObjectParameter(0);
        Interpolation interp = (Interpolation)paramBlock.getObjectParameter(1);

        double[] backgroundValues = (double[])paramBlock.getObjectParameter(2);

        if (interp instanceof InterpolationNearest) {
            return new WarpNearestOpImage(source,
View Full Code Here

Examples of javax.media.jai.Interpolation

        RenderedImage source = paramBlock.getRenderedSource(0);
        float xScale = paramBlock.getFloatParameter(0);
        float yScale = paramBlock.getFloatParameter(1);
        float xTrans = paramBlock.getFloatParameter(2);
        float yTrans = paramBlock.getFloatParameter(3);
        Interpolation interp = (Interpolation)paramBlock.getObjectParameter(4);

  // Check and see if we are scaling by 1.0 in both x and y and no
        // translations. If so call the copy operation.
 
  if (xScale == 1.0F && yScale == 1.0F &&
View Full Code Here

Examples of javax.media.jai.Interpolation

        float scale_x = paramBlock.getFloatParameter(0);
        float scale_y = paramBlock.getFloatParameter(1);
        float trans_x = paramBlock.getFloatParameter(2);
        float trans_y = paramBlock.getFloatParameter(3);
        Interpolation interp = (Interpolation)paramBlock.getObjectParameter(4);

  // Get the source dimensions
  float x0 = (float)source.getMinX();
  float y0 = (float)source.getMinY() ;
  float w = (float)source.getWidth();
View Full Code Here

Examples of org.jboss.ide.eclipse.freemarker.model.Interpolation

    @Override
    public void runWithEvent(Event event) {
      Tree tree = getTreeViewer().getTree();
      TreeItem[] items = tree.getSelection();
      Interpolation interpolation = null;
      for (int i=0; i<items.length; i++) {
        TreeItem item = items[i];
        if (item.getData() instanceof Interpolation) {
          interpolation = (Interpolation) item.getData();
          try {
            SelectionDialog sd = JavaUI.createTypeDialog(new Shell(), null, SearchEngine.createWorkspaceScope(),
                IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false);
            sd.open();
            Object[] objects = sd.getResult();
            if (null != objects && objects.length > 0) {
              ConfigurationManager configuration = ConfigurationManager.getInstance(interpolation.getResource().getProject());
              IType type = (IType) objects[0];
              try {
                configuration.addContextValue(
                    new ContextValue(interpolation.getFirstToken(),
                        configuration.getClass(type.getFullyQualifiedName()), null), interpolation.getResource());
              }
              catch (ClassNotFoundException e) {
                Plugin.log(e);
              }
            }
View Full Code Here

Examples of org.jquantlib.math.interpolations.Interpolation

        QL.info("Testing use of interpolations as functors...");

        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 LinearInterpolation(x, y);
        f.update();

        final Array x2 = new Array(new double[] { -2.0, -1.0, 0.0, 1.0, 3.0, 4.0, 5.0, 6.0, 7.0 });
        final int N = x2.size();

        final double tolerance = 1.0e-12;

        // case 1: extrapolation not allowed
        try {
            final Array y2 = x2.clone().transform(f);
            System.out.println(y2);
            throw new NotThrown();
        } catch (final NotThrown ex) {
            throw new LibraryException("failed to throw exception when trying to extrapolate");
        } catch (final Exception ex) {
            // as expected, we are OK.
            System.out.println(ex);
        }

        // case 2: enable extrapolation
        f.enableExtrapolation();
        final Array y2 = x2.clone().transform(f);
        System.out.println(y2);
        for (int i=0; i<N-1; i++) {
            final double expected = 5.0 - x2.get(i);
            final double calculated = y2.get(i);
View Full Code Here

Examples of org.jquantlib.math.interpolations.Interpolation

        QL.info("Testing backward-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 BackwardFlatInterpolation(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+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);
        }

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

        {
            // this is just a block
            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-1; i++) {
            sum += (x.get(i) - x.get(i-1)) * y.get(i);
            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+1)/2;
            final double calculated = f.primitive(p);
            final double expected = sum;
            sum += (x.get(i+1)-x.get(i))*y.get(i+1)/2;
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
View Full Code Here

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.jquantlib.math.interpolations.Interpolation

        QL.info("Testing use of interpolations as functors...");

        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 LinearInterpolation(x, y);
        f.update();

        final Array x2 = new Array(new double[] { -2.0, -1.0, 0.0, 1.0, 3.0, 4.0, 5.0, 6.0, 7.0 });
        final int N = x2.size();

        final double tolerance = 1.0e-12;

        // case 1: extrapolation not allowed
        try {
            final Array y2 = x2.clone().transform(f);
            System.out.println(y2);
            throw new NotThrown();
        } catch (final NotThrown ex) {
            throw new LibraryException("failed to throw exception when trying to extrapolate");
        } catch (final Exception ex) {
            // as expected, we are OK.
            System.out.println(ex);
        }

        // case 2: enable extrapolation
        f.enableExtrapolation();
        final Array y2 = x2.clone().transform(f);
        System.out.println(y2);
        for (int i=0; i<N-1; i++) {
            final double expected = 5.0 - x2.get(i);
            final double calculated = y2.get(i);
View Full Code Here

Examples of org.jquantlib.math.interpolations.Interpolation

        QL.info("Testing backward-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 BackwardFlatInterpolation(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+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);
        }

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

        {
            // this is just a block
            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-1; i++) {
            sum += (x.get(i) - x.get(i-1)) * y.get(i);
            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+1)/2;
            final double calculated = f.primitive(p);
            final double expected = sum;
            sum += (x.get(i+1)-x.get(i))*y.get(i+1)/2;
            assertFalse("failed to reproduce expected datum"
                    +"\n    expected value:   "+expected
                    +"\n    calculated value: "+calculated
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.