/** {@inheritDoc} */ @Override public Vector1D parse(final String source, final ParsePosition pos) { final double[] coordinates = parseCoordinates(1, source, pos); if (coordinates == null) { return null; } return new Vector1D(coordinates[0]); }
/** Compute the distance between two vectors according to the L<sub>∞</sub> norm. * <p>Calling this method is equivalent to calling: * <code>p1.subtract(p2).getNormInf()</code> except that no intermediate * vector is built</p> * @param p1 first vector * @param p2 second vector * @return the distance between p1 and p2 according to the L<sub>∞</sub> norm */ public static double distanceInf(Vector1D p1, Vector1D p2) { return p1.distanceInf(p2); }
/** {@inheritDoc} */ @Override public IntervalsSet buildNew(final BSPTree<Euclidean1D> tree) { return new IntervalsSet(tree, getTolerance()); }
/** Get a string representation of this vector. * @return a string representation of this vector */ @Override public String toString() { return Vector1DFormat.getInstance().format(this); }
/** {@inheritDoc} */ public Vector1D subtract(Vector<Euclidean1D> p) { Vector1D p3 = (Vector1D) p; return new Vector1D(x - p3.x); }
/** Compute the square of the distance between two vectors. * <p>Calling this method is equivalent to calling: * <code>p1.subtract(p2).getNormSq()</code> except that no intermediate * vector is built</p> * @param p1 first vector * @param p2 second vector * @return the square of the distance between p1 and p2 */ public static double distanceSq(Vector1D p1, Vector1D p2) { return p1.distanceSq(p2); }
/** {@inheritDoc} */ @Override protected AbstractSubHyperplane<Euclidean1D, Euclidean1D> buildNew(final Hyperplane<Euclidean1D> hyperplane, final Region<Euclidean1D> remainingRegion) { return new SubOrientedPoint(hyperplane, remainingRegion); }
/** Build an intervals set corresponding to a single interval. * @param lower lower bound of the interval, must be lesser or equal * to {@code upper} (may be {@code Double.NEGATIVE_INFINITY}) * @param upper upper bound of the interval, must be greater or equal * to {@code lower} (may be {@code Double.POSITIVE_INFINITY}) * @param tolerance tolerance below which points are considered identical. * @since 3.3 */ public IntervalsSet(final double lower, final double upper, final double tolerance) { super(buildTree(lower, upper, tolerance), tolerance); }
/** {@inheritDoc} * <p> * As the 1-dimension Euclidean space does not have proper sub-spaces, * this method always throws a {@link NoSubSpaceException} * </p> * @return nothing * @throws NoSubSpaceException in all cases */ public Space getSubSpace() throws NoSubSpaceException { throw new NoSubSpaceException(); }
/** {@inheritDoc} * <p> * The iterator returns the limit values of sub-intervals in ascending order. * </p> * <p> * The iterator does <em>not</em> support the optional {@code remove} operation. * </p> * @since 3.3 */ public Iterator<double[]> iterator() { return new SubIntervalsIterator(); }
/** Get the offset (oriented distance) of a vector. * @param vector vector to check * @return offset of the vector */ public double getOffset(Vector<Euclidean1D> vector) { return getOffset((Point<Euclidean1D>) vector); }
/** Build a region covering the whole space. * @return a region containing the instance (really an {@link * IntervalsSet IntervalsSet} instance) */ public IntervalsSet wholeSpace() { return new IntervalsSet(tolerance); }
/** Compute the distance between two vectors according to the L<sub>2</sub> norm. * <p>Calling this method is equivalent to calling: * <code>p1.subtract(p2).getNorm()</code> except that no intermediate * vector is built</p> * @param p1 first vector * @param p2 second vector * @return the distance between p1 and p2 according to the L<sub>2</sub> norm */ public static double distance(Vector1D p1, Vector1D p2) { return p1.distance(p2); }
/** {@inheritDoc} */ public Euclidean1D getSubSpace() { return Euclidean1D.getInstance(); }
/** {@inheritDoc} */ public Vector1D negate() { return new Vector1D(-x); }