[GRASS-dev] gmath and gpde update

Soeren Gebbert soerengebbert at googlemail.com
Mon Jan 12 04:31:31 EST 2009


Thanks for you suggestions Glynn.

2009/1/12 Glynn Clements <glynn at gclements.plus.com>

>
> Soeren Gebbert wrote:
>
> > In case we will use the meschach library within grass to replace the
> > existing LAPACK wrapper, my BLAS and solver implementation
> > and several numerical recipes algorithm (lu, eigenvalues solvers ...), i
> > will take the patched debian sources and integrate them into
> > grass.
> >
> > IMHO the following changes have to be made in the meschach library:
> >
> > * replacing malloc, calloc and realloc with the GRASS implementation
>
> Not necessarily. The G_* versions are merely a convenience to avoid
> having to explicitly check for failure. If meschach is already
> performing the checking, there probably isn't much reason to change
> it.
>

Agreed, AFAICT memory checks are performed in meschach.
But i was hoping to get rid of the machine dependent defines within the
include files of meschach,
grass already checks for malloc, calloc and realloc.


>
> > * replacing printf and fprintf with the GRASS implementation
>
> GRASS doesn't have implementations of those functions. It has
> G_message() etc, which should be used for communicating with the user.


Sorry for confusion, i ment G_message() etc.
Usage of G_message() will probably integrate meschach better in the grass
message handling (quite, verbose ...).
But i have to think more about this. You are making a good point.
In case a distribution version of meschach will be used, instead of the copy
in grass,
the message handling will process in the original way ..  so the benefit of
changing the
message handling in the grass copy is lost ... and because of that not
meaningful at all.


>
>
> > * changing the error handling to use G_fatal_error and similar GRASS
> > functions
>
> Probably, although this should be done in a minimal manner, e.g.
> making errors call a user-defined callback, and installing a callback
> which calls G_fatal_error().


Agreed.

>
>
> > * adding the prefix G_math_ to all extern library functions (with
> > preprocessor directives)
>
> Why?


To mark the meschach code as part of the gmath library. Many functions in
meschach are quite short
and in this manner not self explaining. I think the grass code using
meschach will
be more readable if a prefix is used. A developer who is not familiar with
meschach will identify the
functions as part of the gmath library and will not search for local
function definitions.
But i wont touch any function name in the code of meschach. Instead i would
like to include the meschach
includes into gmath.h and redefine the meschach names with macros:

gmath.h:

/*meschach includes*/
#ifndef SYSTEM_MESCHACH
#include "grass/matrix.h"
...
#else
#include <matrix.h>
...
#endif

#define G_math_iv_get iv_get
#define G_math_SPMAT SPMAT
#define G_math_sp_free sp_free
...


>
>
> Is there some reason why GRASS must "assimilate" meschach rather than
> simply using it (with any modifications which are strictly necessary).


No.


>
>
> In particular, if any distributions provide a meschach package, it's
> generally preferable to use that rather than a private copy.


Agreed.
But IMHO a copy of meschach should be provided in grass with minimal changes
so it can be
replaced with a distribution version. I guess this can be handled at
configuration time.

Soeren


>
>
> --
> Glynn Clements <glynn at gclements.plus.com>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-dev/attachments/20090112/f891c55e/attachment.html


More information about the grass-dev mailing list