Java Vector vectorMagnitude4D(float[][][][] vec4D)

Here you can find the source of vectorMagnitude4D(float[][][][] vec4D)

Description

vector Magnitude D

License

Apache License

Declaration

static public float[][][] vectorMagnitude4D(float[][][][] vec4D) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    static public float[][][] vectorMagnitude4D(float[][][][] vec4D) {
        int rows = vec4D.length;
        int cols = vec4D[0].length;
        int slices = vec4D[0][0].length;
        int components = vec4D[0][0][0].length;
        float[][][] M = new float[rows][cols][slices];
        double sum = 0;
        for (int i = 0; i < rows; i++)
            for (int j = 0; j < cols; j++)
                for (int k = 0; k < slices; k++) {
                    sum = 0;//from w  ww  .j  a  va 2 s  .com
                    for (int l = 0; l < components; l++) {
                        sum += Math.pow(vec4D[i][j][k][l], 2);
                    }
                    M[i][j][k] = (float) Math.sqrt(sum);
                }
        return M;
    }
}

Related

  1. vectorDistance(double[] vec1, double[] vec2, double power)
  2. vectorIndexToUpperTriangularIndices(int numberOfRows, int index)
  3. vectorKLDivergence(double v1[], double v2[])
  4. vectorL2Norm(double[] v)
  5. vectorLog10(double v1[])
  6. vectorSimilarity(float[] wordVector1, float[] wordVector2)
  7. vectorSizeToBucketNum(int vectorSize)
  8. vectorSubset(Vector aV1, Vector aV2)
  9. vectorValue(double[] x)