{"id":21126159,"url":"https://github.com/mitsuki31/jmatrix","last_synced_at":"2025-12-29T08:11:17.256Z","repository":{"id":151597001,"uuid":"616012845","full_name":"mitsuki31/jmatrix","owner":"mitsuki31","description":"A lightweight Java library for basic introduction to matrix and linear algebra concepts.","archived":false,"fork":false,"pushed_at":"2024-09-16T15:05:46.000Z","size":1401,"stargazers_count":1,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T05:41:53.821Z","etag":null,"topics":["education","java","library","linear-algebra","matrix"],"latest_commit_sha":null,"homepage":"https://mitsuki31.github.io/jmatrix/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitsuki31.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-19T11:13:55.000Z","updated_at":"2024-09-16T15:02:51.000Z","dependencies_parsed_at":"2023-12-22T08:32:21.375Z","dependency_job_id":"386cf3e0-e4f6-40cc-8ade-dc1b83568e17","html_url":"https://github.com/mitsuki31/jmatrix","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuki31%2Fjmatrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuki31%2Fjmatrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuki31%2Fjmatrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuki31%2Fjmatrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitsuki31","download_url":"https://codeload.github.com/mitsuki31/jmatrix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243573168,"owners_count":20312879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["education","java","library","linear-algebra","matrix"],"created_at":"2024-11-20T04:39:33.762Z","updated_at":"2025-12-29T08:11:17.200Z","avatar_url":"https://github.com/mitsuki31.png","language":"Java","readme":"# JMatrix\n\n\u003c!-- Badges --\u003e\n\u003cdiv id=\"workflows\" align=\"center\"\u003e\n    \u003ca href=\"https://github.com/mitsuki31/jmatrix/actions/workflows/codeql.yml\"\u003e\n        \u003cimg src=\"https://github.com/mitsuki31/jmatrix/actions/workflows/codeql.yml/badge.svg?branch=master\"\n             alt=\"codeql\"\n        /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/mitsuki31/jmatrix/actions/workflows/release-drafter.yml\"\u003e\n        \u003cimg src=\"https://github.com/mitsuki31/jmatrix/actions/workflows/release-drafter.yml/badge.svg?branch=master\"\n             alt=\"release-drafter\"\n        /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003cdiv id=\"other-badges\" align=\"center\"\u003e\n    \u003ca href=\"https://github.com/mitsuki31/jmatrix/blob/master/.github/dependabot.yml\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label=Dependabot\u0026message=active\u0026color=31c753\u0026logo=dependabot\u0026logoColor=white\u0026labelColor=0366d6\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/mitsuki31/jmatrix/blob/master/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/mitsuki31/jmatrix.svg?label=License\u0026color=f9f9f9\u0026labelColor=yellow\u0026logo=github\" /\u003e\n    \u003c/a\u003e\n    \u003ca\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label=Java\u0026message=11\u0026labelColor=orange\u0026color=f9f9f9\u0026logo=openjdk\" /\u003e\n    \u003c/a\u003e\n    \u003ca\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label=Python\u0026message=3.7\u0026labelColor=383838\u0026color=f9f9f9\u0026logo=python\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003c!-- [END] Badges --\u003e\n\n\n**Developed by one person ([Ryuu Mitsuki][mitsuki31])** :fire:  \n\n\u003c!-- TABLE OF CONTENTS::START --\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\n  \u003ch4\u003e\u003ca name=\"table-of-contents\" /\u003eTable of Contents\u003c/h4\u003e\n\u003c/summary\u003e\n\n- [🪐 About JMatrix](#about-jmatrix)\n- [🔌 Installation](#installation)\n    * [🎯 Prerequisites](#prerequisites)\n      + [For Normal Use](#normal-use)\n      + [For Building the Project](#build-use)\n- [Constructor Summary](#constructor-summary)\n    * [`Matrix()`](#cr_matrix-1)\n    * [`Matrix(int, int)`](#cr_matrix-2)\n    * [`Matrix(int, int, int)`](#cr_matrix-3)\n    * [`Matrix(double[][])`](#cr_matrix-4)\n    * [`Matrix.identity(int)`](#cr_matrix-5)\n- [Matrix Operations](#matrix-ops)\n    * [Addition](#matrix-add)\n    * [Subtraction](#matrix-sub)\n    * [Scalar Multiplication](#scalar-mult)\n    * [Matrix Multiplication](#matrix-mult)\n    * [Transposition](#matrix-transpose)\n- [Author](#author)\n- [Contributing](#contributing)\n- [License](#license)\n\u003c/details\u003e\n\n\u003c!-- TABLE OF CONTENTS::END --\u003e\n\n## \u003ca name=\"about-jmatrix\" /\u003e 🪐 About JMatrix\n\n**JMatrix** is a lightweight [Java][java-wiki] library that provides essential matrix operations like addition, subtraction, multiplication, and determinant calculation. Designed with simplicity in mind, it is perfect for educational purposes and small-scale projects involving [linear algebra][linear-algebra-wiki]. The library also supports custom matrix sizes and efficient handling of matrix operations for both square and rectangular matrices.\n\n\u003e [!IMPORTANT]  \n\u003e This project was intended for educational purposes only. It is not recommended for use in large-scale projects.\n\n**JMatrix** provides following basic matrix operations:\n\n- [Addition][matrix-add]\n- [Subtraction][matrix-sub]\n- [Multiplication][matrix-mult]\n- [Transposition][matrix-transpose]\n- [Trace](https://en.wikipedia.org/wiki/Trace_(linear_algebra))\n- [Determinant](https://en.wikipedia.org/wiki/Determinant)\n\nIn addition to the fundamental matrix operations, **JMatrix** also includes matrix type checkers, allowing users to identify certain characteristics of matrices:\n\n- `isDiagonal`          - Check whether the matrix is [diagonal]( https://en.wikipedia.org/wiki/Diagonal_matrix).\n- `isSquare`            - Check whether the matrix is [square](https://en.wikipedia.org/wiki/Square_matrix).\n- `isLowerTriangular`   - Check whether the matrix is [lower triangular](https://en.wikipedia.org/wiki/Triangular_matrix).\n- `isUpperTriangular`   - Check whether the matrix is [upper triangular](https://en.wikipedia.org/wiki/Triangular_matrix).\n- `isPermutationMatrix` - Check whether the matrix is [permutation matrix](https://en.wikipedia.org/wiki/Permutation_matrix).\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eWhat is Matrix?\u003c/b\u003e\u003c/summary\u003e\n\n\u003e Matrices are rectangular arrays of numbers or symbols, arranged in [rows][matrix-row] and [columns][matrix-col].  \n\u003e They are widely used in various fields, including mathematics, physics, computer science, and engineering.  \n\u003e Matrices provide a concise and organized way to represent and manipulate data.  \n\u003e\n\u003e Refer to [:books: JMatrix Wiki][what-is-matrix], if want to know about matrix with simplified informations.\n\u003c/details\u003e\n\n---\n\n## \u003ca name=\"installation\" /\u003e 🔌 Installation\n\nIf you are interested in obtaining the latest stable version of the project, please check the [latest version][latest-ver]. You can download the archived package containing compiled classes from there.\n\nFor improved stability and better usability, we highly recommend downloading the archived package that also includes the source files (`jmatrix-\u003cVERSION\u003e_with_sources.jar`).\nThis package contains all the necessary documentation about classes, methods, and other aspects related to **JMatrix**, making it easier to explore and understand the library APIs.\n\n\u003e [!WARNING]  \n\u003e Currently, there is an issue with pre-build processes when using **Make** on Windows systems. The issue was that it failed while trying to create child processes to configure the build requirements.\n\u003e \n\u003e For better functionality, we recommend using [**Maven**][maven] instead. Because using **Make** is an alternative way for flexibility on UNIX systems.\n\n### \u003ca name=\"prerequisites\" /\u003e 🎯 Prerequisites\n\n#### \u003ca name=\"normal-use\" /\u003e For Normal Use\n\nTo use **JMatrix** in your project, you will need the following prerequisites:\n\n- [**Java**][java] *(min. JDK 11, recommended is JDK 17 and later)*\n- [**Git Bash**][git-bash] *(optional, Windows only)*\n\n#### \u003ca name=\"build-use\" /\u003e For Building the Project\n\nIf you plan to build the **JMatrix** project, please ensure you have the following prerequisites:\n\n- [**Java**][java] *(min. JDK 11, recommended is JDK 17 and later)*.\n- [**Python**][python] *(min. version 3.7, recommended is 3.11 and later)*.\n- Latest version of [**Make**][mingw] or [**Maven**][maven].\n\n\u003e [!IMPORTANT]  \n\u003e If you choose to build the project using [Maven][maven], you don't need [Python][python].\n\u003e \n\u003e Sadly, we're having a problem with pre-build processes on Windows systems. It is recommended to use [Maven][maven] instead if you're using Windows to build the project, ensuring better functionality.\n\nFor more detailed instructions on building the project, you can refer to the [:bookmark:Getting Started][get-started] page.\n\nOnce you have the necessary prerequisites, you can start exploring and using **JMatrix** in your projects. The documentation included in the archived package will guide you through the classes, methods, and functionalities offered by the library.\n\n---\n\n## \u003ca name=\"constructor-summary\" /\u003e Constructor Summary\n\nThere are five constructors available for constructing matrices in the **JMatrix** library. Each constructor serves a specific purpose, providing users with flexibility and ease of use.\n\n\u003e [!NOTE]  \n\u003e If you are unfamiliar with matrices or need a refresher, you can check the [:bookmark:Introduction to Matrix][what-is-matrix] page to gain a basic understanding before delving into matrix constructors.\n\n### \u003ca name=\"cr_matrix-1\" /\u003e `Matrix()`\n\n```java\npublic Matrix();\n```\n\nThis constructor does not require any arguments and constructs a Matrix with null entries, resulting in a null matrix. A null matrix cannot perform any operations until it is initialized with valid elements. For example:\n\n```java\n// Create a null entries matrix\nMatrix m = new Matrix();\n```\n\n\u003e [!NOTE]  \n\u003e Do not confuse the **null matrix** with the **zero matrix**.\n\u003e A **null matrix** has null entries, whereas the **zero matrix** contains all elements as zeros.\n\n\u003e \u003cdetails\u003e\u003csummary\u003e\u003cb\u003eExamples\u003c/b\u003e\u003c/summary\u003e\n\u003e\n\u003e #### Zero Matrix\n\u003e\n\u003e ```math\n\u003e \\begin{bmatrix}\n\u003e   0.0 \u0026 0.0 \u0026 0.0 \\\\\n\u003e   0.0 \u0026 0.0 \u0026 0.0\n\u003e \\end{bmatrix}_{2 \\times 3}\n\u003e ```\n\u003e\n\u003e #### Null Matrix\n\u003e\n\u003e ```console\n\u003e null\n\u003e ```\n\u003e\n\u003e Yes, that is a **null matrix**. It has none or null entries inside the matrix. The output above is the result of this code below:\n\u003e\n\u003e ```java\n\u003e Matrix nullM = new Matrix();\n\u003e System.out.println(\n\u003e     (nullM.getEntries() == null) ? nullM.getEntries() : nullM.toString());\n\u003e ```\n\u003e\n\u003e Also if you use either the `display()` or `prettyDisplay()` method from null matrix, this output will be printed.\n\u003e\n\u003e ```console\n\u003e \u003cnull_matrix\u003e\n\u003e ```\n\u003e\n\u003e \u003c/details\u003e \n\n\n### \u003ca name=\"cr_matrix-2\" /\u003e `Matrix(int, int)`\n\n```java\npublic Matrix(int rows, int cols);\n```\n\nWith this constructor, you can create a **zero matrix** with ease by providing two arguments: the number of [rows][matrix-row] and [columns][matrix-col]. A **zero matrix** contains all elements as zeros. For example:\n\n```java\n// Create null matrix with size 3x4\nMatrix m = new Matrix(3, 4);\n```\n\nThe code above constructs a new **zero matrix** with size $3 \\times 4$. The matrix will looks like this:\n\n```math\n\\begin{bmatrix}\n  0.0 \u0026 0.0 \u0026 0.0 \u0026 0.0 \\\\\n  0.0 \u0026 0.0 \u0026 0.0 \u0026 0.0 \\\\\n  0.0 \u0026 0.0 \u0026 0.0 \u0026 0.0\n\\end{bmatrix}\n```\n\n### \u003ca name=\"cr_matrix-3\" /\u003e `Matrix(int, int, double)`\n\n```java\npublic Matrix(int rows, int cols, double val);\n```\n\nThis constructor is similar to [`Matrix(int, int)`](#cr_matrix-2) but with an additional argument that sets the value for all elements of the constructed matrix. For example:\n\n```java\n// Create a new matrix with size 4x4 and set all elements to 5.0\nMatrix m = new Matrix(4, 4, 5);\n```\n\nThe constructed matrix will looks like this:\n\n```math\n\\begin{bmatrix}\n  5.0 \u0026 5.0 \u0026 5.0 \u0026 5.0 \\\\\n  5.0 \u0026 5.0 \u0026 5.0 \u0026 5.0 \\\\\n  5.0 \u0026 5.0 \u0026 5.0 \u0026 5.0 \\\\\n  5.0 \u0026 5.0 \u0026 5.0 \u0026 5.0\n\\end{bmatrix}\n```\n\n### \u003ca name=\"cr_matrix-4\" /\u003e `Matrix(double[][])`\n\n```java\npublic Matrix(double[][] arr);\n```\n\nThis constructor is **highly recommended** for constructing a new [matrix][what-is-matrix]. You can declare the entries first and then convert them into a **Matrix** object whenever needed.\n\n\u003e [!NOTE]  \n\u003e Please note, this constructor only accepts two-dimensional array with type of `double`.\n\nFor example:\n\n```java\n// Declare and initialize entries \"a\"\ndouble[][] a = {\n    { 1, 2, 3 },\n    { 4, 5, 6 }\n};\n\n// Convert to Matrix\nMatrix m = new Matrix(a);\n```\n\nAlternatively, you can directly create a new matrix using this code:\n\n```java\n// Create new matrix\nMatrix m = new Matrix(new double[][] {\n    { 1, 2, 3 },\n    { 4, 5, 6 }\n});\n```\n\n### \u003ca name=\"cr_matrix-5\" /\u003e `Matrix.identity(int)`\n\n```java\npublic static Matrix identity(int n);\n```\n\nThis constructor creates a new **identity matrix** with a size of $n \\times n$ (where $n$ is a non-floating number). An **identity matrix** is a square matrix with ones on the main diagonal and zeros elsewhere, often denoted as $I$.\n\nPlease avoid using $I$ or $i$ as variable names for matrices in code, as $i$ is commonly used in `for-loop` statements. Instead, consider using $mI$ or a similar alternative. For instance:\n\n```java\n// Create new identity matrix with size 5x5\nMatrix mI = Matrix.identity(5);\n```\n\nThe matrix will looks like this:\n\n```math\n\\begin{bmatrix}\n  1.0 \u0026 0.0 \u0026 0.0 \u0026 0.0 \u0026 0.0 \\\\\n  0.0 \u0026 1.0 \u0026 0.0 \u0026 0.0 \u0026 0.0 \\\\\n  0.0 \u0026 0.0 \u0026 1.0 \u0026 0.0 \u0026 0.0 \\\\\n  0.0 \u0026 0.0 \u0026 0.0 \u0026 1.0 \u0026 0.0 \\\\\n  0.0 \u0026 0.0 \u0026 0.0 \u0026 0.0 \u0026 1.0\n\\end{bmatrix}\n```\n\n## \u003ca name=\"matrix-ops\" /\u003e Matrix Operations\n\nThe **JMatrix** library provides several basic matrix operations that allow users to perform common matrix calculations with ease. These operations include:\n\n- [Addition](#matrix-add)\n- [Subtraction](#matrix-sub)\n- [Scalar Multiplication](#scalar-mult)\n- [Matrix Multiplication](#matrix-mult)\n- [Transposition](#matrix-transpose)\n- [Trace](https://en.wikipedia.org/wiki/Trace_(linear_algebra))\n- [Determinant](https://en.wikipedia.org/wiki/Determinant)\n\nFor more detailed information about each matrix operation, you can refer to the [:books: JMatrix Wiki][matrix-ops].\n\n### \u003ca name=\"matrix-add\" /\u003e Addition\n\n```java\npublic void sum(Matrix m);\n```\n```java\npublic static Matrix sum(Matrix m, Matrix n);\n```\n```java\npublic void sum(double[][] a);\n```\n```java\npublic static double[][] sum(double[][] a, double[][] b);\n```\n\n:book: **Wiki:** [Matrix Addition][matrix-add]\n\nIn **matrix addition**, two matrices with the same dimensions are added together element-wise. Each element of the resulting matrix is the sum of the corresponding elements from the two input matrices.\n\n\u003e [!IMPORTANT]  \n\u003e Before performing **matrix addition**, ensure that the two matrices have the same dimensions (in other words, square matrix).\n\n**Example code:**\n\n```java\n// Construct new matrices\nMatrix m = new Matrix(new double[][] {\n    { 6, 7, 0, 1 },\n    { 2, 6, 1, 8 }\n});\n\nMatrix n = new Matrix(new double[][] {\n    { 1, 9, 3, -4 },\n    { 7, 1, -1, 5 }\n});\n\n// Perform addition for both matrices and\n// create a new matrix as the resultant matrix\nMatrix k = Matrix.sum(m, n);\n```\n\n**Result:**\n\n```math\n\\mathbf{k} =\n\\begin{bmatrix}\n  7.0 \u0026 16.0 \u0026 3.0 \u0026 -3.0 \\\\\n  9.0 \u0026 7.0 \u0026 0.0 \u0026 13.0\n\\end{bmatrix}\n```\n\nIn the example above, two matrices $m$ and $n$ are created. The `Matrix.sum(m, n)` method is used to add both matrices element-wise, and the resulting matrix $k$ is computed and stored. The output matrix $k$ is the sum of matrices $m$ and $n$.\n\n### \u003ca name=\"matrix-sub\" /\u003e Subtraction\n\n```java\npublic void sub(Matrix m);\n```\n```java\npublic static Matrix sub(Matrix m, Matrix n);\n```\n```java\npublic void sub(double[][] a);\n```\n```java\npublic static double[][] sub(double[][] a, double[][] b);\n```\n\n:book: **Wiki:** [Matrix Subtraction][matrix-sub]\n\n**Matrix subtraction** involves subtracting corresponding elements of one matrix from another.\n\n\u003e [!IMPORTANT]  \n\u003e Before performing **matrix subtraction**, ensure that the two matrices have the same dimensions (in other words, square matrix).\n\n**Example code:**\n\n```java\n// Construct new matrices\nMatrix m = new Matrix(new double[][] {\n    { 1, -5, 8, -2, 3 },\n    { 2, 12, -2, 7, 0 },\n    { 6, 7, 9, 1, -5 }\n});\n\nMatrix n = new Matrix(new double[][] {\n    { 4, 6, 8, -3, 9 },\n    { -10, 6, 8, 1, 1 },\n    { 6, -7, 2, 3, 5 }\n});\n\n// Perform subtraction for both matrices and\n// create a new matrix as the resultant matrix\nMatrix k = Matrix.sub(m, n);\n```\n\n**Result:**\n\n```math\n\\mathbf{k} =\n\\begin{bmatrix}\n  -3.0 \u0026 -11.0 \u0026 0.0 \u0026 1.0 \u0026 -6.0 \\\\\n  12.0 \u0026 6.0 \u0026 -10.0 \u0026 6.0 \u0026 -1.0 \\\\\n  0.0 \u0026 14.0 \u0026 7.0 \u0026 -2.0 \u0026 -10.0\n\\end{bmatrix}\n```\n\nIn the example above, two matrices $m$ and $n$ are created. The `Matrix.sub(m, n)` method is used to subtract $n$ from $m$ element-wise, and the resulting matrix $k$ is computed and stored. The output matrix $k$ is the difference between matrices $m$ and $n$.\n\n### \u003ca name=\"scalar-mult\" /\u003e Scalar Multiplication\n\n```java\npublic void mult(double x);\n```\n```java\npublic static Matrix mult(Matrix m, double x);\n```\n\n:book: **Wiki:** [Scalar Multiplication][scalar-mult]\n\n**Scalar multiplication** involves multiplying all elements of a matrix by a scalar value. The resulting matrix will have each of its elements multiplied by the given scalar value.\n\n\u003e [!NOTE]  \n\u003e The resulting matrix's sizes of **scalar multiplication** will be always the same with the sizes of the operand matrix.\n\n**Example code:**\n\n```java\n// Construct new matrix\nMatrix m = new Matrix(new double[][] {\n    { 9, 6, 4 },\n    { 2, 1, 5 }\n});\n\n// Perform scalar multiplication with the scalar equal to 5\n// and create a new matrix as the resultant matrix\nMatrix s = Matrix.mult(m, 5);\n```\n\n**Result:**\n\n```math\n\\mathbf{s} =\n\\begin{bmatrix}\n  45.0 \u0026 30.0 \u0026 20.0 \\\\\n  10.0 \u0026 5.0 \u0026 25.0\n\\end{bmatrix}\n```\n\nIn the example above, a matrix $m$ is created. The `Matrix.mult(m, 5)` method is used to multiply each element of matrix $m$ by the scalar value $5$, resulting in a new matrix $s$.\n\n### \u003ca name=\"matrix-mult\" /\u003e Matrix Multiplication\n\n```java\npublic void mult(Matrix m);\n```\n```java\npublic static Matrix mult(Matrix m, Matrix n);\n```\n```java\npublic void mult(double[][] a);\n```\n```java\npublic static double[][] mult(double[][] a, double[][] b);\n```\n\n:book: **Wiki:** [Matrix Multiplication][matrix-mult]\n\n**Matrix multiplication** involves multiplying two matrices together following a specific rule.\n\n\u003e [!IMPORTANT]  \n\u003e Before performing **matrix multiplication**, ensure the number of [columns][matrix-col] in the first matrix must be equal to the number of [rows][matrix-row] in the second matrix.\n\n**Example code:**\n\n```java\n// Create and construct new matrices\nMatrix m = new Matrix(new double[][] {\n    { 2, 2, 2, 2 },\n    { 2, 2, 2, 2 }\n});\n\nMatrix n = new Matrix(new double[][] {\n    { 4, 4 },\n    { 4, 4 },\n    { 4, 4 },\n    { 4, 4 }\n});\n\n// Operate matrix multiplication for both matrices\n// and create a new matrix as the resultant matrix\nMatrix mn = Matrix.mult(m, n);\n```\n\n**Result:**\n```math\n\\mathbf{mn} =\n\\begin{bmatrix}\n  32.0 \u0026 32.0 \\\\\n  32.0 \u0026 32.0\n\\end{bmatrix}\n```\n\nIn the example above, two matrices $m$ and $n$ are created. The `Matrix.mult(m, n)` method is used to perform **matrix multiplication** between matrices $m$ and $n$, resulting in a new matrix $mn$.\n\n\n### \u003ca name=\"matrix-transpose\" /\u003e Transposition\n\n```java\npublic void transpose();\n```\n```java\npublic static Matrix transpose(Matrix m);\n```\n```java\npublic static double[][] transpose(double[][] a);\n```\n\n:book: **Wiki:** [Matrix Transposition][matrix-transpose]\n\n**Matrix transposition** involves swapping the [rows][matrix-row] and [columns][matrix-col] of a matrix. The resulting matrix will have its rows and columns interchanged.\n\n\u003e [!NOTE]  \n\u003e 💡 **Tip:** Repeating this operation to the transposed matrix will reset their indices position to the original position.\n\n**Example code:**\n\n```java\n// Create and construct new matrix\nMatrix m = new Matrix (new double[][] {\n    { 1, 2, 3, 4 },\n    { 5, 6, 7, 8 }\n});\n\n// Transpose the matrix and create a new matrix\n// to store the transposed matrix\nMatrix mT = Matrix.transpose(m);\n```\n\n**Result:**\n\n```math\n\\mathbf{mT} =\n\\begin{bmatrix}\n  1.0 \u0026 5.0 \\\\\n  2.0 \u0026 6.0 \\\\\n  3.0 \u0026 7.0 \\\\\n  4.0 \u0026 8.0\n\\end{bmatrix}\n```\n\nIn the example above, a matrix $m$ is created. The `Matrix.transpose(m)` method is used to transpose matrix $m$, resulting in a new matrix $mT$ with the [rows][matrix-row] and [columns][matrix-col] interchanged.\n\n\n## \u003ca name=\"author\" /\u003e Author\n\n**JMatrix** is authored and maintained by [Ryuu Mitsuki][mitsuki31].\n\n## \u003ca name=\"contributing\" /\u003e Contributing\n\nPlease feel free to contribute to this project if you know of a problematic algorithm based on linear algebra concepts or if you wish to make any existing algorithm better. Any contributions is very appreciated and greatly helped me.\n\n## \u003ca name=\"license\" /\u003e License\n\n**JMatrix** is licensed under the [Apache License 2.0][apache-2.0]. This license permits you to use, modify, distribute, and sublicense the software, subject to certain conditions.\n\nYou are free to use **JMatrix** for both commercial and non-commercial purposes. If you modify the software, you must clearly indicate the changes you made. Any contributions you make to the project are also subject to the same license terms.\n\nThe [Apache License 2.0][apache-2.0] allows you to distribute derivative works, but you must include the full text of the license in your distribution. Additionally, you are responsible for ensuring that any downstream recipients of the software are aware of its licensing terms.\n\nFor more details about the permissions, limitations, and conditions under which **JMatrix** is licensed, please refer to the [LICENSE][license] file provided with the project. The [LICENSE][license] file contains the complete text of \"The License\", ensuring full transparency and clarity regarding the terms of use for the software.\n\nBy using **JMatrix**, you agree to comply with the terms of the [Apache License 2.0][apache-2.0] and understand your rights and responsibilities as a user of this open-source software.\n\n\n[mitsuki31]: https://github.com/mitsuki31\n[jmatrix]: https://github.com/mitsuki31/jmatrix\n[license]: https://github.com/mitsuki31/jmatrix/blob/master/LICENSE\n[latest-ver]: https://github.com/mitsuki31/jmatrix/releases/latest\n\n\n\u003c!-- JMATRIX WIKI LINKS --\u003e\n[get-started]: https://github.com/mitsuki31/jmatrix/wiki/Getting-Started\n[what-is-matrix]: https://github.com/mitsuki31/jmatrix/wiki/Introduction-to-Matrix\n[matrix-row]: https://github.com/mitsuki31/jmatrix/wiki/Introduction-to-Matrix#matrix-row\n[matrix-col]: https://github.com/mitsuki31/jmatrix/wiki/Introduction-to-Matrix#matrix-column\n\n[matrix-ops]: https://github.com/mitsuki31/jmatrix/wiki/Matrix-Operations\n[matrix-add]: https://github.com/mitsuki31/jmatrix/wiki/Matrix-Operations#matrix-add\n[matrix-sub]: https://github.com/mitsuki31/jmatrix/wiki/Matrix-Operations#matrix-sub\n[scalar-mult]: https://github.com/mitsuki31/jmatrix/wiki/Matrix-Operations#mult-scalar\n[matrix-mult]: https://github.com/mitsuki31/jmatrix/wiki/Matrix-Operations#mult-matrices\n[matrix-transpose]: https://github.com/mitsuki31/jmatrix/wiki/Matrix-Operations#transpose-matrix\n\n\n\u003c!-- WIKIPEDIA LINKS --\u003e\n[bash-wiki]: https://en.m.wikipedia.org/wiki/Bash_(Unix_shell)\n[java-wiki]: https://en.m.wikipedia.org/wiki/Java_(programming_language)\n[linear-algebra-wiki]: https://en.m.wikipedia.org/wiki/Linear_algebra\n\n\n\u003c!-- OTHER LINKS --\u003e\n[java]: https://www.oracle.com/java/technologies/downloads\n[apache-2.0]: https://www.apache.org/licenses/LICENSE-2.0\n[python]: https://www.python.org\n[mingw]: https://www.mingw-w64.org/downloads\n[maven]: https://maven.apache.org/download.cgi\n[git-bash]: https://git-scm.com/downloads\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitsuki31%2Fjmatrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitsuki31%2Fjmatrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitsuki31%2Fjmatrix/lists"}