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(matrix): Introduce methods for swapping specified rows and columns #108

Merged
merged 5 commits into from
May 30, 2024

Conversation

mitsuki31
Copy link
Owner

Overview

This pull request introduces several enhancements and improvements to the Matrix class, focusing on documentation updates, refactoring, and the addition of methods for swapping specified rows and columns within the matrix.

Notable Changes

  • Feature Addition: Two sets of methods have been introduced to facilitate the swapping of specified rows and columns within the matrix. These methods optimize performance by either directly swapping column elements relying on arithmetic operations or utilizing System.arraycopy for row swaps.

  • Documentation Enhancement: Detailed descriptions have been added to clarify the matrix definition in the Matrix class documentation. Additionally, the class version has been updated.

  • Refactoring: New taglets, namely apiNote and implNote, have been incorporated. Furthermore, adjustments have been made to the configuration of the maven-compiler-plugin dependency to resolve compatibility issues with version 3.13.0.

Description

Features Addition

  • Two sets of methods have been introduced to empower users with the ability to swap specified rows and columns within the matrix seamlessly.
  • For column swapping, a method has been implemented that directly manipulates column elements, eliminating the need for temporary variables and enhancing efficiency through arithmetic operations.
  • Alternatively, for row swapping, methods leveraging System.arraycopy have been introduced. This approach not only improves performance but also facilitates negative indexing for specifying rows, allowing for greater flexibility in matrix manipulation.

Documentation Enhancement

  • The Matrix class documentation now provides a more comprehensive explanation of the matrix definition, aiding developers in better understanding its functionalities and usage.
  • Version details have been updated to reflect the changes made, ensuring clarity for users regarding the current state of the class.

Refactoring

  • New taglets (apiNote and implNote) have been integrated into the codebase, enriching the documentation with additional context and implementation notes.
  • In response to compatibility issues with the maven-compiler-plugin version 3.13.0, <compilerVersion> has been removed from the plugin configuration, ensuring smooth integration with the latest dependency version.

Summary

This pull request enhances the Matrix class by focusing on refactoring code for better maintainability, and introducing efficient methods for swapping specified rows and columns within the matrix. These changes aim to streamline development processes, optimize performance, and enrich the overall user experience when working with matrices in the application.

Introduced new methods to swap specified rows in the matrix. It utilizes the `System.arraycopy` method to perform the row swaps, which offers better performance and speed. Additionally, it allows negative indexing for specifying the first row and the second row (i.e., counting from the end of the rows).
Introduced new methods to swap specified rows in the matrix. It swaps the columns' elements directly without using a temporary variable, relying on arithmetic operations to perform the swap.
New taglets that has been added:
  - apiNote (ptcmf)
  - implNote (ptcmf)

Additionally, removed the `<compilerVersion>` in the configuration of maven-compiler-plugin due to incompatible with the maven-compiler-plugin version 3.13.0.
Added more description about matrix definition in the `Matrix` class docs. And also update its version.
@mitsuki31 mitsuki31 added lang:java Some changes on Java code minor Minor update feature Add new features to improve the project labels May 30, 2024
@mitsuki31 mitsuki31 self-assigned this May 30, 2024
@github-actions github-actions bot added the enhancement Enhancing existing features label May 30, 2024
Copy link
Owner Author

@mitsuki31 mitsuki31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bad logic inside the body insertRow method on row index checker.

} else if (row < 0 || row > mRows) { // Check for the index is out of bounds
JMatrixUtils.raiseError(new InvalidIndexException(
String.format("Given row index is out of range: %d",
(row < 0) ? (row - mRows - 1) : row
)
));

It should be like this:

-    } else if (row < 0 || row > mRows) {  // Check for the index is out of bounds
+    } else if (row < 0 || row >= mRows) {  // Check for the index is out of bounds

Where the given row must be lower than (and not equals) to mRows (the total rows of the matrix).

@mitsuki31 mitsuki31 merged commit f3e0aaa into master May 30, 2024
34 checks passed
@mitsuki31 mitsuki31 deleted the feature/add-elements-swapper branch May 30, 2024 12:49
@mitsuki31 mitsuki31 added this to the v1.5.0 milestone May 30, 2024
@mitsuki31
Copy link
Owner Author

There's a bad logic inside the body insertRow method on row index checker.

} else if (row < 0 || row > mRows) { // Check for the index is out of bounds
JMatrixUtils.raiseError(new InvalidIndexException(
String.format("Given row index is out of range: %d",
(row < 0) ? (row - mRows - 1) : row
)
));

It should be like this:

-    } else if (row < 0 || row > mRows) {  // Check for the index is out of bounds
+    } else if (row < 0 || row >= mRows) {  // Check for the index is out of bounds

Where the given row must be lower than (and not equals) to mRows (the total rows of the matrix).

This issue was moved to #110.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancing existing features 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.

1 participant