All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jeometry.math.Matrix Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package org.jeometry.math;

import java.awt.Dimension;

import org.jeometry.Jeometry;

/**
 * This interface describe a general two dimensional matrix. A matrix A is a two-dimensional array of double values that is defined such as: 
 * $$
 * A = \begin{bmatrix} 
 *        a_{00} & \dots  & a_{0i} & \dots  & a_{0m} \\
 *        \vdots & \ddots & \vdots & \ddots & \vdots \\
 *        a_{i0} & \dots  & a_{ij} & \dots  & a_{im} \\
 *        \vdots & \ddots & \vdots & \ddots & \vdots \\     
 *        a_{n0} & \dots  & a_{nj} & \dots  & a_{nm}
 *     \end{bmatrix}
 * $$
 * where:
 * 
    *
  • n is the number of rows. *
  • m is the number of columns. *
  • aij is the value located at row i and column j *
* @author Julien Seinturier - COMEX S.A. - [email protected] - https://github.com/jorigin/jeometry * @version {@value Jeometry#version} b{@value Jeometry#BUILD} * @since 1.0.0 */ public interface Matrix { /** * Indicates that the export of a matrix data to a linear array is row-major (made row by row from the first to the last). * @see #COLUMN_MAJOR */ public static final int ROW_MAJOR = 1; /** * Indicates that the the export of a matrix data to a linear array is column-major (made column by column from the first to the last). * @see #ROW_MAJOR */ public static final int COLUMN_MAJOR = 2; /** * Get the matrix values as a linear array according to the given ordering. * If the ordering is {@link #ROW_MAJOR}, the output array contains the sequence of all rows from the first to the last. * On the other hand, if the ordering is {@link #COLUMN_MAJOR}, the output array contains the sequence of all columns from the first to the last. * @param ordering the ordering to use ({@link #ROW_MAJOR} or {@link #COLUMN_MAJOR}). * @return the matrix values as a linear array. * @see #setDataArray(int, double[]) */ public double[] getDataArray(int ordering); /** * Get the matrix values as a linear array according to the given ordering. * If the ordering is {@link #ROW_MAJOR}, the output array contains the sequence of all rows from the first to the last. * On the other hand, if the ordering is {@link #COLUMN_MAJOR}, the output array contains the sequence of all columns from the first to the last. * @param ordering the ordering to use ({@link #ROW_MAJOR} or {@link #COLUMN_MAJOR}). * @param output the array where the value are stored. * @return the matrix values as a linear array. * @see #setDataArray(int, double[]) * @throws IllegalArgumentException if the output array does not fit the matrix capabilities. */ public double[] getDataArray(int ordering, double[] output) throws IllegalArgumentException; /** * Set the matrix values from a linear array according to the given ordering. * If the ordering is {@link #ROW_MAJOR}, the output array contains the sequence of all rows from the first to the last. * On the other hand, if the ordering is {@link #COLUMN_MAJOR}, the output array contains the sequence of all columns from the first to the last. * @param ordering the ordering of the linear array ({@link #ROW_MAJOR} or {@link #COLUMN_MAJOR}). * @param data the matrix values. * @throws IllegalArgumentException if the given data does not fit the matrix capabilities. */ public void setDataArray(int ordering, double[] data) throws IllegalArgumentException; /** * Get the matrix values as a two-dimensionnal array. * The output array has the same number of rows and columns as the matrix. * @return the matrix values as a two-dimensionnal array. * @see #setDataArray2D(double[][]) */ public double[][] getDataArray2D(); /** * Get the matrix values as a two-dimensionnal array. * The output array has the same number of rows and columns as the matrix. * @param output the two-dimensional array where the value are stored. * @return the matrix values as a two-dimensionnal array. * @see #setDataArray2D(double[][]) */ public double[][] getDataArray2D(double[][] output); /** * Set the matrix values from a two-dimensionnal array. * The input array has to have the same number of rows and columns as the matrix. * @param data the matrix values * @throws IllegalArgumentException if the given data does not fir the matrix capabilities. */ public void setDataArray2D(double[][] data) throws IllegalArgumentException; /** * Get the value that is stored at the given (row, column). * @param row the row that holds the value. * @param col the column that holds the value. * @return the value that is stored at the given (row, column). * @throws IllegalArgumentException if the row or col does not fit the matrix size. * @see #setValue(int, int, double) */ public double getValue(int row, int col) throws IllegalArgumentException; /** * Set the value that is stored at the given (row, column). * @param row the row that holds the value. * @param col the column that holds the value. * @param value value to store at the given (row, column). * @throws IllegalArgumentException if the row or col does not fit the matrix size. * @see #getValue(int, int) */ public void setValue(int row, int col, double value) throws IllegalArgumentException; /** * Copy the given matrix values within this one. After a call to this method, all cells [row, column] of this matrix * have the same values as the cells [row, column] from the given matrix. * @param matrix the matrix from which the values are copied * @throws IllegalArgumentException if the given matrix size is not compatible with this one */ public void setValues(Matrix matrix); /** * Set all the matrix cells with the given value. * @param value the value to set to all the matrix cells */ public void setTo(double value); /** * Get a {@link Vector} made of the values of the column at the given index. * @param index the index of the column (0 ≤ index < {@link #getColumnsCount()}) * @return a {@link Vector} made of the values of the column at the given index * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getColumnsCount()}[ * @see #getColumn(int, Vector) * @see #getColumn(int, double[]) */ public Vector getColumn(int index); /** * Fill the given {@link Vector} with the values of the column at the given index. * The vector {@link Vector#getDimension() dimension} has to be equals to the {@link #getRowsCount() rows count} of this matrix. * @param index the index of the column (0 ≤ index < {@link #getColumnsCount()}) * @param output the vector to fill * @return a reference on the output vector * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getColumnsCount()}[ or if the vector dimension differs from the matrix {@link #getRowsCount() rows count} * @see #getColumn(int) * @see #getColumn(int, double[]) */ public Vector getColumn(int index, Vector output); /** * Fill the given double array with the values of the column at the given index. * The length of the array has to be equals to the {@link #getRowsCount() rows count} of this matrix. * @param index the index of the column (0 ≤ index < {@link #getColumnsCount()}) * @param output the double array to fill * @return a reference on the output array * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getColumnsCount()}[ or if the length of the array differs from the matrix {@link #getRowsCount() rows count} * @see #getColumn(int) * @see #getColumn(int, Vector) */ public double[] getColumn(int index , double[] output); /** * Set the values of the column at the given index with the ones given by the input {@link Vector}. * The vector {@link Vector#getDimension() dimension} has to be equals to the {@link #getRowsCount() rows count} of this matrix. * @param index the index of the column (0 ≤ index < {@link #getColumnsCount()}) * @param input the source vector * @return a reference on this object (useful for chaining operations) * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getColumnsCount()}[ or if the vector dimension differs from the matrix {@link #getRowsCount() rows count} * @see #setColumn(int, double[]) */ public Matrix setColumn(int index, Vector input); /** * Set the values of the column at the given index with the ones given by the input double array. * The length of the array has to be equals to the {@link #getRowsCount() rows count} of this matrix. * @param index the index of the column (0 ≤ index < {@link #getColumnsCount()}) * @param input the source array * @return a reference on this object (useful for chaining operations) * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getColumnsCount()}[ or if the length of the array differs from the matrix {@link #getRowsCount() rows count} * @see #setColumn(int, Vector) */ public Matrix setColumn(int index, double[] input); /** * Get a {@link Vector} made of the values of the row at the given index. * @param index the index of the row (0 ≤ index < {@link #getRowsCount()}) * @return a {@link Vector} made of the values of the row at the given index * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getRowsCount()}[ * @see #getRow(int, Vector) * @see #getRow(int, double[]) */ public Vector getRow(int index); /** * Fill the given {@link Vector} with the values of the row at the given index. * The vector {@link Vector#getDimension() dimension} has to be equals to the {@link #getColumnsCount() columns count} of this matrix. * @param index the index of the row (0 ≤ index < {@link #getRowsCount()}) * @param output the vector to fill * @return a reference on the output vector * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getRowsCount()}[ or if the vector dimension differs from the matrix {@link #getColumnsCount() columns count} * @see #getRow(int) * @see #getRow(int, double[]) */ public Vector getRow(int index, Vector output); /** * Fill the given double array with the values of the row at the given index. * The length of the array has to be equals to the {@link #getColumnsCount() columns count} of this matrix. * @param index the index of the row (0 ≤ index < {@link #getRowsCount()}) * @param output the array to fill * @return a reference on the output array * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getRowsCount()}[ or if the length of the array differs from the matrix {@link #getColumnsCount() columns count} * @see #getRow(int) * @see #getRow(int, Vector) */ public double[] getRow(int index, double[] output); /** * Set the values of the row at the given index with the ones given by the input {@link Vector}. * The vector {@link Vector#getDimension() dimension} has to be equals to the {@link #getColumnsCount() columns count} of this matrix. * @param index the index of the row (0 ≤ index < {@link #getRowsCount()}) * @param input the source vector * @return a reference on this object (useful for chaining operations) * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getRowsCount()}[ or if the vector dimension differs from the matrix {@link #getColumnsCount() columns count} * @see #setRow(int, double[]) */ public Matrix setRow(int index, Vector input); /** * Set the values of the row at the given index with the ones given by the input double array. * The length of the array has to be equals to the {@link #getColumnsCount() columns count} of this matrix. * @param index the index of the row (0 ≤ index < {@link #getRowsCount()}) * @param input the source array * @return a reference on this object (useful for chaining operations) * @throws IllegalArgumentException if index does not lies within the interval [0, {@link #getRowsCount()}[ or if the length of the array differs from the matrix {@link #getColumnsCount() columns count} * @see #setRow(int, Vector) */ public Matrix setRow(int index, double[] input); /** * Extract a sub-matrix from this one according to the given offsets and counts. * The extracted matrix is a copy of the original. * @param rowOffset the index of first row to extract * @param columnOffset the index of first column to extract * @param rowCount the number of rows to extract from the given offset * @param columnCount the number of columns to extract from the given offset * @return a sub-matrix from this one according to the given offsets and counts */ public Matrix extract(int rowOffset, int columnOffset, int rowCount, int columnCount); /** * Extract a sub-matrix from this one according to the given offsets and counts. * The extracted matrix is a copy of the original. * @param rowOffset the index of first row to extract * @param columnOffset columnOffset the index of first column to extract * @param rowCount the number of rows to extract from the given offset * @param columnCount the number of columns to extract from the given offset * @param result the matrix that store the extraction * @return a reference on result * @throws IllegalArgumentException if the result does not fit */ public Matrix extract(int rowOffset, int columnOffset, int rowCount, int columnCount, Matrix result); /** * Get the number of rows that this matrix contains. * @return the number of rows that this matrix contains. * @see #getColumnsCount() * @see #getDimension() */ public int getRowsCount(); /** * Get the number of columns that this matrix contains. * @return the number of columns that this matrix contains. * @see #getRowsCount() * @see #getDimension() */ public int getColumnsCount(); /** * Get the dimension (the number of rows and columns) of this matrix. * @return the dimension (the number of rows and columns) of this matrix. * @see #getRowsCount() * @see #getColumnsCount() */ public Dimension getDimension(); /** * Compute the matrix determinant. Let A be a general n×m sized matrix such that: * $$ * A = \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * where: *
    *
  • n is the number of rows. *
  • m is the number of columns. *
  • aij is the value located at row i and column j *
* Its determinant, denoted |A| is such that: * $$ * |A|\ =\ \sum_{k=1}^{k}a_{ij}C_{ij} * $$ * where Cij is the cofactor of aij defined by: * $$ * C_{ij}\ =\ (-1)^{i+j}M_{ij} * $$ * with Mij the minor of matrix A formed by eliminating row i and column j from A.

* Many implementation of the determinant can be provided, this description is purely formal. * @return the matrix determinant. */ public double determinant(); /** * Compute the transpose of the current matrix and return it. * Let A be a matrix, the transpose of A, denoted AT * is the matrix that is obtained by exchanging A rows and columns. A matrix and its transpose satisfy:

* (AT)-1 = (A-1)T *

* Note that the transpose of an A, B matrices product is such as: * (A×B)T = AT×BT * @return the transpose of the current matrix. */ public Matrix transpose(); /** * Compute the transpose of the current matrix and store it within the given result. * Let A be a matrix, the transpose of A, denoted AT * is the matrix that is obtained by exchanging A rows and columns. A matrix and its transpose satisfy:

* (AT)-1 = (A-1)T *

* Note that the transpose of an A, B matrices product is such as: * (A×B)T = AT×BT * @param result the matrix that has to store the result of the transpose. * @return the same reference as result * @throws IllegalArgumentException is the given result does not fit the transpose matrix. */ public Matrix transpose(Matrix result) throws IllegalArgumentException; /** * Modify this matrix by its transpose. * Let A be a matrix, the transpose of A, denoted AT * is the matrix that is obtained by exchanging A rows and columns. A matrix and its transpose satisfy:

* (AT)-1 = (A-1)T *

* Note that the transpose of an A, B matrices product is such as: * (A×B)T = AT×BT * @return a reference on this matrix. */ public Matrix transposeAffect(); /** * Multiply the current matrix by the given one (regarding to matrix product). Formally, this methods compute:

* M = A×B

* where: *
    *
  • M is the returned result. *
  • A is this matrix. *
  • B is the matrix given by b. *
* @param b the matrix to multiply. * @return the product of this matrix by the given one. * @throws IllegalArgumentException if the matrix are incompatible for multiplication. */ public Matrix multiply(Matrix b) throws IllegalArgumentException; /** * Multiply the current matrix by the given one (regarding to matrix product). Formally, this methods compute:

* M = A×B

* where: *
    *
  • M is the returned result. *
  • A is this matrix. *
  • B is the matrix given by b. *
* @param b the matrix to multiply. * @param result the matrix that has to store the result of the multiplication. * @return the same reference as result. * @throws IllegalArgumentException if the matrix are incompatible for multiplication. */ public Matrix multiply(Matrix b, Matrix result) throws IllegalArgumentException; /** * Modify this matrix to be the result of the multiplication of this matrix with the given one (regarding to matrix product). * Formally, this methods compute:

* M = A×B

* where: *
    *
  • M is the returned result. *
  • A is this matrix. *
  • B is the matrix given by b. *
* @param b the matrix to multiply. * @return a reference on this matrix. * @throws IllegalArgumentException if the matrix are incompatible for multiplication. */ public Matrix multiplyAffect(Matrix b) throws IllegalArgumentException; /** * Return the {@link Vector vector} resulting of the multiplication of this matrix with the given one. * (regarding to matrix product).

* Formally, this methods compute:

* u = A×v

* where: *
    *
  • u is the returned result. *
  • A is this matrix. *
  • v is the input vector. *
* @param v the vector to multiply. * @return the {@link Vector vector} resulting of the multiplication of this matrix with the given one. */ public Vector multiply(Vector v); /** * Affect the result {@link Vector vector} with the result of the multiplication of this matrix with the given vector v. * (regarding to matrix product)

* Formally, this methods compute:

* u = A×v

* where: *
    *
  • u is the returned result. *
  • A is this matrix. *
  • v is the input vector. *
* @param v the vector to multiply. * @param result the vector that store the result. * @return the same reference as result. */ public Vector multiply(Vector v, Vector result); /** * Return the matrix resulting of the multiplication of this matrix with a scalar. * Formally, let A a matrix such that: * $$ * A = \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The result of the multiplcation of A by a scalar s is the matrix As that verifies: * $$ * A_{s} = \begin{bmatrix} * sa_{00} & \dots & sa_{0i} & \dots & sa_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * sa_{i0} & \dots & sa_{ij} & \dots & sa_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * sa_{n0} & \dots & sa_{nj} & \dots & sa_{nm} * \end{bmatrix} * $$ * @param scalar the scalar to multiply. * @return the matrix resulting of the multiplication of this matrix with a scalar. */ public Matrix multiply(double scalar); /** * Store the result of the multiplication of this matrix with a scalar within the given result. * Formally, let M a matrix such that: * $$ * A = \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The result of the multiplcation of A by a scalar s is the matrix As that verifies: * $$ * A_{s} = \begin{bmatrix} * sa_{00} & \dots & sa_{0i} & \dots & sa_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * sa_{i0} & \dots & sa_{ij} & \dots & sa_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * sa_{n0} & \dots & sa_{nj} & \dots & sa_{nm} * \end{bmatrix} * $$ * @param scalar the scalar to multiply. * @param result the matrix that have to store the result of the multiplication of this matrix with the scalar. * @return the same reference as result * @throws IllegalArgumentException if the result matrix does not fit the multiplication. */ public Matrix multiply(double scalar, Matrix result) throws IllegalArgumentException; /** * Modify this matrix with the result of the multiplication of this matrix with a scalar. * Formally, let A a matrix such that: * $$ * A = \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The result of the multiplcation of A by a scalar s is the matrix As that verifies: * $$ * A_{s} = \begin{bmatrix} * sa_{00} & \dots & sa_{0i} & \dots & sa_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * sa_{i0} & \dots & sa_{ij} & \dots & sa_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * sa_{n0} & \dots & sa_{nj} & \dots & sa_{nm} * \end{bmatrix} * $$ * @param scalar the scalar to multiply. * @return a reference on this matrix. */ public Matrix multiplyAffect(double scalar); /** * Compute and return the addition of this matrix with the given one. * Formally, let A and B two matrices such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * and\ B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0i} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{ij} & \dots & b_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{nj} & \dots & b_{nm} * \end{bmatrix} * $$ * The addition of A and B, denoted A + B is such that: * $$ * A+B\ =\ \begin{bmatrix} * b_{00}+a_{00} & \dots & b_{0i}+a_{0i} & \dots & b_{0m}+a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0}+a_{i0} & \dots & b_{ij}+a_{ij} & \dots & b_{im}+a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0}+a_{n0} & \dots & b_{nj}+a_{nj} & \dots & b_{nm}+a_{nm} * \end{bmatrix} * $$ * @param b the matrix to add. This matrix has to be same sized as this matrix. * @return the addition of this matrix with the given one. If the input matrix is null then null is returned. * @throws IllegalArgumentException if the input matrix size differs from this one. */ public Matrix add(Matrix b) throws IllegalArgumentException; /** * Compute the addition of this matrix with the given one and store it within the result matrix. * Formally, let A and B two matrices such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * and\ B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0i} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{ij} & \dots & b_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{nj} & \dots & b_{nm} * \end{bmatrix} * $$ * The addition of A and B, denoted A + B is such that: * $$ * A+B\ =\ \begin{bmatrix} * b_{00}+a_{00} & \dots & b_{0i}+a_{0i} & \dots & b_{0m}+a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0}+a_{i0} & \dots & b_{ij}+a_{ij} & \dots & b_{im}+a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0}+a_{n0} & \dots & b_{nj}+a_{nj} & \dots & b_{nm}+a_{nm} * \end{bmatrix} * $$ * @param b the matrix to add. This matrix has to be same sized as this matrix. * @param result the matrix that store the result. This matrix has to be same sized as this matrix. * @return the same reference as result. * @throws IllegalArgumentException if the input or result matrices size differs from this one. */ public Matrix add(Matrix b, Matrix result) throws IllegalArgumentException; /** * Affect this matrix with the result of its addition with the given one. * Formally, let A and B two matrices such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * and\ B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0i} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{ij} & \dots & b_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{nj} & \dots & b_{nm} * \end{bmatrix} * $$ * The addition of A and B, denoted A + B is such that: * $$ * A+B\ =\ \begin{bmatrix} * b_{00}+a_{00} & \dots & b_{0i}+a_{0i} & \dots & b_{0m}+a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0}+a_{i0} & \dots & b_{ij}+a_{ij} & \dots & b_{im}+a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0}+a_{n0} & \dots & b_{nj}+a_{nj} & \dots & b_{nm}+a_{nm} * \end{bmatrix} * $$ * @param b the matrix to add. This matrix has to be same sized as this matrix. * @return a reference on this matrix. * @throws IllegalArgumentException if the input matrix size differs from this one. */ public Matrix addAffect(Matrix b) throws IllegalArgumentException; /** * Compute and return the addition of this matrix with the given scalar. * Formally, let s be a scalar and A a matrix such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The addition of A and s, denoted As is such that: * $$ * A_{s}\ =\ \begin{bmatrix} * s+a_{00} & \dots & s+a_{0i} & \dots & s+a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * s+a_{i0} & \dots & s+a_{ij} & \dots & s+a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * s+a_{n0} & \dots & s+a_{nj} & \dots & s+a_{nm} * \end{bmatrix} * $$ * @param s the scalar to add. * @return the addition of this matrix with the given scalar. */ public Matrix add(double s); /** * Compute the addition of this matrix with the given scalar and store it within the given result matrix. * Formally, let s be a scalar and A a matrix such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The addition of A and s, denoted As is such that: * $$ * A_{s}\ =\ \begin{bmatrix} * s+a_{00} & \dots & s+a_{0i} & \dots & s+a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * s+a_{i0} & \dots & s+a_{ij} & \dots & s+a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * s+a_{n0} & \dots & s+a_{nj} & \dots & s+a_{nm} * \end{bmatrix} * $$ * @param s the scalar to add. * @param result the matrix that store the result. This matrix has to be same sized as this matrix. * @return the addition of this matrix with the given scalar. If the result matrix is null then null is returned. * @throws IllegalArgumentException if the result matrix size differs from this one. */ public Matrix add(double s, Matrix result) throws IllegalArgumentException; /** * Affect this matrix with the result of the addition of this matrix with the given scalar. * Formally, let s be a scalar and A a matrix such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The addition of A and s, denoted As is such that: * $$ * A_{s}\ =\ \begin{bmatrix} * s+a_{00} & \dots & s+a_{0i} & \dots & s+a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * s+a_{i0} & \dots & s+a_{ij} & \dots & s+a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * s+a_{n0} & \dots & s+a_{nj} & \dots & s+a_{nm} * \end{bmatrix} * $$ * @param s the scalar to add. * @return a reference on this matrix. */ public Matrix addAffect(double s); /** * Compute and return the subtraction of this matrix with the given one. * Formally, let A and B two matrices such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * and\ B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0i} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{ij} & \dots & b_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{nj} & \dots & b_{nm} * \end{bmatrix} * $$ * The subtraction of A and B, denoted A - B is such that: * $$ * A+B\ =\ \begin{bmatrix} * b_{00}-a_{00} & \dots & b_{0i}-a_{0i} & \dots & b_{0m}-a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0}-a_{i0} & \dots & b_{ij}-a_{ij} & \dots & b_{im}-a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0}-a_{n0} & \dots & b_{nj}-a_{nj} & \dots & b_{nm}-a_{nm} * \end{bmatrix} * $$ * @param b the matrix to subtract. This matrix has to be same sized as this matrix. * @return the subtraction of this matrix with the given one. If the input matrix is null then null is returned. * @throws IllegalArgumentException if the input matrix size differs from this one. */ public Matrix subtract(Matrix b) throws IllegalArgumentException; /** * Compute the subtraction of this matrix with the given one and store it within the result matrix. * Formally, let A and B two matrices such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * and\ B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0i} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{ij} & \dots & b_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{nj} & \dots & b_{nm} * \end{bmatrix} * $$ * The subtraction of A and B, denoted A - B is such that: * $$ * A+B\ =\ \begin{bmatrix} * b_{00}-a_{00} & \dots & b_{0i}-a_{0i} & \dots & b_{0m}-a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0}-a_{i0} & \dots & b_{ij}-a_{ij} & \dots & b_{im}-a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0}-a_{n0} & \dots & b_{nj}-a_{nj} & \dots & b_{nm}-a_{nm} * \end{bmatrix} * $$ * @param b the matrix to subtract. This matrix has to be same sized as this matrix. * @param result the matrix that store the result. This matrix has to be same sized as this matrix. * @return the same reference as result. * @throws IllegalArgumentException if the input or result matrices size differs from this one. */ public Matrix subtract(Matrix b, Matrix result) throws IllegalArgumentException; /** * Affect this matrix with the result of its subtraction with the given one. * Formally, let A and B two matrices such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * and\ B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0i} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{ij} & \dots & b_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{nj} & \dots & b_{nm} * \end{bmatrix} * $$ * The subtraction of A and B, denoted A - B is such that: * $$ * A+B\ =\ \begin{bmatrix} * b_{00}-a_{00} & \dots & b_{0i}-a_{0i} & \dots & b_{0m}-a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0}-a_{i0} & \dots & b_{ij}-a_{ij} & \dots & b_{im}-a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0}-a_{n0} & \dots & b_{nj}-a_{nj} & \dots & b_{nm}-a_{nm} * \end{bmatrix} * $$ * @param b the matrix to subtract. This matrix has to be same sized as this matrix. * @return a reference on this matrix. * @throws IllegalArgumentException if the input matrix size differs from this one. */ public Matrix subtractAffect(Matrix b) throws IllegalArgumentException; /** * Compute and return the subtraction of this matrix with the given scalar. * Formally, let s be a scalar and A a matrix such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The subtraction of A and s, denoted As is such that: * $$ * A_{s}\ =\ \begin{bmatrix} * a_{00}-s & \dots & a_{0i}-s & \dots & a_{0m}-s \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0}-s & \dots & a_{ij}-s & \dots & a_{im}-s \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0}-s & \dots & a_{nj}-s & \dots & a_{nm}-s * \end{bmatrix} * $$ * @param s the scalar to subtract. * @return the subtraction of this matrix with the given scalar. */ public Matrix subtract(double s); /** * Compute the subtraction of this matrix with the given scalar and store it within the given result matrix. * Formally, let s be a scalar and A a matrix such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The subtraction of A and s, denoted As is such that: * $$ * A_{s}\ =\ \begin{bmatrix} * a_{00}-s & \dots & a_{0i}-s & \dots & a_{0m}-s \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0}-s & \dots & a_{ij}-s & \dots & a_{im}-s \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0}-s & \dots & a_{nj}-s & \dots & a_{nm}-s * \end{bmatrix} * $$ * @param s the scalar to subtract. * @param result the matrix that store the result. This matrix has to be same sized as this matrix. * @return the subtraction of this matrix with the given scalar. If the result matrix is null then null is returned. * @throws IllegalArgumentException if the result matrix size differs from this one. */ public Matrix subtract(double s, Matrix result) throws IllegalArgumentException; /** * Affect this matrix with the result of the subtraction of this matrix with the given scalar. * Formally, let s be a scalar and A a matrix such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{im} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nm} * \end{bmatrix} * $$ * The subtraction of A and s, denoted As is such that: * $$ * A_{s}\ =\ \begin{bmatrix} * a_{00}-s & \dots & a_{0i}-s & \dots & a_{0m}-s \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0}-s & \dots & a_{ij}-s & \dots & a_{im}-s \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0}-s & \dots & a_{nj}-s & \dots & a_{nm}-s * \end{bmatrix} * $$ * @param s the scalar to subtract. * @return a reference on this matrix. */ public Matrix subtractAffect(double s); /** * Return the inverse of the current matrix. Let A be a square matrix, its inverse, denoted A-1 is such that:
* A×A-1 = I
* where I is the identity matrix and × is the standard matrix product. * @return the inverse of the current matrix. * @throws IllegalStateException if the matrix is not invertible. */ public Matrix invert() throws IllegalStateException; /** * Compute the inverse of the current matrix and store it within the result matrix. * Let A be a square matrix, its inverse, denoted A-1 is such that:
* A×A-1 = I
* where I is the identity matrix and × is the standard matrix product. * @param result the matrix that has to store the inverse of the current matrix. * @return the same reference as result * @throws IllegalStateException if the result is not same sized as this matrix. * @throws IllegalArgumentException if the matrix is not invertible. */ public Matrix invert(Matrix result) throws IllegalStateException, IllegalArgumentException; /** * Compute the cofactor matrix. Formally, let A a square matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0n} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{in} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nn} * \end{bmatrix} * $$ * The cofactor matrix of A, denoted C, is such that:
* $$ * C\ =\ \begin{bmatrix} * c_{00} & \dots & c_{0i} & \dots & c_{0n} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * c_{i0} & \dots & c_{ij} & \dots & c_{in} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * c_{n0} & \dots & c_{nj} & \dots & c_{nn} * \end{bmatrix} * $$ *
where cij = (-1)(i+j)|M(ij)|
* with Mij is the minor matrix from A obtained by ignoring row i and column j from A *
* @return the cofactor matrix. * @throws IllegalStateException if the matrix is not square. */ public Matrix cofactor() throws IllegalStateException; /** * Compute the cofactor matrix and store it within the given result. Formally, let A a square matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0i} & \dots & a_{0n} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{ij} & \dots & a_{in} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nj} & \dots & a_{nn} * \end{bmatrix} * $$ * The cofactor matrix of A, denoted C, is such that:
* $$ * C\ =\ \begin{bmatrix} * c_{00} & \dots & c_{0i} & \dots & c_{0n} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * c_{i0} & \dots & c_{ij} & \dots & c_{in} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * c_{n0} & \dots & c_{nj} & \dots & c_{nn} * \end{bmatrix} * $$ *
where cij = (-1)(i+j)|M(ij)|
* with Mij is the minor matrix from A obtained by ignoring row i and column j from A *
* @param result the matrix that have to store the result. * @return the same reference as result * @throws IllegalStateException if the matrix is not square. * @throws IllegalArgumentException if the result has not the same size as this matrix. */ public Matrix cofactor(Matrix result) throws IllegalStateException, IllegalArgumentException; /** * Construct a new matrix that is made of the horizontal concatenation of the given matrix to this one. * Formally, let A a n×j matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} * \end{bmatrix} * $$ * and let B a n×k matrix defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0s} & \dots & b_{0k} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{is} & \dots & b_{ik} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{ns} & \dots & b_{nk} * \end{bmatrix} * $$ * The horizontal concatenation Ch of A and B is a n×j+k matrix defined such that: * $$ * C_{h}\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} & b_{00} & \dots & b_{0s} & \dots & b_{0k} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} & b_{i0} & \dots & b_{is} & \dots & b_{ik} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} & b_{n0} & \dots & b_{ns} & \dots & b_{nk} * \end{bmatrix} * $$ * @param right the matrix to concatenate on the right * @return the concatenated matrix * @throws IllegalArgumentException if the number of lines from the input matrix is not compatible with the number of lines of this matrix */ public Matrix concatHorizontal(Matrix right); /** * Construct a new matrix that is made of the horizontal concatenation of the given matrix to this one. * Formally, let A a n×j matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} * \end{bmatrix} * $$ * and let B a n×k matrix defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0s} & \dots & b_{0k} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{i0} & \dots & b_{is} & \dots & b_{ik} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{n0} & \dots & b_{ns} & \dots & b_{nk} * \end{bmatrix} * $$ * The horizontal concatenation Ch of A and B is a n×j+k matrix defined such that: * $$ * C_{h}\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} & b_{00} & \dots & b_{0s} & \dots & b_{0k} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} & b_{i0} & \dots & b_{is} & \dots & b_{ik} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} & b_{n0} & \dots & b_{ns} & \dots & b_{nk} * \end{bmatrix} * $$ * @param right the matrix to concatenate on the right * @param result the matrix that has to store the result (has to be well fitted) * @return the concatenated matrix (a reference on result) * @throws IllegalArgumentException if the number of lines from the input matrix is not compatible with the number of lines of this matrix or if the result matrix size is not compatible */ public Matrix concatHorizontal(Matrix right, Matrix result); /** * Construct a new matrix that is made of the horizontal concatenation of the given {@link Vector} to this one. * Formally, let A a n×j matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} * \end{bmatrix} * $$ * and let B a vector of dimension n defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{0} \\ * \vdots \\ * b_{i} \\ * \vdots \\ * b_{n} * \end{bmatrix} * $$ * The horizontal concatenation Ch of A and B is a n×j+k matrix defined such that: * $$ * C_{h}\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} & b_{0} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} & b_{i} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} & b_{n} * \end{bmatrix} * $$ * @param right the vector to concatenate on the right * @return the concatenated matrix * @throws IllegalArgumentException if the dimension of the input vector is not compatible with the number of lines of this matrix */ public Matrix concatHorizontal(Vector right); /** * Construct a new matrix that is made of the horizontal concatenation of the given {@link Vector} to this one. * Formally, let A a n×j matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} * \end{bmatrix} * $$ * and let B a vector of dimension n defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{0} \\ * \vdots \\ * b_{i} \\ * \vdots \\ * b_{n} * \end{bmatrix} * $$ * The horizontal concatenation Ch of A and B is a n×j+k matrix defined such that: * $$ * C_{h}\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0j} & b_{0} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\ * a_{i0} & \dots & a_{il} & \dots & a_{ij} & b_{i} \\ * \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\ * a_{n0} & \dots & a_{nl} & \dots & a_{nj} & b_{n} * \end{bmatrix} * $$ * @param right the vector to concatenate on the right * @param result the matrix that has to store the result (has to be well fitted) * @return the concatenated matrix * @throws IllegalArgumentException if the dimension of the input vector is not compatible with the number of lines of this matrix or if the result matrix is invalid */ public Matrix concatHorizontal(Vector right, Matrix result); /** * Construct a new matrix that is made of the vertical concatenation of the given matrix to this one. * Formally, let A a j×m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} * \end{bmatrix} * $$ * and let B a k×m matrix defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0v} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{u0} & \dots & b_{uv} & \dots & b_{um} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{k0} & \dots & b_{kv} & \dots & b_{km} * \end{bmatrix} * $$ * The vertical concatenation Cv of A and B is a j+k × m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} \\ * b_{00} & \dots & b_{0v} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{u0} & \dots & b_{uv} & \dots & b_{um} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{k0} & \dots & b_{kv} & \dots & b_{km} * \end{bmatrix} * $$ * @param bottom the matrix to concatenate on the bottom of this one * @return the concatenated matrix (a reference on result) * @throws IllegalArgumentException if the number of columns from the input matrix is not compatible with the number of columns of this matrix or if the result matrix size is not compatible */ public Matrix concatVertical(Matrix bottom); /** * Construct a new matrix that is made of the vertical concatenation of the given matrix to this one. * Formally, let A a j×m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} * \end{bmatrix} * $$ * and let B a k×m matrix defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{00} & \dots & b_{0v} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{u0} & \dots & b_{uv} & \dots & b_{um} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{k0} & \dots & b_{kv} & \dots & b_{km} * \end{bmatrix} * $$ * The vertical concatenation Cv of A and B is a j+k × m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} \\ * b_{00} & \dots & b_{0v} & \dots & b_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{u0} & \dots & b_{uv} & \dots & b_{um} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * b_{k0} & \dots & b_{kv} & \dots & b_{km} * \end{bmatrix} * $$ * @param bottom the matrix to concatenate on the bottom of this one * @param result the matrix that has to store the result (has to be well fitted) * @return the concatenated matrix (a reference on result) * @throws IllegalArgumentException if the number of columns from the input matrix is not compatible with the number of columns of this matrix or if the result matrix size is not compatible */ public Matrix concatVertical(Matrix bottom, Matrix result); /** * Construct a new matrix that is made of the vertical concatenation of the given {@link Vector} to this one. * Formally, let A a j×m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} * \end{bmatrix} * $$ * and let B a vector of dimension m defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{0} & \dots & b_{v} & \dots & b_{m} * \end{bmatrix} * $$ * The vertical concatenation Cv of A and B is a j+k × m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} \\ * b_{0} & \dots & b_{v} & \dots & b_{m} \\ * \end{bmatrix} * $$ * @param bottom the vector to concatenate on the bottom of this one * @return the concatenated matrix (a reference on result) * @throws IllegalArgumentException if the input vector dimension is not compatible with the number of columns of this matrix */ public Matrix concatVertical(Vector bottom); /** * Construct a new matrix that is made of the vertical concatenation of the given {@link Vector} to this one. * Formally, let A a j×m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} * \end{bmatrix} * $$ * and let B a vector of dimension m defined such that: * $$ * B\ =\ \begin{bmatrix} * b_{0} & \dots & b_{v} & \dots & b_{m} * \end{bmatrix} * $$ * The vertical concatenation Cv of A and B is a j+k × m matrix defined such that: * $$ * A\ =\ \begin{bmatrix} * a_{00} & \dots & a_{0l} & \dots & a_{0m} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{t0} & \dots & a_{tl} & \dots & a_{tm} \\ * \vdots & \ddots & \vdots & \ddots & \vdots \\ * a_{j0} & \dots & a_{jl} & \dots & a_{jm} \\ * b_{0} & \dots & b_{v} & \dots & b_{m} \\ * \end{bmatrix} * $$ * @param bottom the vector to concatenate on the bottom of this one * @param result the matrix that has to store the result (has to be well fitted) * @return the concatenated matrix (a reference on result) * @throws IllegalArgumentException if the input vector dimension is not compatible with the number of columns of this matrix or if the result matrix is not well fitted */ public Matrix concatVertical(Vector bottom, Matrix result); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy