Package org.apache.commons.math3.analysis.differentiation

Examples of org.apache.commons.math3.analysis.differentiation.DerivativeStructure


        DerivativeStructure[] f = new DerivativeStructure[m];
        Arrays.fill(f, variables[0].getField().getZero());

        for (int j = 0; j < n; ++j) {
            DerivativeStructure tmp1 = variables[0].getField().getOne();
            DerivativeStructure tmp2 = variables[j].multiply(2).subtract(1);
            DerivativeStructure temp = tmp2.multiply(2);
            for (int i = 0; i < m; ++i) {
                f[i] = f[i].add(tmp2);
                DerivativeStructure ti = temp.multiply(tmp2).subtract(tmp1);
                tmp1 = tmp2;
                tmp2 = ti;
            }
        }
View Full Code Here


    }

    @Override
    public DerivativeStructure[] value(DerivativeStructure[] variables) {
        DerivativeStructure[] f = new DerivativeStructure[m];
        DerivativeStructure sum  = variables[0].getField().getZero().subtract(n + 1);
        DerivativeStructure prod = variables[0].getField().getOne();
      for (int j = 0; j < n; ++j) {
        sum  = sum.add(variables[j]);
        prod = prod.multiply(variables[j]);
      }
      for (int i = 0; i < n; ++i) {
        f[i] = variables[i].add(sum);
      }
      f[n - 1] = prod.subtract(1);
      return f;
    }
View Full Code Here

            theoreticalMinParams);
    }

    @Override
    public DerivativeStructure[] value(DerivativeStructure[] variables) {
        DerivativeStructure x1 = variables[0];
        DerivativeStructure x2 = variables[1];
        DerivativeStructure x3 = variables[2];
        DerivativeStructure x4 = variables[3];
        DerivativeStructure x5 = variables[4];
        DerivativeStructure[] f = new DerivativeStructure[m];
      for (int i = 0; i < m; ++i) {
        double temp = 10.0 * i;
        DerivativeStructure tmp1 = x4.multiply(-temp).exp();
        DerivativeStructure tmp2 = x5.multiply(-temp).exp();
        f[i] = x1.add(x2.multiply(tmp1)).add(x3.multiply(tmp2)).negate().add(y[i]);
      }
      return f;
    }
View Full Code Here

            theoreticalMinParams);
    }

    @Override
    public DerivativeStructure[] value(DerivativeStructure[] variables) {
        DerivativeStructure x01 = variables[0];
        DerivativeStructure x02 = variables[1];
        DerivativeStructure x03 = variables[2];
        DerivativeStructure x04 = variables[3];
        DerivativeStructure x05 = variables[4];
        DerivativeStructure x06 = variables[5];
        DerivativeStructure x07 = variables[6];
        DerivativeStructure x08 = variables[7];
        DerivativeStructure x09 = variables[8];
        DerivativeStructure x10 = variables[9];
        DerivativeStructure x11 = variables[10];
        DerivativeStructure[] f = new DerivativeStructure[m];
        for (int i = 0; i < m; ++i) {
            double temp = i / 10.0;
            DerivativeStructure tmp1 = x05.multiply(-temp).exp();
            DerivativeStructure tmp2 = x06.negate().multiply(x09.subtract(temp).multiply(x09.subtract(temp))).exp();
            DerivativeStructure tmp3 = x07.negate().multiply(x10.subtract(temp).multiply(x10.subtract(temp))).exp();
            DerivativeStructure tmp4 = x08.negate().multiply(x11.subtract(temp).multiply(x11.subtract(temp))).exp();
            f[i] = x01.multiply(tmp1).add(x02.multiply(tmp2)).add(x03.multiply(tmp3)).add(x04.multiply(tmp4)).negate().add(y[i]);
        }
        return f;
    }
View Full Code Here

        return model;
    }

    public DerivativeStructure[] value(DerivativeStructure[] params) {
        final DerivativeStructure cx = params[0];
        final DerivativeStructure cy = params[1];
        final DerivativeStructure r = params[2];

        final DerivativeStructure[] model = new DerivativeStructure[points.size() * 2];

        for (int i = 0; i < points.size(); i++) {
            final Vector2D p = points.get(i);

            // Find the circle point closest to the observed point
            // (observed points are points add through the addPoint method above)
            final DerivativeStructure dX = cx.subtract(p.getX());
            final DerivativeStructure dY = cy.subtract(p.getY());
            final DerivativeStructure scaling = r.divide(dX.multiply(dX).add(dY.multiply(dY)).sqrt());
            final int index  = i * 2;
            model[index]     = cx.subtract(scaling.multiply(dX));
            model[index + 1] = cy.subtract(scaling.multiply(dY));

        }

        return model;

View Full Code Here

        try {
            dataset = new StatisticalReferenceDataset(in) {

                @Override
                public DerivativeStructure getModelValue(final double x, final DerivativeStructure[] a) {
                    final DerivativeStructure p = a[0].add(a[1].add(a[2].multiply(x)).multiply(x));
                    final DerivativeStructure q = a[3].add(a[4].multiply(x)).multiply(x).add(1.0);
                    return p.divide(q);
                }

            };
        } finally {
View Full Code Here

        try {
            dataset = new StatisticalReferenceDataset(in) {

                @Override
                public DerivativeStructure getModelValue(final double x, final DerivativeStructure[] a) {
                    final DerivativeStructure p = a[0].add(a[1].add(a[2].add(a[3].multiply(x)).multiply(x)).multiply(x));
                    final DerivativeStructure q = a[4].add(a[5].add(a[6].multiply(x)).multiply(x)).multiply(x).add(1.0);
                    return p.divide(q);
                }

            };
        } finally {
View Full Code Here

        return r / points.size();
    }

    private DerivativeStructure distance(Vector2D point,
                                         DerivativeStructure cx, DerivativeStructure cy) {
        DerivativeStructure dx = cx.subtract(point.getX());
        DerivativeStructure dy = cy.subtract(point.getY());
        return dx.multiply(dx).add(dy.multiply(dy)).sqrt();
    }
View Full Code Here

        DerivativeStructure dy = cy.subtract(point.getY());
        return dx.multiply(dx).add(dy.multiply(dy)).sqrt();
    }

    public DerivativeStructure getRadius(DerivativeStructure cx, DerivativeStructure cy) {
        DerivativeStructure r = cx.getField().getZero();
        for (Vector2D point : points) {
            r = r.add(distance(point, cx, cy));
        }
        return r.divide(points.size());
    }
View Full Code Here

        return sum;
    }

    public DerivativeStructure value(DerivativeStructure[] variables)  {
        DerivativeStructure radius = getRadius(variables[0], variables[1]);

        DerivativeStructure sum = variables[0].getField().getZero();
        for (Vector2D point : points) {
            DerivativeStructure di = distance(point, variables[0], variables[1]).subtract(radius);
            sum = sum.add(di.multiply(di));
        }

        return sum;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.analysis.differentiation.DerivativeStructure

Copyright © 2018 www.massapicom. 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.