Class VectorMath

java.lang.Object
jdk.incubator.vector.VectorMath

public final class VectorMath extends Object
The class VectorMath contains methods for performing scalar numeric operations in support of vector numeric operations.
Since:
24
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    static byte
    addSaturating(byte a, byte b)
    Adds two byte values using saturation arithemetic.
    static int
    addSaturating(int a, int b)
    Adds two int values using saturation arithemetic.
    static long
    addSaturating(long a, long b)
    Adds two long values using saturation arithemetic.
    static short
    addSaturating(short a, short b)
    Adds two short values using saturation arithemetic.
    static byte
    addSaturatingUnsigned(byte a, byte b)
    Adds two byte values using saturation arithemetic and numerically treating the values as unsigned.
    static int
    addSaturatingUnsigned(int a, int b)
    Adds two int values using saturation arithemetic and numerically treating the values as unsigned.
    static long
    addSaturatingUnsigned(long a, long b)
    Adds two long values using saturation arithemetic and numerically treating the values as unsigned.
    static short
    addSaturatingUnsigned(short a, short b)
    Adds two short values using saturation arithemetic and numerically treating the values as unsigned.
    static byte
    maxUnsigned(byte a, byte b)
    Returns the greater of two byte values numerically treating the values as unsigned.
    static int
    maxUnsigned(int a, int b)
    Returns the greater of two int values numerically treating the values as unsigned.
    static long
    maxUnsigned(long a, long b)
    Returns the greater of two long values numerically treating the values as unsigned.
    static short
    maxUnsigned(short a, short b)
    Returns the greater of two short values numerically treating the values as unsigned.
    static byte
    minUnsigned(byte a, byte b)
    Returns the smaller of two byte values numerically treating the values as unsigned.
    static int
    minUnsigned(int a, int b)
    Returns the smaller of two int values numerically treating the values as unsigned.
    static long
    minUnsigned(long a, long b)
    Returns the smaller of two long values numerically treating the values as unsigned.
    static short
    minUnsigned(short a, short b)
    Returns the smaller of two short values numerically treating the values as unsigned.
    static byte
    subSaturating(byte a, byte b)
    Subtracts two byte values using saturation arithemetic.
    static int
    subSaturating(int a, int b)
    Subtracts two int values using saturation arithemetic.
    static long
    subSaturating(long a, long b)
    Subtracts two long values using saturation arithemetic.
    static short
    subSaturating(short a, short b)
    Subtracts two short values using saturation arithemetic.
    static byte
    subSaturatingUnsigned(byte a, byte b)
    Subtracts two byte values using saturation arithemetic and numerically treating the values as unsigned.
    static int
    subSaturatingUnsigned(int a, int b)
    Subtracts two int values using saturation arithemetic and numerically treating the values as unsigned.
    static long
    subSaturatingUnsigned(long a, long b)
    Subtracts two long values using saturation arithemetic and numerically treating the values as unsigned.
    static short
    subSaturatingUnsigned(short a, short b)
    Subtracts two short values using saturation arithemetic and numerically treating the values as unsigned.

    Methods declared in class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details Link icon

    • minUnsigned Link icon

      public static long minUnsigned(long a, long b)
      Returns the smaller of two long values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0L. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the smaller of a and b.
      See Also:
    • maxUnsigned Link icon

      public static long maxUnsigned(long a, long b)
      Returns the greater of two long values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0xFFFFFFFF_FFFFFFFFL numerically treating it as unsigned. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the larger of a and b.
      See Also:
    • addSaturating Link icon

      public static long addSaturating(long a, long b)
      Adds two long values using saturation arithemetic. The lower and upper (inclusive) bounds are Long.MIN_VALUE and Long.MAX_VALUE, respectively.

      If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Long.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Long.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturating Link icon

      public static long subSaturating(long a, long b)
      Subtracts two long values using saturation arithemetic. The lower and upper (inclusive) bounds are Long.MIN_VALUE and Long.MAX_VALUE, respectively.

      If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Long.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Long.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also:
    • addSaturatingUnsigned Link icon

      public static long addSaturatingUnsigned(long a, long b)
      Adds two long values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0L and 0xFFFFFFFF_FFFFFFFFL, respectively, numerically treating them as unsigned.

      If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound 0xFFFFFFFF_FFFFFFFFL.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturatingUnsigned Link icon

      public static long subSaturatingUnsigned(long a, long b)
      Subtracts two long values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0L and 0xFFFFFFFF_FFFFFFFFL, respectively, numerically treating them as unsigned.

      If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound 0L.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also:
    • minUnsigned Link icon

      public static int minUnsigned(int a, int b)
      Returns the smaller of two int values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the smaller of a and b.
      See Also:
    • maxUnsigned Link icon

      public static int maxUnsigned(int a, int b)
      Returns the greater of two int values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0xFFFFFFFF numerically treating it as unsigned. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the larger of a and b.
      See Also:
    • addSaturating Link icon

      public static int addSaturating(int a, int b)
      Adds two int values using saturation arithemetic. The lower and upper (inclusive) bounds are Integer.MIN_VALUE and Integer.MAX_VALUE, respectively.

      If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Integer.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Integer.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturating Link icon

      public static int subSaturating(int a, int b)
      Subtracts two int values using saturation arithemetic. The lower and upper (inclusive) bounds are Integer.MIN_VALUE and Integer.MAX_VALUE, respectively.

      If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Integer.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Integer.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also:
    • addSaturatingUnsigned Link icon

      public static int addSaturatingUnsigned(int a, int b)
      Adds two int values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0 and 0xFFFFFFFF, respectively, numerically treating them as unsigned.

      If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound 0xFFFFFFFF.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturatingUnsigned Link icon

      public static int subSaturatingUnsigned(int a, int b)
      Subtracts two int values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0 and -0xFFFFFFFF, respectively, numerically treating them as unsigned.

      If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound 0.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also:
    • minUnsigned Link icon

      public static short minUnsigned(short a, short b)
      Returns the smaller of two short values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the smaller of a and b.
      See Also:
    • maxUnsigned Link icon

      public static short maxUnsigned(short a, short b)
      Returns the greater of two short values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0xFFFF numerically treating it as unsigned. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the larger of a and b.
      See Also:
    • addSaturating Link icon

      public static short addSaturating(short a, short b)
      Adds two short values using saturation arithemetic. The lower and upper (inclusive) bounds are Short.MIN_VALUE and Short.MAX_VALUE, respectively.

      If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Short.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Short.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturating Link icon

      public static short subSaturating(short a, short b)
      Subtracts two short values using saturation arithemetic. The lower and upper (inclusive) bounds are Short.MIN_VALUE and Short.MAX_VALUE, respectively.

      If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Short.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Short.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also:
    • addSaturatingUnsigned Link icon

      public static short addSaturatingUnsigned(short a, short b)
      Adds two short values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0 and 0xFFFF, respectively, numerically treating them as unsigned.

      If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound 0xFFFF.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturatingUnsigned Link icon

      public static short subSaturatingUnsigned(short a, short b)
      Subtracts two short values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0 and 0xFFFF, respectively, numerically treating them as unsigned.

      If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound 0.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also:
    • minUnsigned Link icon

      public static byte minUnsigned(byte a, byte b)
      Returns the smaller of two byte values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the smaller of a and b.
      See Also:
    • maxUnsigned Link icon

      public static byte maxUnsigned(byte a, byte b)
      Returns the greater of two byte values numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression 0xFF numerically treating it as unsigned. If the operands have the same value, the result is that same value.
      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the larger of a and b.
      See Also:
    • addSaturating Link icon

      public static byte addSaturating(byte a, byte b)
      Adds two byte values using saturation arithemetic. The lower and upper (inclusive) bounds are Byte.MIN_VALUE and Byte.MAX_VALUE, respectively.

      If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Byte.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Byte.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturating Link icon

      public static byte subSaturating(byte a, byte b)
      Subtracts two byte values using saturation arithemetic. The lower and upper (inclusive) bounds are Byte.MIN_VALUE and Byte.MAX_VALUE, respectively.

      If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound Byte.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower bound Byte.MIN_VALUE.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also:
    • addSaturatingUnsigned Link icon

      public static byte addSaturatingUnsigned(byte a, byte b)
      Adds two byte values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0 and 0xFF, respectively, numerically treating them as unsigned.

      If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound 0xFF.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating addition of the operands.
      See Also:
    • subSaturatingUnsigned Link icon

      public static byte subSaturatingUnsigned(byte a, byte b)
      Subtracts two byte values using saturation arithemetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are 0 and 0xFF, respectively, numerically treating them as unsigned.

      If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound 0.

      Parameters:
      a - the first operand.
      b - the second operand.
      Returns:
      the saturating difference of the operands.
      See Also: