Java Abs abs(double[] arr)

Here you can find the source of abs(double[] arr)

Description

Computes the absolute value for each element in the array, in place.

License

Open Source License

Parameter

Parameter Description
arr a float array

Declaration

public static void abs(double[] arr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w  w w  .  ja  v  a 2  s .c o m*/
     * Computes the absolute value for each element in the array, in place.
     *
     * @param   arr a short array
     */
    public static void abs(short[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (short) Math.abs(arr[i]);
        }
    }

    /**
     * Computes the absolute value for each element in the array, in place.
     *
     * @param   arr an integer array
     */
    public static void abs(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Math.abs(arr[i]);
        }
    }

    /**
     * Computes the absolute value for each element in the array, in place.
     *
     * @param   arr a long array
     */
    public static void abs(long[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Math.abs(arr[i]);
        }
    }

    /**
     * Computes the absolute value for each element in the array, in place.
     *
     * @param   arr a float array
     */
    public static void abs(float[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Math.abs(arr[i]);
        }
    }

    /**
     * Computes the absolute value for each element in the array, in place.
     *
     * @param   arr a float array
     */
    public static void abs(double[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Math.abs(arr[i]);
        }
    }
}

Related

  1. abs(double x)
  2. abs(double x)
  3. abs(double x)
  4. abs(double z)
  5. abs(double... values)
  6. abs(double[] array)
  7. abs(double[] da)
  8. abs(double[] in)
  9. abs(double[] in)