Template Nightmare

M

Michael

Hi guys,
I'm trying to use the JAMA libraries which are a templated set of classes,
but my experience in templated classes is limited.
Now, htis is the definition according to the lib's DOxygen breakdown:


template<class Real>
JAMA::Eigenvalue<Real>::Eigenvalue<Real> ( const TNT::Array2D< Real >
& A ) [inline]



and I try to invoke it with:




TNT::Array2D<double> CovarMatrix(3,3,0.0);

//(Do stuff to Covar)

JAMA::Eigenvalue<double> EV(CovarMatrix);



but the compilers not having any of it. Could someone please expain the
above notation to me.

Many Thanks



Mike
 
R

red floyd

Michael said:
Hi guys,
I'm trying to use the JAMA libraries which are a templated set of classes,
but my experience in templated classes is limited.
Now, htis is the definition according to the lib's DOxygen breakdown:


template<class Real>
JAMA::Eigenvalue<Real>::Eigenvalue<Real> ( const TNT::Array2D< Real >
& A ) [inline]



and I try to invoke it with:




TNT::Array2D<double> CovarMatrix(3,3,0.0);

//(Do stuff to Covar)

JAMA::Eigenvalue<double> EV(CovarMatrix);



but the compilers not having any of it. Could someone please expain the
above notation to me.

Many Thanks



Mike

Care to be a bit more specific? What is the error you are getting?
 
M

Michael

red floyd said:
Michael said:
Hi guys,
I'm trying to use the JAMA libraries which are a templated set of classes,
but my experience in templated classes is limited.
Now, htis is the definition according to the lib's DOxygen breakdown:


template<class Real>
JAMA::Eigenvalue<Real>::Eigenvalue<Real> ( const TNT::Array2D< Real >
& A ) [inline]



and I try to invoke it with:




TNT::Array2D<double> CovarMatrix(3,3,0.0);

//(Do stuff to Covar)

JAMA::Eigenvalue<double> EV(CovarMatrix);



but the compilers not having any of it. Could someone please expain the
above notation to me.

Many Thanks



Mike

Care to be a bit more specific? What is the error you are getting?




Visual Studio .Net 2003 tries to compile with the following errors:

Compiling...
BSPTCreator.cpp
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\jama\jama_eig.h(234) : error C2668: 'std::max' :
ambiguous call to overloaded function
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xutility(1242): could be 'const _Ty &std::max<Real>(const
_Ty &,const _Ty &)'
with
[
_Ty=double,
Real=double
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\tnt_math_utils.h(43): or 'Scalar TNT::max<Real>(const
Scalar &,const Scalar &)'
with
[
Scalar=double,
Real=double
]
while trying to match the argument list '(double, double)'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\jama\jama_eig.h(215) : while compiling class-template
member function 'void JAMA::Eigenvalue<Real>::tql2(void)'
with
[
Real=double
]
c:\Documents and
Settings\Michael\Desktop\Ixium3D\BSPTCreator\BSPTCreator.cpp(181) : see
reference to class template instantiation 'JAMA::Eigenvalue<Real>' being
compiled
with
[
Real=double
]
Build Time 0:02
Build log was saved at "file://c:\Documents and
Settings\Michael\Desktop\Ixium3D\BSPTCreator\Debug\BuildLog.htm"
BSPTCreator - 1 error(s), 0 warning(s)

---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
 
C

Canonical Latin

Michael said:
Compiling...
BSPTCreator.cpp
c:\Program Files\Microsoft Visual Studio .NET
...
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped

Compiler is telling you that <tnt_math_utils.h> is incompatible with
<xutility> in the same namespace. Are you using "using namespace ..." in
your code? If so, don't!
 
R

red floyd

Michael said:

Real >
& A ) [inline]



and I try to invoke it with:




TNT::Array2D<double> CovarMatrix(3,3,0.0);

//(Do stuff to Covar)

JAMA::Eigenvalue<double> EV(CovarMatrix);



but the compilers not having any of it. Could someone please expain the
above notation to me.

Many Thanks



Mike

Care to be a bit more specific? What is the error you are getting?





Visual Studio .Net 2003 tries to compile with the following errors:

Compiling...
BSPTCreator.cpp
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\jama\jama_eig.h(234) : error C2668: 'std::max' :
ambiguous call to overloaded function
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xutility(1242): could be 'const _Ty &std::max<Real>(const
_Ty &,const _Ty &)'
with
[
_Ty=double,
Real=double
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\tnt_math_utils.h(43): or 'Scalar TNT::max<Real>(const
Scalar &,const Scalar &)'
with
[
Scalar=double,
Real=double
]
while trying to match the argument list '(double, double)'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\jama\jama_eig.h(215) : while compiling class-template
member function 'void JAMA::Eigenvalue<Real>::tql2(void)'
with
[
Real=double
]
c:\Documents and
Settings\Michael\Desktop\Ixium3D\BSPTCreator\BSPTCreator.cpp(181) : see
reference to class template instantiation 'JAMA::Eigenvalue<Real>' being
compiled
with
[
Real=double
]
Build Time 0:02
Build log was saved at "file://c:\Documents and
Settings\Michael\Desktop\Ixium3D\BSPTCreator\Debug\BuildLog.htm"
BSPTCreator - 1 error(s), 0 warning(s)

---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped

Let me guess. You're including <windows.h> as well, aren't you?
Microsoft has done the very evil thing of #define'ing min() and max().

In your project properties, add /DNOMINMAX, or in your stdafx.h file (as
the first non-cmment line) #define NOMINMAX

This suppresses the evil redefinition of min and max.
 
M

Michael

Many thnaks guys, I'm back in business.. it was the "using namespace std"
that it didn't like so much!
Mike


red floyd said:
Michael said:
Michael wrote:

Hi guys,
I'm trying to use the JAMA libraries which are a templated set of
classes,

but my experience in templated classes is limited.
Now, htis is the definition according to the lib's DOxygen breakdown:


template<class Real>
JAMA::Eigenvalue<Real>::Eigenvalue<Real> ( const TNT::Array2D<

Real >
& A ) [inline]



and I try to invoke it with:




TNT::Array2D<double> CovarMatrix(3,3,0.0);

//(Do stuff to Covar)

JAMA::Eigenvalue<double> EV(CovarMatrix);



but the compilers not having any of it. Could someone please expain the
above notation to me.

Many Thanks



Mike



Care to be a bit more specific? What is the error you are getting?





Visual Studio .Net 2003 tries to compile with the following errors:

Compiling...
BSPTCreator.cpp
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\jama\jama_eig.h(234) : error C2668: 'std::max' :
ambiguous call to overloaded function
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xutility(1242): could be 'const _Ty
&std::max said:
_Ty &,const _Ty &)'
with
[
_Ty=double,
Real=double
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\tnt_math_utils.h(43): or 'Scalar
TNT::max said:
Scalar &,const Scalar &)'
with
[
Scalar=double,
Real=double
]
while trying to match the argument list '(double, double)'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\Tnt\jama\jama_eig.h(215) : while compiling class-template
member function 'void JAMA::Eigenvalue<Real>::tql2(void)'
with
[
Real=double
]
c:\Documents and
Settings\Michael\Desktop\Ixium3D\BSPTCreator\BSPTCreator.cpp(181) : see
reference to class template instantiation 'JAMA::Eigenvalue<Real>' being
compiled
with
[
Real=double
]
Build Time 0:02
Build log was saved at "file://c:\Documents and
Settings\Michael\Desktop\Ixium3D\BSPTCreator\Debug\BuildLog.htm"
BSPTCreator - 1 error(s), 0 warning(s)

---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped

Let me guess. You're including <windows.h> as well, aren't you?
Microsoft has done the very evil thing of #define'ing min() and max().

In your project properties, add /DNOMINMAX, or in your stdafx.h file (as
the first non-cmment line) #define NOMINMAX

This suppresses the evil redefinition of min and max.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top