Java Array Normalize normalize(float[][] vals, float min, float max)

Here you can find the source of normalize(float[][] vals, float min, float max)

Description

normalize

License

Creative Commons License

Declaration

public static void normalize(float[][] vals, float min, float max) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

public class Main {
    public static void normalize(float[][] vals, float min, float max) {
        final float divider = max - min + 1;
        for (int xx = 0; xx < vals.length; xx++) {
            for (int zz = 0; zz < vals[xx].length; zz++) {
                vals[xx][zz] = clamp(vals[xx][zz], min, max);
                vals[xx][zz] -= min;/*ww  w  .  ja  va 2  s .  c o  m*/
                vals[xx][zz] /= divider;
            }
        }
    }

    public static float clamp(float val, float min, float max) {
        if (val < min) {
            return min;
        } else if (val > max) {
            return max;
        }
        return val;
    }
}

Related

  1. normalize(float[] in)
  2. normalize(float[] in)
  3. normalize(float[] input)
  4. normalize(float[] v)
  5. normalize(float[] vec)
  6. normalize(int[] a)
  7. normalize(int[] values)
  8. normalize(int[][][] data, int startX, int startY, int stopX, int stopY, double scale)
  9. normalize(long[] v, float[] target)