FieldVector3D implements Serializable { public T dotProduct(final FieldVector3D<T> v) { return x.linearCombination(x, v.x, y, v.y, z, v.z); } FieldVector3D(final T x, final T y, final T z);  FieldVector3D(final T[] v);  FieldVector3D(final T alpha, final T delta);  FieldVector3D(final T a, final FieldVector3D<T>u);  FieldVector3D(final T a, final Vector3D u);  FieldVector3D(final double a, final FieldVector3D<T> u);  FieldVector3D(final T a1, final FieldVector3D<T> u1,
                         final T a2, final FieldVector3D<T> u2);  FieldVector3D(final T a1, final Vector3D u1,
                         final T a2, final Vector3D u2);  FieldVector3D(final double a1, final FieldVector3D<T> u1,
                         final double a2, final FieldVector3D<T> u2);  FieldVector3D(final T a1, final FieldVector3D<T> u1,
                         final T a2, final FieldVector3D<T> u2,
                         final T a3, final FieldVector3D<T> u3);  FieldVector3D(final T a1, final Vector3D u1,
                         final T a2, final Vector3D u2,
                         final T a3, final Vector3D u3);  FieldVector3D(final double a1, final FieldVector3D<T> u1,
                         final double a2, final FieldVector3D<T> u2,
                         final double a3, final FieldVector3D<T> u3);  FieldVector3D(final T a1, final FieldVector3D<T> u1,
                         final T a2, final FieldVector3D<T> u2,
                         final T a3, final FieldVector3D<T> u3,
                         final T a4, final FieldVector3D<T> u4);  FieldVector3D(final T a1, final Vector3D u1,
                         final T a2, final Vector3D u2,
                         final T a3, final Vector3D u3,
                         final T a4, final Vector3D u4);  FieldVector3D(final double a1, final FieldVector3D<T> u1,
                         final double a2, final FieldVector3D<T> u2,
                         final double a3, final FieldVector3D<T> u3,
                         final double a4, final FieldVector3D<T> u4); T getX(); T getY(); T getZ(); T[] toArray(); Vector3D toVector3D(); T getNorm1(); T getNorm(); T getNormSq(); T getNormInf(); T getAlpha(); T getDelta(); FieldVector3D<T> add(final FieldVector3D<T> v); FieldVector3D<T> add(final Vector3D v); FieldVector3D<T> add(final T factor, final FieldVector3D<T> v); FieldVector3D<T> add(final T factor, final Vector3D v); FieldVector3D<T> add(final double factor, final FieldVector3D<T> v); FieldVector3D<T> add(final double factor, final Vector3D v); FieldVector3D<T> subtract(final FieldVector3D<T> v); FieldVector3D<T> subtract(final Vector3D v); FieldVector3D<T> subtract(final T factor, final FieldVector3D<T> v); FieldVector3D<T> subtract(final T factor, final Vector3D v); FieldVector3D<T> subtract(final double factor, final FieldVector3D<T> v); FieldVector3D<T> subtract(final double factor, final Vector3D v); FieldVector3D<T> normalize(); FieldVector3D<T> orthogonal(); static T angle(final FieldVector3D<T> v1, final FieldVector3D<T> v2); static T angle(final FieldVector3D<T> v1, final Vector3D v2); static T angle(final Vector3D v1, final FieldVector3D<T> v2); FieldVector3D<T> negate(); FieldVector3D<T> scalarMultiply(final T a); FieldVector3D<T> scalarMultiply(final double a); boolean isNaN(); boolean isInfinite(); @Override boolean equals(Object other); @Override int hashCode(); T dotProduct(final FieldVector3D<T> v); T dotProduct(final Vector3D v); FieldVector3D<T> crossProduct(final FieldVector3D<T> v); FieldVector3D<T> crossProduct(final Vector3D v); T distance1(final FieldVector3D<T> v); T distance1(final Vector3D v); T distance(final FieldVector3D<T> v); T distance(final Vector3D v); T distanceInf(final FieldVector3D<T> v); T distanceInf(final Vector3D v); T distanceSq(final FieldVector3D<T> v); T distanceSq(final Vector3D v); static T dotProduct(final FieldVector3D<T> v1,
                                                                   final FieldVector3D<T> v2); static T dotProduct(final FieldVector3D<T> v1,
                                                                   final Vector3D v2); static T dotProduct(final Vector3D v1,
                                                                   final FieldVector3D<T> v2); static FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
                                                                                    final FieldVector3D<T> v2); static FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
                                                                                    final Vector3D v2); static FieldVector3D<T> crossProduct(final Vector3D v1,
                                                                                    final FieldVector3D<T> v2); static T distance1(final FieldVector3D<T> v1,
                                                                  final FieldVector3D<T> v2); static T distance1(final FieldVector3D<T> v1,
                                                                  final Vector3D v2); static T distance1(final Vector3D v1,
                                                                  final FieldVector3D<T> v2); static T distance(final FieldVector3D<T> v1,
                                                                 final FieldVector3D<T> v2); static T distance(final FieldVector3D<T> v1,
                                                                 final Vector3D v2); static T distance(final Vector3D v1,
                                                                 final FieldVector3D<T> v2); static T distanceInf(final FieldVector3D<T> v1,
                                                                    final FieldVector3D<T> v2); static T distanceInf(final FieldVector3D<T> v1,
                                                                    final Vector3D v2); static T distanceInf(final Vector3D v1,
                                                                    final FieldVector3D<T> v2); static T distanceSq(final FieldVector3D<T> v1,
                                                                   final FieldVector3D<T> v2); static T distanceSq(final FieldVector3D<T> v1,
                                                                   final Vector3D v2); static T distanceSq(final Vector3D v1,
                                                                   final FieldVector3D<T> v2); @Override String toString(); String toString(final NumberFormat format);  }
@Test public void testDotProduct() { Well1024a random = new Well1024a(553267312521321234l); for (int i = 0; i < 10000; ++i) { double ux = 10000 * random.nextDouble(); double uy = 10000 * random.nextDouble(); double uz = 10000 * random.nextDouble(); double vx = 10000 * random.nextDouble(); double vy = 10000 * random.nextDouble(); double vz = 10000 * random.nextDouble(); double sNaive = ux * vx + uy * vy + uz * vz; FieldVector3D<DerivativeStructure> uds = createVector(ux, uy, uz, 3); FieldVector3D<DerivativeStructure> vds = createVector(vx, vy, vz, 3); Vector3D v = new Vector3D(vx, vy, vz); DerivativeStructure sAccurate = FieldVector3D.dotProduct(uds, vds); Assert.assertEquals(sNaive, sAccurate.getReal(), 2.5e-16 * sNaive); Assert.assertEquals(ux + vx, sAccurate.getPartialDerivative(1, 0, 0), 2.5e-16 * sNaive); Assert.assertEquals(uy + vy, sAccurate.getPartialDerivative(0, 1, 0), 2.5e-16 * sNaive); Assert.assertEquals(uz + vz, sAccurate.getPartialDerivative(0, 0, 1), 2.5e-16 * sNaive); sAccurate = FieldVector3D.dotProduct(uds, v); Assert.assertEquals(sNaive, sAccurate.getReal(), 2.5e-16 * sNaive); Assert.assertEquals(vx, sAccurate.getPartialDerivative(1, 0, 0), 2.5e-16 * sNaive); Assert.assertEquals(vy, sAccurate.getPartialDerivative(0, 1, 0), 2.5e-16 * sNaive); Assert.assertEquals(vz, sAccurate.getPartialDerivative(0, 0, 1), 2.5e-16 * sNaive); } }