octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [CHANGESET]: First attempt at a single precision type.


From: John W. Eaton
Subject: Re: [CHANGESET]: First attempt at a single precision type.
Date: Wed, 30 Apr 2008 18:19:17 -0400

On 30-Apr-2008, David Bateman wrote:

| John W. Eaton wrote:
| > On 30-Apr-2008, John W. Eaton wrote:
| > 
| > | Did you mean to write this as
| > | 
| > |   ComplexMatrix ComplexMatrix::stack (const Matrix&) const
| > |   {
| > |     return MArray2<ComplexMatrix>::stack (a);
| > |   }
| > | 
| > | in the ComplexMatrix class?
| > 
| > Oops, I meant "MArray2<complex>::stack (a)".
| 
| Or even "MArray2<Complex>::stack(a)", sorry the fault was only in the
| e-mail not in what I implemented.. Thinking about the problem is
| probably that the template needs to be instantiated somewhere, though I
| thought the call to the templated method should have done that itself..
| I think I see in any case why these functions haven't been templated in
| the past :-)

OK, it will work with the following function in MArray2.h:

  template <class U>
  MArray2<T> stack (const MArray2<U>&) const
  {
    ...
  }

and the following in CMatrix.cc:

  ComplexMatrix
  ComplexMatrix::stack (const Matrix& a) const
  {
    return MArray2<Complex>::stack (a);
  }

Of course it would be better to put this in CMatrix.h so it could be
inlined.  To do that, you'll need to include Matrix.h in CMatrix.h.
Without that, it fails because Matrix is not a complete type at the
time CMatrix.h is parsed (I think).  The error message from g++ didn't
really help me zero in on the problem immediately...

Something else to consider is that these are binary operations, so
maybe they should't be member functions?  These are some of the older
function in liboctave which were written when I didn't really know
what I was doing (as if I do now).

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]