Java Square Calculate squaredNorm(final double[] vec)

Here you can find the source of squaredNorm(final double[] vec)

Description

Returns the square of the euclidean norm of a vector.

License

Open Source License

Parameter

Parameter Description
vec the vector.

Return

the square of the euclidean norm of vector vec.

Declaration

public static double squaredNorm(final double[] vec) 

Method Source Code

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

public class Main {
    /**//from w w  w. j av a  2  s .c o  m
    * Returns the square of the euclidean norm of a vector.
    * @param vec  the vector.
    * @return     the square of the euclidean norm of vector vec.
    * 
    */
    public static double squaredNorm(final double[] vec) {
        assert vec != null;

        double s = 0;
        for (double i : vec) {
            s += Math.pow(i, 2);
        }
        return s;
    }
}

Related

  1. square2Index(long square)
  2. squareArea(final double side)
  3. squared(int x)
  4. squaredError(double[] vector1, double[] vector2)
  5. squaredLoss(double[] x, double[] y, double w_0, double w_1)
  6. squareEntries(double[][] m)
  7. squarenessRatio(final double w, final double h)
  8. squareOfSumFirstN(long n)
  9. squareRoot(Number num)