Java Abs abs(double[] v)

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

Description

Takes the absolute value of each component of an array.

License

Open Source License

Declaration

public static double[] abs(double[] v) 

Method Source Code

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

public class Main {
    /**//from  w w w.  j a  v a 2s . c  om
     * Takes the absolute value of each component of an array.
     */
    public static double[] abs(double[] v) {
        double[] ans = new double[v.length];
        for (int i = 0; i < v.length; i++) {
            ans[i] = Math.abs(v[i]);
        }
        return (ans);
    }

    /**
     * Takes the absolute value of each component of an array.
     */
    public static double[][] abs(double[][] v) {
        double[][] ans = new double[v.length][];
        for (int i = 0; i < v.length; i++) {
            ans[i] = abs(v[i]);
        }
        return (ans);
    }

    /**
     * Takes the absolute value of each component of an array.
     */
    public static int[] abs(int[] v) {
        int[] ans = new int[v.length];
        for (int i = 0; i < v.length; i++) {
            ans[i] = Math.abs(v[i]);
        }
        return (ans);
    }

    /**
     * Takes the absolute value of each component of an array.
     */
    public static int[][] abs(int[][] v) {
        int[][] ans = new int[v.length][];
        for (int i = 0; i < v.length; i++) {
            ans[i] = abs(v[i]);
        }
        return (ans);
    }
}

Related

  1. abs(double[] arr)
  2. abs(double[] array)
  3. abs(double[] da)
  4. abs(double[] in)
  5. abs(double[] in)
  6. abs(double[][] A)
  7. abs(final byte x)
  8. abs(final double d)
  9. abs(final double value)