Template Nightmare

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael

    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::Eigenvalu e<Real>::Eigenv alue<Real> ( const TNT::Array2D< Real >
    & A ) [inline]



    and I try to invoke it with:




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

    //(Do stuff to Covar)

    JAMA::Eigenvalu e<double> EV(CovarMatrix) ;



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

    Many Thanks



    Mike


  • red floyd

    #2
    Re: Template Nightmare

    Michael wrote:[color=blue]
    > 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::Eigenvalu e<Real>::Eigenv alue<Real> ( const TNT::Array2D< Real >
    > & A ) [inline]
    >
    >
    >
    > and I try to invoke it with:
    >
    >
    >
    >
    > TNT::Array2D<do uble> CovarMatrix(3,3 ,0.0);
    >
    > //(Do stuff to Covar)
    >
    > JAMA::Eigenvalu e<double> EV(CovarMatrix) ;
    >
    >
    >
    > but the compilers not having any of it. Could someone please expain the
    > above notation to me.
    >
    > Many Thanks
    >
    >
    >
    > Mike
    >
    >[/color]

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

    Comment

    • Michael

      #3
      Re: Template Nightmare

      "red floyd" <no.spam@here.d ude> wrote in message
      news:fKSnc.4698 2$G16.5481@news svr29.news.prod igy.com...[color=blue]
      > Michael wrote:[color=green]
      > > Hi guys,
      > > I'm trying to use the JAMA libraries which are a templated set of[/color][/color]
      classes,[color=blue][color=green]
      > > but my experience in templated classes is limited.
      > > Now, htis is the definition according to the lib's DOxygen breakdown:
      > >
      > >
      > > template<class Real>
      > > JAMA::Eigenvalu e<Real>::Eigenv alue<Real> ( const TNT::Array2D<[/color][/color]
      Real >[color=blue][color=green]
      > > & A ) [inline]
      > >
      > >
      > >
      > > and I try to invoke it with:
      > >
      > >
      > >
      > >
      > > TNT::Array2D<do uble> CovarMatrix(3,3 ,0.0);
      > >
      > > //(Do stuff to Covar)
      > >
      > > JAMA::Eigenvalu e<double> EV(CovarMatrix) ;
      > >
      > >
      > >
      > > but the compilers not having any of it. Could someone please expain the
      > > above notation to me.
      > >
      > > Many Thanks
      > >
      > >
      > >
      > > Mike
      > >
      > >[/color]
      >
      > Care to be a bit more specific? What is the error you are getting?[/color]




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

      Compiling...
      BSPTCreator.cpp
      c:\Program Files\Microsoft Visual Studio .NET
      2003\Vc7\includ e\Tnt\jama\jama _eig.h(234) : error C2668: 'std::max' :
      ambiguous call to overloaded function
      c:\Program Files\Microsoft Visual Studio .NET
      2003\Vc7\includ e\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\includ e\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\includ e\Tnt\jama\jama _eig.h(215) : while compiling class-template
      member function 'void JAMA::Eigenvalu e<Real>::tql2(v oid)'
      with
      [
      Real=double
      ]
      c:\Documents and
      Settings\Michae l\Desktop\Ixium 3D\BSPTCreator\ BSPTCreator.cpp (181) : see
      reference to class template instantiation 'JAMA::Eigenval ue<Real>' being
      compiled
      with
      [
      Real=double
      ]
      Build Time 0:02
      Build log was saved at "file://c:\Documents and
      Settings\Michae l\Desktop\Ixium 3D\BSPTCreator\ Debug\BuildLog. htm"
      BSPTCreator - 1 error(s), 0 warning(s)

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


      Comment

      • Canonical Latin

        #4
        Re: Template Nightmare


        "Michael" <slick_mick_00@ hotmail.com> wrote in message
        news:c7p1o5$98k $1@sparta.btint ernet.com...[color=blue]
        > Compiling...
        > BSPTCreator.cpp
        > c:\Program Files\Microsoft Visual Studio .NET
        > ...
        > ---------------------- Done ----------------------
        > Build: 0 succeeded, 1 failed, 0 skipped[/color]

        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!


        Comment

        • red floyd

          #5
          Re: Template Nightmare

          Michael wrote:[color=blue]
          > "red floyd" <no.spam@here.d ude> wrote in message
          > news:fKSnc.4698 2$G16.5481@news svr29.news.prod igy.com...
          >[color=green]
          >>Michael wrote:
          >>[color=darkred]
          >>>Hi guys,
          >>>I'm trying to use the JAMA libraries which are a templated set of[/color][/color]
          >
          > classes,
          >[color=green][color=darkred]
          >>>but my experience in templated classes is limited.
          >>>Now, htis is the definition according to the lib's DOxygen breakdown:
          >>>
          >>>
          >>> template<class Real>
          >>> JAMA::Eigenvalu e<Real>::Eigenv alue<Real> ( const TNT::Array2D<[/color][/color]
          >
          > Real >
          >[color=green][color=darkred]
          >>>& A ) [inline]
          >>>
          >>>
          >>>
          >>>and I try to invoke it with:
          >>>
          >>>
          >>>
          >>>
          >>>TNT::Array2D <double> CovarMatrix(3,3 ,0.0);
          >>>
          >>>//(Do stuff to Covar)
          >>>
          >>>JAMA::Eigenv alue<double> EV(CovarMatrix) ;
          >>>
          >>>
          >>>
          >>>but the compilers not having any of it. Could someone please expain the
          >>>above notation to me.
          >>>
          >>>Many Thanks
          >>>
          >>>
          >>>
          >>>Mike
          >>>
          >>>[/color]
          >>
          >>Care to be a bit more specific? What is the error you are getting?[/color]
          >
          >
          >
          >
          >
          > Visual Studio .Net 2003 tries to compile with the following errors:
          >
          > Compiling...
          > BSPTCreator.cpp
          > c:\Program Files\Microsoft Visual Studio .NET
          > 2003\Vc7\includ e\Tnt\jama\jama _eig.h(234) : error C2668: 'std::max' :
          > ambiguous call to overloaded function
          > c:\Program Files\Microsoft Visual Studio .NET
          > 2003\Vc7\includ e\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\includ e\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\includ e\Tnt\jama\jama _eig.h(215) : while compiling class-template
          > member function 'void JAMA::Eigenvalu e<Real>::tql2(v oid)'
          > with
          > [
          > Real=double
          > ]
          > c:\Documents and
          > Settings\Michae l\Desktop\Ixium 3D\BSPTCreator\ BSPTCreator.cpp (181) : see
          > reference to class template instantiation 'JAMA::Eigenval ue<Real>' being
          > compiled
          > with
          > [
          > Real=double
          > ]
          > Build Time 0:02
          > Build log was saved at "file://c:\Documents and
          > Settings\Michae l\Desktop\Ixium 3D\BSPTCreator\ Debug\BuildLog. htm"
          > BSPTCreator - 1 error(s), 0 warning(s)
          >
          > ---------------------- Done ----------------------
          > Build: 0 succeeded, 1 failed, 0 skipped
          >
          >[/color]

          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.


          Comment

          • Michael

            #6
            Re: Template Nightmare

            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.spam@here.d ude> wrote in message
            news:YEVnc.6587 0$_G.39436@news svr25.news.prod igy.com...[color=blue]
            > Michael wrote:[color=green]
            > > "red floyd" <no.spam@here.d ude> wrote in message
            > > news:fKSnc.4698 2$G16.5481@news svr29.news.prod igy.com...
            > >[color=darkred]
            > >>Michael wrote:
            > >>
            > >>>Hi guys,
            > >>>I'm trying to use the JAMA libraries which are a templated set of[/color]
            > >
            > > classes,
            > >[color=darkred]
            > >>>but my experience in templated classes is limited.
            > >>>Now, htis is the definition according to the lib's DOxygen breakdown:
            > >>>
            > >>>
            > >>> template<class Real>
            > >>> JAMA::Eigenvalu e<Real>::Eigenv alue<Real> ( const TNT::Array2D<[/color]
            > >
            > > Real >
            > >[color=darkred]
            > >>>& A ) [inline]
            > >>>
            > >>>
            > >>>
            > >>>and I try to invoke it with:
            > >>>
            > >>>
            > >>>
            > >>>
            > >>>TNT::Array2D <double> CovarMatrix(3,3 ,0.0);
            > >>>
            > >>>//(Do stuff to Covar)
            > >>>
            > >>>JAMA::Eigenv alue<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?[/color]
            > >
            > >
            > >
            > >
            > >
            > > Visual Studio .Net 2003 tries to compile with the following errors:
            > >
            > > Compiling...
            > > BSPTCreator.cpp
            > > c:\Program Files\Microsoft Visual Studio .NET
            > > 2003\Vc7\includ e\Tnt\jama\jama _eig.h(234) : error C2668: 'std::max' :
            > > ambiguous call to overloaded function
            > > c:\Program Files\Microsoft Visual Studio .NET
            > > 2003\Vc7\includ e\xutility(1242 ): could be 'const _Ty[/color][/color]
            &std::max<Real> (const[color=blue][color=green]
            > > _Ty &,const _Ty &)'
            > > with
            > > [
            > > _Ty=double,
            > > Real=double
            > > ]
            > > c:\Program Files\Microsoft Visual Studio .NET
            > > 2003\Vc7\includ e\Tnt\tnt_math_ utils.h(43): or 'Scalar[/color][/color]
            TNT::max<Real>( const[color=blue][color=green]
            > > 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\includ e\Tnt\jama\jama _eig.h(215) : while compiling[/color][/color]
            class-template[color=blue][color=green]
            > > member function 'void JAMA::Eigenvalu e<Real>::tql2(v oid)'
            > > with
            > > [
            > > Real=double
            > > ]
            > > c:\Documents and
            > > Settings\Michae l\Desktop\Ixium 3D\BSPTCreator\ BSPTCreator.cpp (181) : see
            > > reference to class template instantiation 'JAMA::Eigenval ue<Real>' being
            > > compiled
            > > with
            > > [
            > > Real=double
            > > ]
            > > Build Time 0:02
            > > Build log was saved at "file://c:\Documents and
            > > Settings\Michae l\Desktop\Ixium 3D\BSPTCreator\ Debug\BuildLog. htm"
            > > BSPTCreator - 1 error(s), 0 warning(s)
            > >
            > > ---------------------- Done ----------------------
            > > Build: 0 succeeded, 1 failed, 0 skipped
            > >
            > >[/color]
            >
            > 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.
            >
            >[/color]


            Comment

            Working...