[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [CHANGESET]: First attempt at a single precision type.
From: |
Jaroslav Hajek |
Subject: |
Re: [CHANGESET]: First attempt at a single precision type. |
Date: |
Mon, 28 Apr 2008 21:41:37 +0200 |
On Mon, Apr 28, 2008 at 7:28 PM, John W. Eaton <address@hidden> wrote:
> On 28-Apr-2008, Jaroslav Hajek wrote:
>
> | still, the code duplication seems to be massive. The different Fortran
> | function names can be handled by overloaded wrappers. OTOH, it is
> | certainly desirable to have as much code compiled as possible, and
> | users aren't supposed to instantiate Matrix for anything other than
> | float and double.
>
> I'd really like to avoid the duplication as much as possible, even if
> it's likely that there will only be two instantiated types.
>
> Although it seems that we would need to have explicit specializations
> for functions that call BLAS and LAPACK routines, I think we can get
> the compiler to do a lot of that work for us if we use functors and
> some wrappers, though I do agree that using functors to wrap functions
> that take many arguments (like the BLAS and LAPACK functions do) will
> add some complication to the code. Template tricks can avoid the need
> to define specific functors for each type signature we will encounter,
> but it means building up the machinery to do it (I think the text C++
> Templates: The Complete Guide by Vandevoorde and Josuttis outlines all
> the techniques we would need.
>
> Whether we use functors or not, it might be good to wrap the BLAS and
> LAPACK routines anyway, so we can avoid the details of how character
> arguments are passed.
>
>
> | Is there any possibility to put a template for a method in a .cc file,
> | explicitly instantiate there, and just export the explicit instances?
> |
> | I'm thinking about something like this:
> | file RealMatrix.h:
> |
> | template <typename T>
> | class RealMatrix
> | {
> | bool is_symmetric(void) const;
> | };
> |
> | template class RealMatrix<float>;
> | typedef RealMatrix<float> FloatMatrix;
> |
> | template class RealMatrix<double>;
> | typedef RealMatrix<double> Matrix;
> |
> | // external explicit instances ????
> | template void RealMatrix<float>::is_symmetric();
> | template void RealMatrix<double>::is_symmetric();
> |
> | file RealMatrix.cc:
> |
> | # include RealMatrix.h
> | template<typename T>
> | void
> | RealMatrix<T>:: is_symmetric(void)
> | {
> | // code here
> | }
> |
> |
> | It seems not to be possible with g++. In that case, the best way to
> | keep maximum code precompiled is probably David's, despite the code
> | duplication.
>
> I'm not sure I understand the problem. We already have some fucntions
> defined in MArray2 (for example). If needed, there are forwarding
> functions in the Matrix class so that the return types of these
> functions are correct. In the case of is_symmetric, the return type
> should always be bool, so I don't think a forwarding function would
> even be necessary. I would expect inheritance rules to make this
> fairly simple.
>
Never mind. I just didn't know whether a particular template instance
can be linked from external .o file. I found out that this is normally
possible though.
> jwe
>
>
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- Re: [CHANGESET]: First attempt at a single precision type., (continued)
- Re: [CHANGESET]: First attempt at a single precision type., David Bateman, 2008/04/30
- Re: [CHANGESET]: First attempt at a single precision type., John W. Eaton, 2008/04/30
- Re: [CHANGESET]: First attempt at a single precision type., John W. Eaton, 2008/04/30
- Re: [CHANGESET]: First attempt at a single precision type., David Bateman, 2008/04/30
- Re: [CHANGESET]: First attempt at a single precision type., John W. Eaton, 2008/04/30
- Re: [CHANGESET]: First attempt at a single precision type., David Bateman, 2008/04/30
- Re: [CHANGESET]: First attempt at a single precision type., John W. Eaton, 2008/04/28
- Re: [CHANGESET]: First attempt at a single precision type.,
Jaroslav Hajek <=
- Re: [CHANGESET]: First attempt at a single precision type., David Bateman, 2008/04/29
- Re: [CHANGESET]: First attempt at a single precision type., John W. Eaton, 2008/04/29
- Re: [CHANGESET]: First attempt at a single precision type., David Bateman, 2008/04/29
- Re: [CHANGESET]: First attempt at a single precision type., Peter L., 2008/04/29
- Re: [CHANGESET]: First attempt at a single precision type., Jaroslav Hajek, 2008/04/29
- Re: [CHANGESET]: First attempt at a single precision type., David Bateman, 2008/04/29
- Re: [CHANGESET]: First attempt at a single precision type., John W. Eaton, 2008/04/29
- Re: [CHANGESET]: First attempt at a single precision type., David Bateman, 2008/04/29
Re: [CHANGESET]: First attempt at a single precision type., Jaroslav Hajek, 2008/04/28