mitsuki31 / jmatrix

A lightweight Java library for basic introduction to matrix and linear algebra concepts.
https://mitsuki31.github.io/jmatrix/
Apache License 2.0
1 stars 0 forks source link

Matrix type checkers additions 🔎 #62

Closed mitsuki31 closed 1 year ago

mitsuki31 commented 1 year ago

What's Changed

All Commits - 89e1fed - Add new matrix type checker - 13dd86c - Overload the `isLowerTriangular` method - ccca585 - Add javadoc to `isLowerTriangular` method - 0557b9b - Add new matrix type checker - ad09dd5 - Add javadoc to `isUpperTriangular` methods - ef282af - Update the javadocs on recently added methods - 6078663 - Update the javadoc and fix the javadoc error

Description

Triangular Matrices in linear algebra are a specific type of square matrix where all the elements either above or below the main diagonal are zeros. The main diagonal of a square matrix consists of elements that run from the top-left to the bottom-right of the matrix. In triangular matrices, the elements above the main diagonal (upper triangular) or below the main diagonal (lower triangular) are all zeros. A diagonal matrix is one that consists of upper and lower a triangular elements. You can use the Matrix.isDiagonal(Matrix) method to check whether the matrix is diagonal.

\begin{matrix}
  \mathbf{Square \; Diagonal \; Matrix} \\
  \begin{bmatrix}
    1 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 \\
    0 & 0 & 1 & 0 \\
    0 & 0 & 0 & 1
  \end{bmatrix}
\end{matrix}

Upper Triangular Matrix

An upper triangular matrix is a square matrix where all elements below the main diagonal are zeros. The elements above or on the main diagonal may be non-zero. Visually, an upper triangular matrix will have a shape that looks like:

\begin{matrix}
  % :: Title
  \mathbf{Upper \; Triangular \; Matrix} \\

  % :: Type A
  \begin{bmatrix}
    \alpha & \alpha & \alpha & \alpha \\
    0 & \alpha & \alpha & \alpha \\
    0 & 0 & \alpha & \alpha \\
    0 & 0 & 0 & \alpha
  \end{bmatrix}

  \hspace{8.5pt} \iff \hspace{8.5pt}

  % :: Type B
  \begin{bmatrix}
    \alpha & \alpha & \alpha & \alpha \\
    & \alpha & \alpha & \alpha \\
    & & \alpha & \alpha \\
    0 & & & \alpha
  \end{bmatrix}
\end{matrix}

Lower Triangular Matrix

A lower triangular matrix is a square matrix where all the elements above the main diagonal are zeros. The elements below or on the main diagonal may be non-zero. Visually, a lower triangular matrix will have a shape that looks like:

\begin{matrix}
  % :: Title
  \mathbf{Lower \; Triangular \; Matrix} \\

  % :: Type A
  \begin{bmatrix}
    \alpha & 0 & 0 & 0 \\
    \alpha & \alpha & 0 & 0 \\
    \alpha & \alpha & \alpha & 0 \\
    \alpha & \alpha & \alpha & \alpha
  \end{bmatrix}

  \hspace{8.5pt} \iff \hspace{8.5pt}

  % :: Type B
  \begin{bmatrix}
    \alpha & & & 0 \\
    \alpha & \alpha & & \\
    \alpha & \alpha & \alpha & \\
    \alpha & \alpha & \alpha & \alpha
  \end{bmatrix}
\end{matrix}

JMatrix now includes the isLowerTriangular and isUpperTriangular methods to check whether the given square matrix is lower triangular or upper triangular, respectively. These methods can be useful in identifying specific matrix properties and performing various matrix-related calculations.

Summary

In this set of changes, the JMatrix library has been enhanced with the addition of isLowerTriangular and isUpperTriangular methods to check for lower triangular and upper triangular matrices, respectively. Javadocs have also been included for all the newly added methods, ensuring comprehensive documentation and improving code clarity. These changes contribute to the versatility and usability of JMatrix by providing additional matrix type checkers and descriptive documentation for users.