Example usage for org.apache.commons.math3.util MathArrays safeNorm

List of usage examples for org.apache.commons.math3.util MathArrays safeNorm

Introduction

In this page you can find the example usage for org.apache.commons.math3.util MathArrays safeNorm.

Prototype

public static double safeNorm(double[] v) 

Source Link

Document

Returns the Cartesian norm (2-norm), handling both overflow and underflow.

Usage

From source file:nars.predict.RNNBeliefPrediction.java

public static double[] normalize(double[] x) {
    double d = MathArrays.safeNorm(x);
    if (d == 0)//ww w  . j  a v  a  2 s.c o  m
        return x;
    for (int i = 0; i < x.length; i++)
        x[i] /= d;
    return x;
}