Here you can find the source of normalizeComponentsOverwrite(float[][][][] in)
public static final void normalizeComponentsOverwrite(float[][][][] in)
//package com.java2s; //License from project: Apache License public class Main { public static final void normalizeComponentsOverwrite(float[][][][] in) { int nx = in.length; int ny = in[0].length; int nz = in[0][0].length; int nc = in[0][0][0].length; float lensqr = -1; for (int x = 0; x < nx; x++) for (int y = 0; y < ny; y++) for (int z = 0; z < nz; z++) { lensqr = sumSquares(in[x][y][z]); if (lensqr > 0) { for (int c = 0; c < nc; c++) { in[x][y][z][c] = (float) (in[x][y][z][c] / Math.sqrt(lensqr)); }/*from w w w.jav a 2 s. c o m*/ } } } public static final float sumSquares(float[] in) { float sum = 0; for (int i = 0; i < in.length; i++) { sum += (in[i] * in[i]); } return sum; } public static final double sumSquares(double[] in) { float sum = 0; for (int i = 0; i < in.length; i++) { sum += (in[i] * in[i]); } return sum; } }