Advertisement
AlexandrP

Matrix.java

Apr 4th, 2024
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.92 KB | None | 0 0
  1. package com.epam.rd.qa.basicio;
  2.  
  3. /**
  4.  * Encapsulates two-dimensional array-matrix block of real ({@code double}) type.
  5.  * {@code Matrix} is the cover for two-dimensional array of real values, storing matrix
  6.  * values with operations of matrix addition, deduction, and multiplication.
  7.  */
  8. public class Matrix {
  9.  
  10.     /**
  11.      * Creates an empty matrix with predetermined number
  12.      * of rows and columns (all values in matrix equal to 0)
  13.      *
  14.      * @param rows number of rows
  15.      * @param cols number of columns
  16.      * @throws MatrixException if {@code rows} or {@code cols} less than 1
  17.      */
  18.     public Matrix(int rows, int cols) throws MatrixException {
  19.         throw new UnsupportedOperationException();
  20.     }
  21.  
  22.     /**
  23.      * Creates a matrix based on existing two-dimensional array
  24.      *
  25.      * @param values two-dimensional array
  26.      * @throws MatrixException if {@code rows} or {@code cols} less than 1
  27.      */
  28.     public Matrix(double[][] values) throws MatrixException {
  29.         throw new UnsupportedOperationException();
  30.     }
  31.  
  32.     /**
  33.      * Returns count of matrix rows.
  34.      *
  35.      * @return count of rows in the matrix
  36.      */
  37.     public int getRows() {
  38.         throw new UnsupportedOperationException();
  39.     }
  40.  
  41.     /**
  42.      * Returns count of matrix columns
  43.      *
  44.      * @return count of columns in the matrix
  45.      */
  46.     public int getColumns() {
  47.         throw new UnsupportedOperationException();
  48.     }
  49.  
  50.     /**
  51.      * Returns an element via predetermined correct indexes.
  52.      *
  53.      * @param row row index
  54.      * @param col column index
  55.      * @return the element via indexes
  56.      * @throws MatrixException if index out of bounds
  57.      */
  58.     public double get(int row, int col) throws MatrixException {
  59.         throw new UnsupportedOperationException();
  60.     }
  61.  
  62.     /**
  63.      * Sets new value via predetermined correct indexes.
  64.      *
  65.      * @param row   row index
  66.      * @param col   column index
  67.      * @param value value to set
  68.      * @throws MatrixException if index out of bounds
  69.      */
  70.     public void set(int row, int col, double value) throws MatrixException {
  71.         throw new UnsupportedOperationException();
  72.     }
  73.  
  74.     /**
  75.      * Returns standard two-dimensional array out of matrix.
  76.      * Any changes in the returned array will be reflected to internal array.
  77.      *
  78.      * @return matrix values
  79.      */
  80.     public double[][] toArray() {
  81.         throw new UnsupportedOperationException();
  82.     }
  83.  
  84.     /**
  85.      * Adds all elements of {@code other} matrix to corresponding elements
  86.      * of this matrix and creates new {@code Matrix} with resulting two-dimensional array
  87.      *
  88.      * @param other another {@code Matrix} object
  89.      * @return new matrix
  90.      * @throws MatrixException if matrices have different size
  91.      */
  92.     public Matrix add(Matrix other) throws MatrixException {
  93.         throw new UnsupportedOperationException();
  94.     }
  95.  
  96.     /**
  97.      * Subtract all elements of {@code other} matrix from corresponding elements
  98.      * of this matrix and creates new {@code Matrix} with resulting two-dimensional array
  99.      *
  100.      * @param other another {@code Matrix} object
  101.      * @return new matrix
  102.      * @throws MatrixException if matrices have different size
  103.      */
  104.     public Matrix subtract(Matrix other) throws MatrixException {
  105.         throw new UnsupportedOperationException();
  106.     }
  107.  
  108.     /**
  109.      * Multiply this matrix to {@code other} matrix.<br/>
  110.      * See
  111.      * <a href="https://en.wikipedia.org/wiki/Matrix_multiplication">Matrix multiplication</a>
  112.      * <a href="https://en.wikipedia.org/wiki/Matrix_multiplication_algorithm">Matrix multiplication algorithm</a>
  113.      *
  114.      * @param other another matrix
  115.      * @return new matrix
  116.      * @throws MatrixException if matrices have non-compliant sizes
  117.      */
  118.     public Matrix multiply(Matrix other) throws MatrixException {
  119.         throw new UnsupportedOperationException();
  120.     }
  121. }
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement