Hi all,
I was thinking about the opportunity of writing a basic linear algebra module in XQUERY (matrix / vector elementary computations, maybe up to cholesky decomposition), since I did not find any at present time. However, there are some little things that seems difficult to me. That could be nice to have opinions of more experimented XQUERY developers before starting trying to write it.
Indeed, XQUERY might provide the two basics needs to write a good linear algebra modulus :
- The first one is template programming. template programming is straightforward with XQUERY. - The second one is template expressions (see http://en.wikipedia.org/wiki/Expression_templates for a definition). I guess that such patterns are not too difficult to implement with XQUERY.
However, the bad points seems to be the following ones. Maybe someone have some insight over these questions ?
- I don't know how to allocate and address directly contiguous memory blocks in XQUERY. That is not a good point for performance issues, as working directly with such memory blocks drastically improves basic operations in copying objects (in linear algebra implementation, this is a key point to performance). - Immutability might result in a big overload in memory? This might not be true, see a recent thread over this topic (XQUERY for noobs). - I don't know how to overload the basic operators (*,+,-) with XQUERY. This may result in quite heavy notations like alg:prod($mat1,alg:minus($mat2,$mat3)) instead of $mat1*($mat2-$mat3).
Notice however that there are alternatives to XQUERY, since some very good linear algebra modules exists, but written in imperative languages. I list some alternatives, however, it might not be a good idea to wrap a functional language like XQUERY to an imperative, not thread safe, external module (this point has been noticed to me by BaseX teams members).
At my knowledge, UBLAS is very performant, flexible, and almost standardized one, but written in C++ http://www.boost.org/doc/libs/1_54_0/libs/numeric/ublas/doc/index.htm. I don't know how to bind C++ to JAVA, but it is certainly possible. However, I am wondering if this could be a good idea.
Eigen is another quite interesting C++ implementation (less performant, but more complete). Indeed, it provides a JAVA wrapper, named JEIGEN. Thus it could suit most of my needs.
Any suggestions welcome
Regards,
Jean-Marc