Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for determinant calculation #131

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

mitsuki31
Copy link
Owner

Overview

This pull request includes several feature updates and documentation improvements to enhance the functionality and usability of the JMatrix library, especially focusing on adding support for determinant calculation.

Key Changes

Determinant Calculation Methods

  • Added a new class called MatrixDeterminant to calculate the determinant of a matrix with two algorithms: Laplace expansion and Gaussian elimination. This addition enables efficient calculation of determinants for matrices of varying sizes.
  • Added three new determinant calculation methods to the matrix class:
    • determinant()
      public double determinant();
      Calculates the determinant of the matrix instance.
    • determinant(Matrix)
      public static double determinant(Matrix m);
      Calculates the determinant of a given matrix.
    • determinant(double[][])
      public static double determinant(double[][] a);
      Calculates the determinant of a matrix represented as a two-dimensional (2D) array.

Note

Those method will automatically chooses the best algorithm for calculating the determinant based on the size of the matrix that are given. The cofactor expansion or laplace expansion algorithm will be used if the matrix size is smaller than or equal to $4\times4$; otherwise, the Gauss elimination algorithm will be used for larger matrix.

Documentation Updates

  • Added a version class to matrix checker classes where missing from previous changes (feat: Enhance matrix validation and exception handling #129).
  • Added detailed Javadoc with usage, exceptions, and algorithm notes for the new determinant calculation methods, providing clear guidance for users.
  • Improved comment region markers for constructors and special methods, enhancing code readability and maintainability.

Impact

  • The new determinant calculation methods will enable users to efficiently calculate determinants for matrices of varying sizes, making it easier to perform tasks such as matrix inversion, solving systems of linear equations, and more.
  • The new determinant calculation methods are designed to be efficient and scalable, minimizing performance impacts on large matrices.
  • The detailed Javadoc and improved comment region markers will provide clear guidance for users, making it easier for them to understand and use the library's features.

This feature adds a new class to calculate the determinant of a matrix with two algorithms. There are two main methods, one is using cofactor expansion and the other is using the Gaussian elimination algorithm.
This change was to add the version class to the matrix checker classes where missing from previous changes (#129).
* Added `determinant()` method to calculate the determinant of the matrix instance.
  - Utilizes cofactor expansion for matrices smaller than 4x4 and Gaussian elimination for larger ones.
  - Added detailed Javadoc with usage, exceptions, and algorithm notes.
* Added static `determinant(Matrix m)` method for calculating the determinant of a given matrix.
  - Chooses the optimal algorithm for determinant calculation based on matrix size.
  - Added detailed Javadoc with usage, exceptions, and algorithm notes.
* Added static `determinant(double[][] a)` method for calculating the determinant of a matrix represented as a 2D array.
  - Chooses the optimal algorithm for determinant calculation based on matrix size.
  - Added detailed Javadoc with usage, exceptions, and algorithm notes.
* Added comment region markers for constructors, special constructors, matrix operations, type checkers, utility methods, and overridden methods.
* Updated Javadoc for methods and added `@since` tags to indicate the introduction of these features in version 1.5.0.

Note: Those determinant calculation methods utilizes the `MatrixDeterminant` interface.
@mitsuki31 mitsuki31 self-assigned this Sep 13, 2024
@github-actions github-actions bot added feature Add new features to improve the project lang:java Some changes on Java code labels Sep 13, 2024
@mitsuki31 mitsuki31 added this to the v1.5.0 milestone Sep 13, 2024
@mitsuki31 mitsuki31 added the minor Minor update label Sep 13, 2024
@mitsuki31 mitsuki31 linked an issue Sep 13, 2024 that may be closed by this pull request
4 tasks
@mitsuki31 mitsuki31 merged commit f80d147 into master Sep 13, 2024
34 checks passed
@mitsuki31 mitsuki31 deleted the feature/add-determinant-operation branch September 13, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Add new features to improve the project lang:java Some changes on Java code minor Minor update
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Enhancing JMatrix with additional methods
1 participant