Here you can find the source of abs(double[] v)
public static double[] abs(double[] v)
//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); } }