jMatrices - Java Matrix Library


  White Paper
  Java Doc


What is jMatrices?

jMatrices is an effort at providing an open source Java library for matrices.

Not another one...

I don't believe in redoing what has already been accompalished. I toed with the idea for weeks and played around with other Matrix libraries. After a lot of thought, I decided, rather than complaining (to myself) all the time, I should get down to do something about it. And hence, jMatrices was born.

...and it is different.

My biggest grouse with other Matrix libraries were the huge interfaces provide by the Matrix objects. A Matrix object acted as a one stop shop for everything that can be done with matrices! Now there are hundreds of things one can think of doing with a Matrix object.

The worst case is when Matrix object starts exposing methods for applying functions to each element. I can think of thousands such functions! So how did we solve this problem? Elementary, Dr. Watson.

				Matrix m = MatrixFactory.getRandomMatrix(3,3,null);
				/* Apply a function (sin) to all the elements of a matrix */ 
				Matrix sinM = MatrixEBETransformer.transform( m, new MatrixEBETransformation() {
						double transform(double element) {
							return Math.sin(element);
				//a method implementing scalar multiplication
				public Matrix scalarMultiplication(final int multiplier) {
					return MatrixEBETransformer.ebeTransform( m, new MatrixEBETransformation() {
							double transform(double element) {
								return multiplier*element;

Now isn't that powerful, flexible, manageable and simple? (Okay! people might protest that not everyone knows, how to use annonymous classes, but eh! if we don't use the language for all its worth, then we might as well do it in C or any such language.)

The Master Stroke

A library that provides just a Matrix data type without providing, a rich set of operations is of no use. The question that arose was - how to organize myraid operations possible on and with Matrices?

Patterns to the rescue. No! No! it has nothing to do with another pattern language. While thinking about the solution to the problem stated above, I realized that operations did follow a pattern allowing for a good way to segregate them into meaningful units.


For a discussion of how patterns were used in grouping the operations, please, refer to the white paper, section 4.2 - Operation Classification.

Copyright © 2001-2004, Piyush Purang | email | Last modified at 2004-05-18 04:31 PM