468,768 Members | 1,318 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,768 developers. It's quick & easy.

numeric library help

Hi all,
I am looking for a high-performance container(matrix and vector) for
numerical computation. Someone recommended the boost::multi_array. After
having looked at the documentation, I know several more candidates from it. They
are : MTL, blitz++, boost::ublas. I have no idea which one is the best.
The documentation of these packages are trying to convince me that they
are free from drawback :)) I need someone to tell me the experience in
using these packages. I must pick one of them before I begin my
development of a special numerical library based on it.
Jul 19 '05 #1
4 5294
Rex_chaos wrote:
Hi all,
I am looking for a high-performance container(matrix and vector) for
numerical computation. Someone recommended the boost::multi_array. After
having looked at the documentation, I know several more candidates from
it. They are : MTL, blitz++, boost::ublas. I have no idea which one is the
best. The documentation of these packages are trying to convince me that
they are free from drawback :)) I need someone to tell me the experience
in using these packages. I must pick one of them before I begin my
development of a special numerical library based on it.


there's one more:

FLENS - Flexible Library for Efficient Numerical Solutions

http://sourceforge.net/projects/flens/

I am working in the department of numerical analysis at the University of
Ulm and we started about half a year ago with the implementation of FLENS.

First of all some reasons why we started with an own implementation might be
interesting for you:

MTL: It doesn't compile with iso standard conform compilers. It seams the
MTL-project is no longer active or at least has become a little sleepy.
It's also hard to maintain or to extend the MTL-code. And IMO to use MTL
is not always intuitive and the code just looks ugly (ok, matter of taste).

Blitz: Very nice and we copied some usability-features. But it's not ment
to be a numerical analysis library. It defines array-containers, provides
functionality to fill those ellegant, avoids unnecessary temoprary objects.
But if you need a matrix-vector multiplication or you need solvers for
linear equatiuons you have to implement this on your own (well, one thing
the developers of Blitz write themselves is that it's hard to extend,
partly due to the usage of expression templates)

boost::ublas I think from the above boost::ublas is best suited for
numerical analysis. It provides dense and sparse matrices, operations for
slicing (like in MatLab A(3:5, 7:8) just a less convenient notation). For
our purpose it was still not flexible enough regarding creation of own
matrix types. Another reason was, thst it also has some inconvenient
notations (not well suited for teaching purpose and some of our master
students are great mathematicians but poor programmers, they need a
interface as close to something like MatLab as possible.)

So I would say if you have to choose from the above 3 libs and if you really
need numerical functionality I would go with boost::ublas. However it
depends on what exactly your project is about (You said "special" numerical
library we experienced that "our special" required a more flexible
matrix-/vector concept)

So now some words about our library. Our master students use it for their
master thesis and in our lectures it's used for the exercises. But of
course it's only about 6 months old, so I don't want to claim that it is as
mature (and documented) as one of the lib's above. I only know that it
works fine for OUR teaching and research, but we steadily find and fix
bugs. If you plan to use our library you can tell me more about what your
project is about and I can tell you if it's reasonable IMO to really use
it. Of course, we would support by fixing flens-lib problems as soon as
possible over that time (like we do for our students).

cheers
Michael

P.S. a little example of what we call a usable interface:
DoubleDenseMatrix A(2, 2);
A = 1, 1,
1, 3
1, 5;

DoubleDenseVector b(3);
b = 4,
8,
11;

// SLICING
cout << "A(1:2,1:2) = " << A(_(1,2), _(1,2)) << endl;
cout << "b(1:2) = " << b(_(1,2)) << endl;

// SOLVE for x: A(1:2,1:2)*x = b(1:2)
cout << "x = A(1:2,1:2)/b(1:2) = "
<< A(_(1,2), _(1,2))/b(_(1,2)) << endl;



Jul 19 '05 #2
> there's one more:

FLENS - Flexible Library for Efficient Numerical Solutions

http://sourceforge.net/projects/flens/ I am working in the department of numerical analysis at the University of
Ulm and we started about half a year ago with the implementation of FLENS.

First of all some reasons why we started with an own implementation might be
interesting for you:

MTL: It doesn't compile with iso standard conform compilers. It seams the
MTL-project is no longer active or at least has become a little sleepy.
It's also hard to maintain or to extend the MTL-code. And IMO to use MTL
is not always intuitive and the code just looks ugly (ok, matter of taste).
Maybe. But from the website of MTL, it seems that the developers are
going to have a further develope the package. Anyway, I don't really
like the interface of MTL. BTW, from the FAQ of MTL, it seems that the
highest efficiency must be actived by some compilers not all. :(
Blitz: Very nice and we copied some usability-features. But it's not ment
to be a numerical analysis library. It defines array-containers, provides
functionality to fill those ellegant, avoids unnecessary temoprary objects.
But if you need a matrix-vector multiplication or you need solvers for
linear equatiuons you have to implement this on your own (well, one thing
the developers of Blitz write themselves is that it's hard to extend,
partly due to the usage of expression templates) Actually, I have been writing my own package since one year ago. But I
give up recently because of the powerful Blitz. Some comments are
trying to convince me that Blitz are free from drawbacks !? Your
opinion on the library show me something more important than the
effeciency - the second development. Maybe blitz is not really
suitable for my purpose.

boost::ublas I think from the above boost::ublas is best suited for
numerical analysis. It provides dense and sparse matrices, operations for
slicing (like in MatLab A(3:5, 7:8) just a less convenient notation). For
our purpose it was still not flexible enough regarding creation of own
matrix types. Another reason was, thst it also has some inconvenient
notations (not well suited for teaching purpose and some of our master
students are great mathematicians but poor programmers, they need a
interface as close to something like MatLab as possible.) It sounds that you are doing something more abstract and fexible. I
have no idea about it. I think boost::ublas is good because of it's
consideration of different type of matrix. But I am worrying about the
following issue. You know, ublas is part of boost project and it's
implementation depends on several package of boost. So far, boost is
only a third-party library or loosely speaking it is a quasi-standard
library(isn't it?). From the user's view point, boost is very powerful
but most of the functionality make no sense to me. So if I choose
ublas as a foundation of my numerical library, the dependency to boost
is quite a issue. What's your opinion?
So now some words about our library. Our master students use it for their
master thesis and in our lectures it's used for the exercises. But of
course it's only about 6 months old, so I don't want to claim that it is as
mature (and documented) as one of the lib's above. I only know that it
works fine for OUR teaching and research, but we steadily find and fix
bugs. If you plan to use our library you can tell me more about what your
project is about and I can tell you if it's reasonable IMO to really use
it. Of course, we would support by fixing flens-lib problems as soon as
possible over that time (like we do for our students).


It sounds great. I would like to know more about it but the site you
give above is blocked. Would you please tell me something more about
flens? Is it a elegant library just like blitz? What is the aim of
this project (just provide a friendly interface)?

Finally, I would like to have your opinion about the effeciency of the
libraies talking above. I am a very beginner of cpp programming. For
comparing with the OOP(eg. inheritance mechanism, operator-based
mechanism), template technique, which leads to generic programming,
is a good choice for providing high effeciency code, just like MTL do.
For further lower the cost, blitz take expression template as the core
of the library. The author of the blitz claims that some code of the
library is more efficient than that of Fortran ?! I don't know the
effeciency of ublas and flens.

p.s. What I am doing is to develope a library for some numerical
routines and solver of PDE. Solving nonlinear PDE is also a essential
part of my library.
Jul 19 '05 #3
Hi Rex,
You know, ublas is part of boost project and it's
implementation depends on several package of boost. So far, boost is
only a third-party library or loosely speaking it is a quasi-standard
library(isn't it?). From the user's view point, boost is very powerful
but most of the functionality make no sense to me. So if I choose
ublas as a foundation of my numerical library, the dependency to boost
is quite a issue. What's your opinion?


uBlas uses other parts of the boost library. If I take a quick look in
config.hpp of boost I get:
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/limits.hpp>
#include <boost/utility.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/find.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_reference.hpp>

Maybe there are some more includes in other files. There are no libs and no
*.cpp to add to your project, just include the necessary header files out of
your boost tree. I did no installation nor any regression. I just put the
boost tree on my harddisk.

There is a yahoo group for ublas (ublas-dev ?), where you can find the
bindings to LAPACK, ATLAS, BLAS and UMFPACK. I use the LAPACK-Bindings which
work fine for me. Here I found these includes to other parts of boost
(perhaps not complete as well):
# include <boost/static_assert.hpp>
# include <boost/type_traits.hpp>

Regards,
Patrick
Jul 19 '05 #4
> uBlas uses other parts of the boost library. If I take a quick look in
config.hpp of boost I get:
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/limits.hpp>
#include <boost/utility.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/find.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_reference.hpp>

Maybe there are some more includes in other files. There are no libs and no
*.cpp to add to your project, just include the necessary header files out of
your boost tree. I did no installation nor any regression. I just put the
boost tree on my harddisk.


I have tested both the ublas and blitz. From the user's point of view,
blitz provide a more friendly interface as well as higher effeciency.
However, blitz is a little bit difficult to extend. I am hesitating
which one is better for my developement of a numerical library
including a PDE solver, etc.
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by GujuBoy | last post: by
7 posts views Thread by BBFrost | last post: by
9 posts views Thread by Agnes | last post: by
4 posts views Thread by Dimitrios Charitatos | last post: by
7 posts views Thread by Sheldon | last post: by
5 posts views Thread by Andreas Beyer | last post: by
11 posts views Thread by ZMY | last post: by
13 posts views Thread by nishit.gupta | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.