Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Roy Stogner
On Wed, 23 Jan 2008, Roy Stogner wrote: Real min_realpart(const std::vector &v) I finally realized that here was not the best place to bring in the template specialization. We've had some little-used functions libmesh_norm(x) (returning std::norm(x) or x*x as appropriate) and libmesh_real(x

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Roy Stogner
On Wed, 23 Jan 2008, John Peterson wrote: > How about > > #ifdef USE_COMPLEX_NUMBERS > // use ::real syntax > #else > > #endif > > > I didn't try this so if that makes no sense sorry. That was actually the first thing I started coding, so hopefully it makes some sense. ;-) But DistributedVecto

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread John Peterson
How about #ifdef USE_COMPLEX_NUMBERS // use ::real syntax #else #endif I didn't try this so if that makes no sense sorry. -J Derek Gaston writes: > Well... I made up a little toy code here... and got several other > people from around the office (who are _very_ knowledgeable in C++ > lor

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Derek Gaston
To expand on that you could even do something like: template void auxDoSomething() {} template<> void something >::doSomething() { auxDoSomething(); } That way each of your specializations don't have to have code copied and pasted into them Derek On Jan 23, 2008 11:11 AM, Derek Gaston <[

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Derek Gaston
Well... I made up a little toy code here... and got several other people from around the office (who are _very_ knowledgeable in C++ lore) to come try and make it compile... with no luck. It just doesn't seem to be possible. I _did_ actually get it to compile with something like this: template<>

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Roy Stogner
On Wed, 23 Jan 2008, Derek Gaston wrote: > 2008/1/23 Roy Stogner <[EMAIL PROTECTED]>: >> template >> Real DistributedVector >::min () const {...} > > Have you tried: > > template > Real DistributedVector >::min () const {...} No; I didn't even know that was valid syntax. Are you sure you don't

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Derek Gaston
2008/1/23 Roy Stogner <[EMAIL PROTECTED]>: > template > Real DistributedVector >::min () const {...} Have you tried: template Real DistributedVector >::min () const {...} Derek > > with: > > error: invalid use of undefined type 'class > DistributedVector >' > --- > Roy --

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Roy Stogner
On Wed, 23 Jan 2008, Derek Gaston wrote: Sure you can... I do it with some of my classes in my code like this In something.h: template class Something { T doSomething(); }; template<> double Something::doSomething(); The situation here's a little more complicated. This works: templ

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Derek Gaston
On Jan 23, 2008 9:22 AM, Roy Stogner <[EMAIL PROTECTED]> wrote: > The fix looks simple enough (we ought to be explicitly using > std::complex::real()), but I'm not sure of the cleanest way to do > it in standard C++. You can't partially specialize one method or two > in a templated class without r

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Roy Stogner
On Wed, 23 Jan 2008, John Peterson wrote: > Wow, I think you are exactly right. So could this have compiled all > this time because operator< is valid for two iterators, which may be > all the internals of std::min() would have needed? Looks like the > code has been this way as far back as SVN

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Benjamin Kirk
>> Is that line of code even correct for Reals? std::min isn't supposed >> to operate on container iterators, it's just supposed to return the >> minimum of two elements with a defined operator<. There's a >> std::min_element which is probably what the author (I hope it wasn't >> me...) was think

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread John Peterson
Roy Stogner writes: > > > On Wed, 23 Jan 2008, John Peterson wrote: > > > Jan Biermann writes: > > > Hi developers, > > > > > > I just downloaded the latest libmesh version and when I compile it in > > > complex mode, the compiler throws an error from distributed_vector.h: > > > > > >

Re: [Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Roy Stogner
On Wed, 23 Jan 2008, John Peterson wrote: Jan Biermann writes: > Hi developers, > > I just downloaded the latest libmesh version and when I compile it in > complex mode, the compiler throws an error from distributed_vector.h: > > In member function »Real DistributedVector::min() const [with T

[Libmesh-devel] error compiling in complex mode

2008-01-23 Thread John Peterson
Jan Biermann writes: > Hi developers, > > I just downloaded the latest libmesh version and when I compile it in > complex mode, the compiler throws an error from distributed_vector.h: > > In member function »Real DistributedVector::min() const [with T = > std::complex]«: > src/numerics/nu

[Libmesh-devel] error compiling in complex mode

2008-01-23 Thread Jan Biermann
Hi developers, I just downloaded the latest libmesh version and when I compile it in complex mode, the compiler throws an error from distributed_vector.h: In member function »Real DistributedVector::min() const [with T = std::complex]«: src/numerics/numeric_vector.C:182: instantiated from here