473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Template Nightmare

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
Jul 22 '05 #1
5 2616
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?
Jul 22 '05 #2
"red floyd" <no*****@here.dude> wrote in message
news:fK******************@newssvr29.news.prodigy.c om...
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<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\BSPTC reator.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
Jul 22 '05 #3

"Michael" <sl***********@hotmail.com> wrote in message
news:c7**********@sparta.btinternet.com...
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!
Jul 22 '05 #4
Michael wrote:
"red floyd" <no*****@here.dude> wrote in message
news:fK******************@newssvr29.news.prodigy.c om...
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<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\BSPTC reator.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.
Jul 22 '05 #5
Many thnaks guys, I'm back in business.. it was the "using namespace std"
that it didn't like so much!
Mike
"red floyd" <no*****@here.dude> wrote in message
news:YE******************@newssvr25.news.prodigy.c om...
Michael wrote:
"red floyd" <no*****@here.dude> wrote in message
news:fK******************@newssvr29.news.prodigy.c om...
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<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\BSPTC reator.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.

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: yooyoo | last post by:
I am implementing print template solution. I would like to use it in asp app. I open new document then generate print preview then print and finally close preview window, but I am not able to close...
7
by: Lionel B | last post by:
Greetings. The following code compiles ok and does what I'd expect it to do: ---------- START CODE ---------- // test.cpp
0
by: gao_bolin | last post by:
I have a library that has a class Signal<T> whose data type is templated. The class comes with a whole bunch of functions and objects to do various processing on the signal. What I would like to...
6
by: Stuart McGraw | last post by:
I am looking for a VBA "format" or "template" function, that is, a function that takes a format string and a varying number of arguments, and substitutes the argument values into the format string...
5
by: christian | last post by:
Hi! I have a problem with a template function im MSVC6 the template function is defined as: template <__Type1, __Type2> int MyFunc(int param1, double param2) {__Type1 var1; __Type2 var2; ...
12
by: bryan | last post by:
I've posted before but no one replied because I think it was confusing. My problem is that I have a website where users have profile pages, and they can each chooser their own (i.e. blogger.com)...
15
by: Nick Keighley | last post by:
Hi, I found this in code I was maintaining template <class SingletonClass> SingletonClass* Singleton<SingletonClass>::instance () { static SingletonClass _instance; return &_instance; }
4
by: shuisheng | last post by:
Dear All, I want to get a array template like Array<class T, size_t n0, size_t n1, size_t n2 ...> The dimension can be arbitrary. Is it possible? Thanks for your help.
1
by: unkstar | last post by:
I've written a extentable_buffer class, which allows me to acquire bigger buffer whenever I need. The original version has a conversion operator to void*, it's enought for that good old time....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.