How to setup JBLAS


Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /var/www/

Jblas is a linear algebra library for java developers to perform matrix operations easily. As we know  it is very difficult to program matrix operations .And Jblas provides us a number of inbuilt methods which we can use directly to perform matrix operations in few seconds.

Jlbas provides matrix objects for different data types say DoubleMatrix, FloatMatrix. Double matrix is the most commonly used matrix method in jblas.

In this blog , we will use Double Matrix to demonstrate the capabilities of jblas.

The below mentioned example, as you can see it, is a 2*2 matrix. To perform operations using standard java,we’ll need to write many lines of code.But with jblas, we can do it in a single line by using jblas methods.

Example :

Let’s create couple of 2*2 matrices.

DoubleMatrix dm1 = new DoubleMatrix(new double[][]{{1,2},{3,4}});

DoubleMatrix dm2 = new DoubleMatrix(new double[][]{{5,6},{7,8}});

We will use these matrix to manipulate inbuilt jblas methods .

Here are few Methods defined in Jblas :

  • dm1.sum() – Finds the sum fo all elements in a matrix.
  • dm1.rows() – Finds the number of rows in a matrix.
  • dm1.colums – Fins the number of columns in a matrix.
  • dm1.add(dm2) – Adds two matrices.
  • dm1.sub(dm2) – Subtracts two matrices.

As you can see, we can perform matrix without calculation in just one line. To know more about how to use these functions, read  my article on “_______”.

Read more:

How to Use :

There are three ways to use jblas :

  • Download jblas and run it
  • Add jblas dependeny in pom.xml file of maven project.






Read more about maven at :

  • Clone repository from github and install locally.


How to add jblas Depedency in Maven Project :

  • Open Eclipse - >  Project -> New Project -> Other -> Maven Project ,add group id and artifact id like i am using groupid - “com.numahub.demo” ,artifact id – modulePractice and click Finish.


  • Now for adding jblas dependencies ,go to your project(modulePractice) -> pom.xml and click on dependencies -> Add , like

Here group id , artifact id and version values are fixed as discussed earlier for jblas dependency.

  • Click OK and save pom.xml.This will add dependency in your project.

Now to check weather dependency get added in project or not , right click on project -> Run As - > Maven Install

If it runs fine which means jblas dependency is working fine.

Now , you can use jblas directly as you can see in below picture .