Skip to content

Very Brief Introduction

Vadim edited this page Aug 28, 2015 · 2 revisions

Documentation of jblas is a bit sparse at it is. A good starting point are the Javadoc pages and main classes like DoubleMatrix.

A minimal example which constructs a matrix and a vector and multiplies them looks like this:

import org.jblas.DoubleMatrix;

public class Example {
  public static void main(String[] args) {
        DoubleMatrix A = new DoubleMatrix(new double[][]{
                {1.0, 2.0, 3.0},
                {4.0, 5.0, 6.0},
                {7.0, 8.0, 9.0}
        });
        DoubleMatrix x = new DoubleMatrix(new double[][] {
                {1.0, 2.0, 3.0},
                {1.0, 2.0, 3.0},
                {1.0, 2.0, 3.0}
        });
        DoubleMatrix y;

        y = A.mmul(x);
  }
}

Operators are mapped to short names, “+” becomes “add”, “-” becomes “sub”, and so on. jblas only support two-dimensional matrices, and also considers vectors as two-dimensional matrices (having only one row or column).

For more information, have a look at DoubleMatrix

You can also find some more information on why you need native code and why it is harder than it has to be on the page Java Native Code Background.