Normalizes the exponentials of provided associative array by using the
log-sum-exp trick.

@param associativeArray
323219
public static void normalizeExp(AssociativeArray associativeArray) {
        double max = max(associativeArray.toFlatDataCollection());

        double sum = 0.0;
        //Prevents numeric underflow by subtracting the max. References: http://www.youtube.com/watch?v=-RVM21Voo7Q
        for(Map.Entry<Object, Object> entry : associativeArray.entrySet()) {
            Double value = Math.exp(TypeInference.toDouble(entry.getValue())-max);
            associativeArray.put(entry.getKey(), value);

            sum += value;
        }
        
        if(sum!=0.0) {
            for(Map.Entry<Object, Object> entry : associativeArray.entrySet()) {
                associativeArray.put(entry.getKey(), TypeInference.toDouble(entry.getValue())/sum);
            }
        }
    }
229184
public function normalizeArray(array $array)
    {
        $normal = [];

        foreach ($array as $action => $config) {
            if (is_string($config)) {
                $config = ['className' => $config];
            }

            if (is_int($action)) {
                list(, $action) = pluginSplit($config['className']);
            }

            $action = Inflector::variable($action);
            $normal[$action] = $config;
        }

        return $normal;
    }
791602
public static function normalizeArray(array &$array, int $sort_flags = SORT_REGULAR)
    {
        ksort($array, $sort_flags);

        foreach ($array as $index => &$arr) {
            if (is_array($arr)) {
                ArrayTool::normalizeArray($arr, $sort_flags);
            }

            if (is_array($array[$index]) && empty($array[$index])) {
                unset($array[$index]);
            }
        }
    }
40035
public static double normalizeLogProps(double[] logProps) {
        double logPropSum = DoubleArrays.logSum(logProps);
        if (logPropSum == Double.NEGATIVE_INFINITY) {
            double uniform = FastMath.log(1.0 / (double)logProps.length);
            for (int d = 0; d < logProps.length; d++) {
                logProps[d] = uniform;
            }
        } else if (logPropSum == Double.POSITIVE_INFINITY) {
            int count = DoubleArrays.count(logProps, Double.POSITIVE_INFINITY);
            if (count == 0) {
                throw new RuntimeException("Unable to normalize since sum is infinite but contains no infinities: " + Arrays.toString(logProps));
            }
            double constant = FastMath.log(1.0 / (double) count);
            for (int d=0; d<logProps.length; d++) {
                if (logProps[d] == Double.POSITIVE_INFINITY) {
                    logProps[d] = constant;
                } else {
                    logProps[d] = Double.NEGATIVE_INFINITY;
                }
            }
        } else {
            for (int d = 0; d < logProps.length; d++) {
                logProps[d] -= logPropSum;
                assert(!Double.isNaN(logProps[d]));
            }            
        }
        return logPropSum;
    }
237660
private static function normalize(&$val) : void
    {
        if (is_array($val)) {
            array_walk($val, [__CLASS__, 'normalize']);
        } elseif (is_scalar($val)) {
            $val = strlen($val) ? $val : null;
        }
    }
1260896
public static function is_associative (array $array)
		{
			foreach ($array as $k => $v)
			{
				$t = str_replace((int)$k, '', $k);
				if (!empty($t))
				{
					if (!static::is_int($k))
					{
						return true;
					}
				}
			}

			return false;
		}
609617
@Override
    public INDArray average(INDArray target, INDArray[] arrays) {
        if (arrays == null || arrays.length == 0)
            throw new RuntimeException("Input arrays are missing");

        if (arrays.length == 1) {
            //Edge case - average 1 array - no op
            if(target == null){
                return null;
            }
            return target.assign(arrays[0]);
        }

        long len = target != null ? target.lengthLong() : arrays[0].length();

        PointerPointer dataPointers = new PointerPointer(arrays.length);
        val firstType = arrays[0].dataType();

        for (int i = 0; i < arrays.length; i++) {
            Nd4j.getCompressor().autoDecompress(arrays[i]);

            Preconditions.checkArgument(arrays[i].dataType() == firstType, "All arrays must have the same data type");

            if (arrays[i].elementWiseStride() != 1)
                throw new ND4JIllegalStateException("Native averaging is applicable only to continuous INDArrays");

            if (arrays[i].lengthLong() != len)
                throw new ND4JIllegalStateException("All arrays should have equal length for averaging");

            dataPointers.put(i, arrays[i].data().addressPointer());
        }


        nativeOps.average(null,
                dataPointers, (LongPointer) arrays[0].shapeInfoDataBuffer().addressPointer(),
                null, null,
                target == null ? null : target.data().addressPointer(), target == null ? null : (LongPointer) target.shapeInfoDataBuffer().addressPointer(),
                null, null,
                arrays.length,
                    len,
                true);

        return target;
    }
1365815
public static void normalizeColumns(final double[][] m1) {
    final int columndimension = getColumnDimensionality(m1);
    for(int col = 0; col < columndimension; col++) {
      double norm = 0.0;
      for(int row = 0; row < m1.length; row++) {
        final double v = m1[row][col];
        norm += v * v;
      }
      if(norm > 0) {
        norm = FastMath.sqrt(norm);
        for(int row = 0; row < m1.length; row++) {
          m1[row][col] /= norm;
        }
      }
    }
  }
478510
final void normalize() {
        if (intLen == 0) {
            offset = 0;
            return;
        }

        int index = offset;
        if (value[index] != 0)
            return;

        int indexBound = index+intLen;
        do {
            index++;
        } while(index < indexBound && value[index] == 0);

        int numZeros = index - offset;
        intLen -= numZeros;
        offset = (intLen == 0 ?  0 : offset+numZeros);
    }
725407
public function normalizeArray($array, $sort = true) {
        $output = array();

        if ($array) {
            foreach ($array as $key => $value) {
                if (is_numeric($key)) {
                    $output[] = $value;
                } else {
                    $output[] = $key;
                }
            }

            if ($sort) {
                sort($output);
            }
        }

        return $output;
    }
851762
public static function normalize(array $array, $default): array
    {
        $normalized = [];

        foreach ($array as $key => $value) {
            if (is_numeric($key)) {
                $key = $value;
                $value = $default;
            }

            $normalized[$key] = $value;
        }

        return $normalized;
    }
814645
function assocIndexOf(array, key) {
  var length = array.length
  while (length--) {
    if (eq(array[length][0], key)) {
      return length
    }
  }
  return -1
}
1144530
public static void sort(long[] longArray) {
        int index = 0;
        long value = 0;
        
        for(int i = 1; i < longArray.length; i++) {
            index = i;
            value = longArray[index];
            
            while(index > 0 && value < longArray[index - 1]) {
                longArray[index] = longArray[index - 1];
                
                index--;
            }
            
            longArray[index] = value;
        }
    }
1008582
void normalizeY(double yMax, int normMax) {
		exploded.forEach(y -> {
			int norm = (int) Math.round((y / yMax) * normMax);
			normalized.add(norm);
		});
	}
1370676
private function _fromAssociativeArray(array $array)
    {
        foreach ($this->_fields as $fieldName => $field) {
            $fieldType = $field['FieldType'];   
            if (is_array($fieldType)) {
                if ($this->_isComplexType($fieldType[0])) {
                    if (array_key_exists($fieldName, $array)) { 
                        $elements = $array[$fieldName];
                        if (!$this->_isNumericArray($elements)) {
                            $elements =  array($elements);    
                        }
                        if (count ($elements) >= 1) {
                            // // require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php");

                            foreach ($elements as $element) {
                                $this->_fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
                            }
                        }
                    } 
                } else {
                    if (array_key_exists($fieldName, $array)) {
                        $elements = $array[$fieldName];
                        if (!$this->_isNumericArray($elements)) {
                            $elements =  array($elements);    
                        }
                        if (count ($elements) >= 1) {
                            foreach ($elements as $element) {
                                $this->_fields[$fieldName]['FieldValue'][] = $element;
                            }
                        }  
                    }
                }
            } else {
                 if ($this->_isComplexType($fieldType)) {
                    if (array_key_exists($fieldName, $array)) {
                        // // require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php");
                        $this->_fields[$fieldName]['FieldValue'] = new $fieldType($array[$fieldName]);
                    }   
                 } else {
                    if (array_key_exists($fieldName, $array)) {
                        $this->_fields[$fieldName]['FieldValue'] = $array[$fieldName];
                    }
                 }
            }
        }
    }
518904
private function normalizeArray(array &$data)
    {
        $normalizedData = array();

        foreach ($data as $key => $val) {
            $normalizedKey = $this->normalizeString($key);

            if ($normalizedKey !== $key) {
                if (array_key_exists($normalizedKey, $normalizedData)) {
                    throw new NormalizationException(sprintf(
                        'The key "%s" is invalid as it will override the existing key "%s"',
                        $key,
                        $normalizedKey
                    ));
                }
            }

            $normalizedData[$normalizedKey] = $val;
            $key = $normalizedKey;

            if (is_array($val)) {
                $this->normalizeArray($normalizedData[$key]);
            }
        }

        $data = $normalizedData;
    }
24425
public static function normalize($headers, $associative = true)
    {
        $normalizedHeaders = [];

        if (!$associative) {
            $headers = self::normalize($headers);
        }

        foreach (HeadersParser::parse($headers) as $name => $value) {
            if (strpos($value, 'HTTP/') === 0) {
                continue;
            }

            list($name, $value) = explode(':', $value, 2);

            $name = self::normalizeHeaderName($name);
            $value = self::normalizeHeaderValue($value);

            if (!$associative) {
                $normalizedHeaders[] = $name.': '.$value;
            } else {
                $normalizedHeaders[$name] = isset($normalizedHeaders[$name])
                    ? $normalizedHeaders[$name].', '.$value
                    : $value;
            }
        }

        return $normalizedHeaders;
    }