Skip to content

This project is intended to serve linear algebra methods, focusing on operations with vectors and matrices. It offers an easy-to-use interface to perform various operations on vectors and matrices.

Notifications You must be signed in to change notification settings

MatiKK/Linear-Algebra-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Matrices-and-Linear-Algebra

This project is intended to serve linear algebra methods, focusing on operations with vectors and matrices. It offers an easy-to-use interface to perform various operations on vectors and matrices.

Example Usage

package algebra;

public class ExampleLinearAlgebra {

    public static void main(String[] args){

    	int[] v1 = {1, 2, 3};
    	int[] v2 = {1, 2, 3};
    	int[] v3 = LinearAlgebra.vectorAddition(v1, v2);
    	v3 = LinearAlgebra.vectorSubtraction(v1, v2);
    	v3 = LinearAlgebra.vectorScalarMultiplication(v3, 50);
    	double dotProd = LinearAlgebra.vectorsDotProduct(v1, v2);
    	int[] orthogonalv3 = LinearAlgebra.perpendicularVector(v3);
    	int[] crossProd = LinearAlgebra.crossProduct(v1, v2);
    	boolean arePerpendicular = 
    		LinearAlgebra.vectorsArePerpendicular(v3,crossProd);
    	
        RealMatrix m1, m2, result;

        // Initial matrix capacity
        m1 = new RealMatrix(3, 3);
        
        // Matrix 4x4 with random integer numbers
        m2 = RealMatrix.random(4, 4);

        // Adding Rows to the matrix
        m1.addRow(new Number[]{1, 2, 3});
        m1.addRow(new double[]{4, 6, 6});
        m1.addRow(v1);
        m1.addRow(1, v2);
        m1.addColumn(1, array);

        // Matrices operations
        m1.add(m2);
        RealMatrix m3 = LinearAlgebra.subtractMatrices(m1,m2);
        m3 = LinearAlgebra.matrixMultiplication(m1, m2);
        m3 = LinearAlgebra.matrixScalarMultiplication(m3, Math.PI);
        double det = LinearAlgebra.matrixDeterminant(m3);
        m3 = LinearAlgebra.matrixInverse(m3);
    }
}

Advise

It is not suggested to use this project for critical work if efficiency and optimization is what you need, better and more optimized codes of your needings can be found. This project only has the intention to show the creator's passion for programming and math.

About

This project is intended to serve linear algebra methods, focusing on operations with vectors and matrices. It offers an easy-to-use interface to perform various operations on vectors and matrices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages