Java Array Flatten flatten(float[][] mat)

Here you can find the source of flatten(float[][] mat)

Description

flatten

License

Apache License

Declaration

public static float[] flatten(float[][] mat) 

Method Source Code

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

import java.util.List;

public class Main {
    public static float[] flatten(float[][] mat) {
        float[] result = new float[mat.length * mat[0].length];
        for (int i = 0; i < mat.length; ++i) {
            System.arraycopy(mat[i], 0, result, i * mat[0].length,
                    mat[i].length);/*from w  ww .java  2s.  com*/
        }
        return result;
    }

    public static double[] flatten(double[][] mat) {
        double[] result = new double[mat.length * mat[0].length];
        for (int i = 0; i < mat.length; ++i) {
            System.arraycopy(mat[i], 0, result, i * mat[0].length,
                    mat[i].length);
        }
        return result;
    }

    public static float[] flatten(float[][][] tens) {
        float[] result = new float[tens.length * tens[0].length
                * tens[0][0].length];
        for (int i = 0; i < tens.length; ++i) {
            for (int j = 0; j < tens[0].length; ++j) {
                System.arraycopy(tens[i][j], 0, result, i * tens[0].length
                        * tens[0][0].length + j * tens[0][0].length,
                        tens[i][j].length);
            }
        }
        return result;
    }

    public static float[] flatten(List<float[]> mat) {
        float[] result = new float[mat.size() * mat.get(0).length];
        for (int i = 0; i < mat.size(); ++i) {
            System.arraycopy(mat.get(i), 0, result, i * mat.get(0).length,
                    mat.get(i).length);
        }
        return result;
    }

    public static int flatten(int I, int J, int i, int j) {
        return (i * J) + j;
    }

    public static String flatten(int I, int J, int i, String j) {
        return "(" + (i * J) + " + " + j + ")";
    }

    public static String flatten(int I, int J, String i, int j) {
        return "(" + i + " * " + J + " + " + j + ")";
    }

    public static String flatten(int I, int J, String i, String j) {
        return "(" + i + " * " + J + " + " + j + ")";
    }

    public static int flatten(int I, int J, int K, int i, int j, int k) {
        return i * J * K + j * K + k;
    }

    public static String flatten(int I, int J, int K, int i, int j, String k) {
        return "(" + (i * J * K + j * K) + " + " + k + ")";
    }

    public static String flatten(int I, int J, int K, String i, int j, int k) {
        return "(" + i + " * " + (J * K) + " + " + (j * K) + " + " + k
                + ")";
    }

    public static String flatten(int I, int J, int K, int i, String j, int k) {
        return "(" + (i * J * K) + " + " + j + "  * " + K + " + " + k + ")";
    }

    public static String flatten(int I, int J, int K, String i, String j,
            int k) {
        return "(" + i + " * " + (J * K) + " + " + j + "  * " + K + " + "
                + k + ")";
    }

    public static String flatten(int I, int J, int K, String i, int j,
            String k) {
        return "(" + i + " * " + (J * K) + " + " + (j * K) + " + " + k
                + ")";
    }

    public static String flatten(int I, int J, int K, int i, String j,
            String k) {
        return "(" + (i * J * K) + " + " + j + "  * " + K + " + " + k + ")";
    }

    public static String flatten(int I, int J, int K, String i, String j,
            String k) {
        return "(" + i + " * " + (J * K) + " + " + j + "  * " + K + " + "
                + k + ")";
    }
}

Related

  1. flatten(byte[][] first)
  2. flatten(E[][] a)
  3. flatten(final Object[] array)
  4. flatten(Object[] array)
  5. flatten(Object[] array)
  6. flatten(Object[] lines, String sep)
  7. flatten(String s[])