Class Vector1D.Sum

  • All Implemented Interfaces:
    java.util.function.Consumer<Vector1D>, java.util.function.Supplier<Vector1D>
    Enclosing class:
    Vector1D

    public static final class Vector1D.Sum
    extends EuclideanVectorSum<Vector1D>
    Class used to create high-accuracy sums of vectors. Each vector component is summed using an instance of Sum.

    This class is mutable and not thread-safe.

    See Also:
    Sum
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.apache.commons.numbers.core.Sum xsum
      X component sum.
    • Constructor Summary

      Constructors 
      Constructor Description
      Sum​(Vector1D initial)
      Construct a new instance with the given initial value.
    • Field Detail

      • xsum

        private final org.apache.commons.numbers.core.Sum xsum
        X component sum.
    • Constructor Detail

      • Sum

        Sum​(Vector1D initial)
        Construct a new instance with the given initial value.
        Parameters:
        initial - initial value
    • Method Detail

      • addScaled

        public Vector1D.Sum addScaled​(double scale,
                                      Vector1D vec)
        Add a scaled vector to this instance. In general, the result produced by this method will be more accurate than if the vector was scaled first and then added directly. In other words, sum.addScale(scale, vec) will generally produce a better result than sum.add(vec.multiply(scale)).
        Specified by:
        addScaled in class EuclideanVectorSum<Vector1D>
        Parameters:
        scale - scale factor
        vec - vector to scale and add
        Returns:
        this instance
      • create

        public static Vector1D.Sum create()
        Create a new instance with an initial value set to the zero vector.
        Returns:
        new instance set to zero
      • of

        public static Vector1D.Sum of​(Vector1D initial)
        Construct a new instance with an initial value set to the argument.
        Parameters:
        initial - initial sum value
        Returns:
        new instance
      • of

        public static Vector1D.Sum of​(Vector1D first,
                                      Vector1D... more)
        Construct a new instance from multiple values.
        Parameters:
        first - first vector
        more - additional vectors
        Returns:
        new instance