Giter Site home page Giter Site logo

jmatrix's Introduction

JMatrix

JMatrix is a lightweight java package that is designed for working with 2 dimensional matrices efficiently. It supports parallel computations for Numerical calculations like multiplications using the concept of multithreading to improve the running time. The implementation also takes into account spatial locality to avoid unnecessary cache miss. The class currently supports all the wrapper classes that extend the Number class in java and it makes use of bounded generics to enforce type check during compile time. Additionally, the current implementation of the arithmetic operations (non-parallel) supports broadcasting similar to numpy by allowing different matrix shapes to be involved in the computation if they satisfy the broadcasting rules.

Current Benchmarks

The computation metrics are recorded for a 2 dimensional floating point matrix of size 1000X1000. Therefore, a total of 2*10e6 FLOPS including the scalar addition and multiplication that are involved.

Operation Execution Time (in seconds)
Matrix multiplication (Normal) 3.409885218
Matrix multiplication (Parallel) 0.774605248

Each Matrix object consists of a timeTaken propery that tracks the running time of the arithmetic operations performed on the object. The recorded time is mesured in nanoseconds.

Example

Below is a contrived example of some of the operations the package supports.

package import
import jmatrix.Matrix;
	
public class JTest{
	
public static void main(String[] args) {
	int n  = 100;
	Integer a[] = new Integer[n];
	Integer b[] = new Integer[n];	
	for(int i =0;i<n;i++){
		a[i] = 1;
		b[i] = 1;
	 }
			
//creating the matrix objects
	Matrix<Integer> mat1 = new Matrix<>(a,10,10);
	Matrix<Integer> mat2 = new Matrix<>(b,10,10);
	Matrix<Integer>mat = new Matrix<>(c);
			
//testing the package operations
	mat1.view();
	mat2.view();
	mat1.multiply(mat2);
	System.out.printf("%.8f\n",mat1.timeTaken/1e9);
	Matrix result = mat1.parallelMultiply(mat2);
	result.view()
	System.out.printf("%.8f\n",mat1.timeTaken/1e9);
  }
		
	
}

jmatrix's People

Contributors

nithinbharathi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.