Java Matrix Sum sum(float[][] a1, float[][] a2)

Here you can find the source of sum(float[][] a1, float[][] a2)

Description

Element-wise summation of two arrays, output writes over first array

License

Open Source License

Parameter

Parameter Description
a1 first array
a2 second array

Declaration

public static void sum(float[][] a1, float[][] a2) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  w w  . j  a v  a2  s . c  o  m
     * Element-wise summation of two arrays, output writes over first array
     * 
     * @param a1 first array
     * @param a2 second array
     */
    public static void sum(float[][] a1, float[][] a2) {
        for (int j = 0; j < a1.length; j++) {
            sum(a1[j], a2[j]);
        }
    }

    /**
     * Element-wise summation of two arrays, output writes over first array
     * 
     * @param a1 first array
     * @param a2 second array
     */
    public static void sum(float[] a1, float[] a2) {
        for (int j = 0; j < a1.length; j++) {
            a1[j] += a2[j];
        }
    }

    /**
     * Element-wise summation of two arrays, output writes over first array
     * 
     * @param a1 first array
     * @param a2 second array
     */
    public static void sum(int[][] a1, int[][] a2) {
        for (int j = 0; j < a1.length; j++) {
            sum(a1[j], a2[j]);
        }
    }

    /**
     * Element-wise summation of two arrays, output writes over first array
     * 
     * @param a1 first array
     * @param a2 second array
     */
    public static void sum(int[] a1, int[] a2) {
        for (int j = 0; j < a1.length; j++) {
            a1[j] += a2[j];
        }
    }

    /**
     * Element-wise summation of two arrays, output writes over first array
     * 
     * @param a1 first array
     * @param a2 second array
     */
    public static void sum(double[][] a1, double[][] a2) {
        for (int j = 0; j < a1.length; j++) {
            sum(a1[j], a2[j]);
        }
    }

    /**
     * Element-wise summation of two arrays, output writes over first array
     * 
     * @param a1 first array
     * @param a2 second array
     */
    public static void sum(double[] a1, double[] a2) {
        for (int j = 0; j < a1.length; j++) {
            a1[j] += a2[j];
        }
    }
}

Related

  1. sum(double[][] input, int column)
  2. sum(double[][] input, int column)
  3. sum(double[][] kernel1, double[][] kernel2)
  4. sum(double[][] o)
  5. sum(double[][] X, int axis)
  6. sum(int M[][])
  7. sum(int[][][] X, int[] coords)
  8. sumArrayDim(double[][] array, int dimToSummarize)
  9. sumArrays(double a[][], double b[][], String sign)