Java Matrix matrixConcatLR(double[][] LMatrix, double[][] RMatrix)

Here you can find the source of matrixConcatLR(double[][] LMatrix, double[][] RMatrix)

Description

matrix Concat LR

License

Open Source License

Declaration

public static double[][] matrixConcatLR(double[][] LMatrix,
            double[][] RMatrix) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[][] matrixConcatLR(double[][] LMatrix,
            double[][] RMatrix) {
        if (LMatrix.length != RMatrix.length) {
            System.out//from  w w  w.  j  av a  2  s.  co  m
                    .println("matrixConcatLR error: the number of rows in two matrix should be same");
            System.exit(0);
        }

        int numRows = LMatrix.length;
        int numColsForLMatrix = LMatrix[0].length;
        int numColsForRMatrix = RMatrix[0].length;

        double[][] newMatrix = new double[numRows][numColsForLMatrix
                + numColsForRMatrix];

        for (int row = 0; row < numRows; row++) {
            for (int col = 0; col < numColsForLMatrix; col++) {
                newMatrix[row][col] = LMatrix[row][col];
            }
            for (int col = numColsForLMatrix; col < numColsForLMatrix
                    + numColsForRMatrix; col++) {
                newMatrix[row][col] = RMatrix[row][col - numColsForLMatrix];
            }
        }

        return newMatrix;
    }
}

Related

  1. matrix_x_matrix(double[][] A, double[][] B)
  2. matrix_x_vectorMatrix(double[][] mat, double[][] vector, int vectorCol)
  3. matrixAbsDiff(double m1[][], double m2[][])
  4. matrixATrans_x_matrixB(double[][] matA, double[][] matB)
  5. matrixConcatUL(double[][] UMatrix, double[][] LMatrix)
  6. matrixDestructAdd(double[][] m1, double[][] m2)
  7. matrixDeterminant(final float[] m, final int m_offset)
  8. matrixEquals(int[][] firstMatrix, int[][] secondMatrix)