Monday, March 18, 2013

Safe and unsafe matrices/vectors

There are was an ugly methods in la4j that started with "unsafe_". So, I've added these methods to provide to the client more effective and raw mechanisms on matrices and vectors. Anyway, I've decided to replace with method by new matrix type - SafeMatrix. The thing is all matrices in la4j are unsafe by default, but if client wants to get safe matrix, he can use special matrix wrapper that wraps unsafe methods with additional checks. Actually, there is another way to do that - introduce new matrix classes (use inheritance) but everybody knows that it prefer to use composition instead of inheritance.

So, the la4j looks more strict and clear now and I feel this is the right way to develop the library.

Just brief exaple of using safe and unsafe matrices:

Matrix a = new Basic1DMatrix(..); // unsafe
Matrix b =; // safe
Matrix c = a.multyply(b, Matrices.SAFE_BASIC1D_FACTORY); // safe

And friendly reminder: if someone want to participate - there are loads of opened issues at GitHub.

No comments:

Post a Comment