Example usage for org.apache.commons.math4.util FastMath round

List of usage examples for org.apache.commons.math4.util FastMath round

Introduction

In this page you can find the example usage for org.apache.commons.math4.util FastMath round.

Prototype

public static int round(final float x) 

Source Link

Document

Get the closest int to x.

Usage

From source file:com.ericbarnhill.arrayMath.ArrayMath.java

/**
  * Element-wise {@code round} of a {@code double[]}. Returns deep copy.
  */*  w  w w.ja v a 2s . co  m*/
  * @param f {@code double[]} array.
  * @return  {@code double[]} array.
  * 
  * @since 0.1
  */
public static double[] asinC(double[] f) {
    final int fi = f.length;
    double[] h = new double[fi];
    for (int i = 0; i < fi; i++) {
        h[i] = FastMath.round(f[i]);
    }
    return h;
}

From source file:com.ericbarnhill.arrayMath.ArrayMath.java

/**
  * In-place element-wise {@code round} of a {@code double[]}. Returns reference to first passed array.
  *//from   w ww  .  j a  va2 s  .  c  om
  * @param f {@code double[]} array.
  * @return  {@code double[]} array.
  * 
  * @since 0.1
  */
public static double[] round(double[] f) {
    final int fi = f.length;
    for (int i = 0; i < fi; i++) {
        f[i] = FastMath.round(f[i]);
    }
    return f;
}

From source file:com.ericbarnhill.arrayMath.ArrayMath.java

/**
  * Element-wise {@code round} of a {@code double[]}. Returns deep copy.
  */*  ww  w  .j  a v  a 2 s .  c  o m*/
  * @param f {@code double[]} array.
  * @return  {@code double[]} array.
  * 
  * @since 0.1
  */
public static double[] roundC(double[] f) {
    final int fi = f.length;
    double[] h = new double[fi];
    for (int i = 0; i < fi; i++) {
        h[i] = FastMath.round(f[i]);
    }
    return h;
}