Re: ROOTCINT and linear algebra classes

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Tue Sep 09 1997 - 11:35:54 MEST


Hi Pasha,

   concerning template based classes in ROOT. This is currently not
supported
on the level of rootcint (i.e. the ClassDef and ClassImp macros do not
handle 
them correctly, yet). On the level of CINT templates are (kind of)
supported,
i.e. you can write macros in which you define templated classes (Masa
please 
explain status of template support in CINT !).

If you could provide the ROOT community with a (non-template) linear
algebra
library, many people will be very grateful and we will be happy to
include it
in the official ROOT release and provide the necessary support.

Concerning the problem you have with VECTOR. You are required to specify
all classes to be exported to the interpreter in a LinkDef.h file.
This file should include the lines:

#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class    VECTOR;
#endif

currently it does not work when you put these lines in the test.hh file
directly. However, as the help of rootcint says (rootcint -?), when
the LinkDef.h file is not specified rootcint will generate one. To be
able to do that it requires that the include file names minus
.<extension>
are the same as the class names. So VECTOR.hh works.

Concerning the "manual intervention". There is nothing wrong with having
a pointer to a double. The warning is generated by the rootcint function
that generates the Streamer() method for VECTOR. The problem is that we
can't generate automatically a Streamer() statement for pointers to
basic
types. What should we do with the pointer? How do we know that Size 
is the length of the vector pointed at by V? So if you look in
the generated Streamer() method you will see that the line outputing
V is commented. Only you know that Size is the length of V so you
should change by hand the Streamer() method to add Size to the
WriteArray statement. Next you must cut and paste the
now customized Streamer() method and include it directly in your
Vector.C source. And in LinkDef.h change the VECTOR pragma to:

#pragma link C++ class    VECTOR-;

where the - tells rootcint NOT to generate a Streamer() method
for VECTOR (since it has its own customized version).

The only problem with this method is that you are now responsible 
for updating VECTOR::Streamer() whenever you change a datamember 
in the VECTOR definition.

I'll make the "manual intervention" message more clear.


Cheers, Fons.



> 
> I've been trying to figure out how to use linear algebra classes with ROOT.
> There are 2 basically different types of linear algebra packages on the market:
> 
> - the ones using templated classes for vectors and matrices
> - the ones not using templates
> 
> In one of the previous postings I asked about how to use templated classes
> with 'rootcint'. - May be it is just not possible?
> 
> Using non-templated classes reveals other problems, an example is enclosed
> below.
> 
>                 I'd appreciate any comments,
>                                                         thanks, Pasha.
> 
> ----------------------------------------------- test.hh
> #include "root/Rtypes.h"
> class VECTOR {
> protected:
>   int      Size;
>   double*  V;
> public:
>   VECTOR();
>   ClassDef(VECTOR,1)
> };
> 
> #ifdef __CINT__
> #pragma link off all globals;
> #pragma link off all classes;
> #pragma link off all functions;
> #pragma link C++ class    VECTOR;
> #endif
> ------------------------------------------------
> /cdf/upgrade/tracking/murat/g3/test/glob>rootcint -f test_cint.cc -c -I../include -I$ROOTSYS/include test.hh
> Note: operator new() masked c
> Warning: Link requested for undefined class test  FILE: LINE:0
> --------------------------------------------------------------------------------
> 
> It looks like the file name matters here (does it really ? ) - if
> I rename test.hh into VECTOR.hh the diagnostics is quite different:
> 
> --------------------------------------------------------------------------------
> /cdf/upgrade/tracking/murat/g3/test/glob>mv test.hh VECTOR.hh
> /cdf/upgrade/tracking/murat/g3/test/glob>rootcint -f test_cint.cc -c -I../include -I$ROOTSYS/include VECTOR.hh
> Note: operator new() masked c
> class VECTOR in VECTOR.hh line 2 original base of virtual func
> *** Datamember VECTOR::V: pointer to fundamental type (need manual intervention)
> 
> --------------------------------------------------------------------------------
> 
> - The 1st question here is what's wrong with having pointer to double ?
> - It is also interesting to know what kind of "manual intervention"
>   user is supposed to provide

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:20 MET