computes the log10 of all values of the passed array - Android java.lang

Android examples for java.lang:array calculation

Description

computes the log10 of all values of the passed array

Demo Code


//package com.java2s;

public class Main {
    /**/*from ww w  .  j  a va 2s .c o m*/
     * computes the log10 of all values of the passed array
     * @param _arr the array to compute log10 from
     * @return an array containing the log10 of the passed array
     */
    public static double[] log10(double[] _arr) {
        double[] res = new double[_arr.length];
        for (int i = 0; i < res.length; i++) {
            if (0.0 == _arr[i]) {
                res[i] = 0;
                continue;
            }
            //         Log.e("ArrayHelper", "before log:"+_arr[i]);
            res[i] = Math.log10(Math.abs(_arr[i]));
            //         Log.e("ArrayHelper", "after log:"+res[i]);
        }
        return res;
    }
}

Related Tutorials