Ambiguous call again

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

    #16
    Re: Ambiguous call again

    Oh, sorry, VC2008 here.

    Comment

    • Anna Smidt

      #17
      Re: Ambiguous call again

      Yes, it works for me.

      But I don't know what else I could provide but the code below.
      As far as I understand it, MatView Mat::viewAsSqua re() requires code
      from "all.hpp", right?
      Should I post the code from "all.hpp"?
      Anna

      #include "all.hpp"

      static const bool USE_EQ_DOUBLES = true; // 1 to for match within
      tolerance
      static const char *MAT_PRINT_FORM AT = "%8.4f "; // default mat print format

      namespace GslMat

      //-----------------------------------------------------------------------------
      MatView Mat::viewAsSqua re ()
      {
      // size_t ncols = size_t(sqrt(thi s->nelems()));
      size_t ncols = static_cast< size_t >( sqrt( this->nelems() ) );
      // check that can square properly (assertion is not essential but
      protects the user)
      ASSERT(ncols * ncols == this->nelems());
      return MatView(*this, 0, 0, ncols, ncols, ncols);
      }

      Comment

      • David Wilkinson

        #18
        Re: Ambiguous call again

        Anna Smidt wrote:
        Oh, sorry, VC2008 here.
        Anna:

        And what about a complete compilable example?

        When you provide a sample that depends on stuff not present in the sample, then
        it is not possible to test your code as given, so the responder has to create a
        compilable example which might (for some unknown reason) not exhibit the problem.

        If you create the self-contained example yourself, and post that, then everybody
        can be on the same page. But very often, the exercise of creating a
        self-contained example will allow you to solve the problem for yourself.

        --
        David Wilkinson
        Visual C++ MVP

        Comment

        • David Wilkinson

          #19
          Re: Ambiguous call again

          Anna Smidt wrote:
          Yes, it works for me.
          >
          But I don't know what else I could provide but the code below.
          As far as I understand it, MatView Mat::viewAsSqua re() requires code
          from "all.hpp", right?
          Should I post the code from "all.hpp"?
          Anna
          >
          #include "all.hpp"
          >
          static const bool USE_EQ_DOUBLES = true; // 1 to for match within
          tolerance
          static const char *MAT_PRINT_FORM AT = "%8.4f "; // default mat print
          format
          >
          namespace GslMat
          >
          //-----------------------------------------------------------------------------
          >
          MatView Mat::viewAsSqua re ()
          {
          // size_t ncols = size_t(sqrt(thi s->nelems()));
          size_t ncols = static_cast< size_t >( sqrt( this->nelems() ) );
          // check that can square properly (assertion is not essential but
          protects the user)
          ASSERT(ncols * ncols == this->nelems());
          return MatView(*this, 0, 0, ncols, ncols, ncols);
          }
          Anna:

          If my simpler example works for you, the it is really up to *you* to figure out
          what is between the simple example and your code. We cannot do that because we
          do not have the code.

          But since your code is at namespace and class scope, perhaps you have done
          something to redefine size_t in this scope.

          What happens if you do

          ::size_t ncols = static_cast< ::size_t >( sqrt( this->nelems() ) );

          ?

          By the way, why are you not getting the ambiguous call on the sqrt here? What is
          the type of this->nelems?

          --
          David Wilkinson
          Visual C++ MVP

          Comment

          • Anna Smidt

            #20
            Re: Ambiguous call again

            Thank god, the constructor error is gone!! Thanks very much!
            By the way, why are you not getting the ambiguous call on the sqrt here?
            I do get the ambiguous call error in the line you suggested:
            Error 6 error C2668: 'sqrt' : ambiguous call to overloaded function
            cmat.cpp 1101 ASMModel

            Now this is one of the last bugs remaining.
            What is the type of this->nelems?
            I don't know, the code is so huge and I am so newbie to C++ that I have
            not yet been able to figure out where nelems originates from.

            Anna

            Comment

            • Giovanni Dicanio

              #21
              Re: Ambiguous call again


              "Bo Persson" <bop@gmb.dkha scritto nel messaggio
              news:6mgct9Fgnk tjU1@mid.indivi dual.net...
              Because some people believe that it makes to code easier to read.
              >
              They are wrong. :-)
              :-)

              So, I just think that readability is a matter of personal preference... :)

              <latin>De gustibus non disputandum est.</latin>

              Giovanni



              Comment

              • Giovanni Dicanio

                #22
                Re: Ambiguous call again


                "Anna Smidt" <a.smidt@nospam gmail.comha scritto nel messaggio
                news:OQ7He8oNJH A.4928@TK2MSFTN GP05.phx.gbl...
                >Try:
                >>
                > size_t ncols = static_cast< size_t >( sqrt( this->nelems() ) );
                >>
                >Giovanni
                >
                This doesn't help.
                OK, so I think that there is some problem with nelems() return value, as
                David W. already pointed out.

                You should post the prototype of nelems() method.

                Giovanni



                Comment

                • Giovanni Dicanio

                  #23
                  Re: Ambiguous call again


                  "Anna Smidt" <a.smidt@nospam gmail.comha scritto nel messaggio
                  news:%23jSGA9qN JHA.1172@TK2MSF TNGP03.phx.gbl. ..
                  Thank god, the constructor error is gone!! Thanks very much!
                  >
                  >By the way, why are you not getting the ambiguous call on the sqrt here?
                  I do get the ambiguous call error in the line you suggested:
                  Error 6 error C2668: 'sqrt' : ambiguous call to overloaded function
                  cmat.cpp 1101 ASMModel
                  You may try using ::sqrt() or std::sqrt() instead.

                  Giovanni


                  Comment

                  • Anna Smidt

                    #24
                    Re: Ambiguous call again

                    Until I know better, I will use double() to resolve the problem. When I
                    know more C++, I will find out if that's correct or if I have to use a
                    different conversion.

                    Comment

                    • Giovanni Dicanio

                      #25
                      Re: Ambiguous call again


                      "Anna Smidt" <a.smidt@nospam gmail.comha scritto nel messaggio
                      news:%23jSGA9qN JHA.1172@TK2MSF TNGP03.phx.gbl. ..
                      >What is the type of this->nelems?
                      I don't know, the code is so huge and I am so newbie to C++ that I have
                      not yet been able to figure out where nelems originates from.
                      I would suggest you to use Visual Assist X from Wholetomato:

                      Visual Assist is a Visual Studio extension - a productivity tool for refactoring, reading, writing, navigating and generating C / C++ / C# code.


                      There is a trial download available.

                      Your coding productivity will increase a lot thanks to VAX.

                      In this particular case, you can put the cursor on nelems() and press
                      CTRL+G, and you will be sent to the definition of that method.

                      Giovanni



                      Comment

                      • Anna Smidt

                        #26
                        Re: Ambiguous call again

                        I am not sure if I have found out correctly:

                        MatView (double other[], size_t nelems, char *sIsRowVec=NULL ): Mat()
                        {
                        sIsRowVec? init(other, 0, 0, 1, nelems, 1): init(other, 0, 0, nelems, 1);
                        }


                        Does this tell me what type of nelems are?
                        Anna

                        Comment

                        • David Wilkinson

                          #27
                          Re: Ambiguous call again

                          Anna Smidt wrote:
                          Thank god, the constructor error is gone!! Thanks very much!
                          >
                          >By the way, why are you not getting the ambiguous call on the sqrt here?
                          I do get the ambiguous call error in the line you suggested:
                          Error 6 error C2668: 'sqrt' : ambiguous call to overloaded
                          function cmat.cpp 1101 ASMModel
                          >
                          Now this is one of the last bugs remaining.
                          >
                          >What is the type of this->nelems?
                          I don't know, the code is so huge and I am so newbie to C++ that I have
                          not yet been able to figure out where nelems originates from.
                          Anna:

                          1. Clearly nelems() is a method of the class Mat; can you not find it in the
                          class definition? Do a Visual Studio search for it if you do not see it.

                          2. However, it seems to me that nelems() must return the number of elements of
                          the matrix (i.e. nrows*ncols). Taking the square root can only make sense if the
                          matrix is square (nrows == ncols), in which case why not just use nrows or ncols?

                          By the way, next time you start a new thread you should use the group

                          microsoft.publi c.vc.language

                          The group you are using (microsoft.publ ic.dotnet.langu ages.vc) is intended for
                          the C++/CLI language which targets the .NET platform (and which you are not using).

                          --
                          David Wilkinson
                          Visual C++ MVP

                          Comment

                          • Giovanni Dicanio

                            #28
                            Re: Ambiguous call again


                            "Bo Persson" <bop@gmb.dkha scritto nel messaggio
                            news:6mgct9Fgnk tjU1@mid.indivi dual.net...
                            Anna Smidt wrote:
                            >Oh, I have a question before I go to bed:
                            >>
                            >double hypotenuse = sqrt( square(p.y - q.y) + square(p.x - q.x) );
                            >>
                            >Why is there a space after "sqrt(" and before the last ")"?
                            >
                            Because some people believe that it makes to code easier to read.
                            >
                            They are wrong. :-)
                            It seems that Google C++ style guide agress with you, too :)



                            Giovanni




                            Comment

                            • Giovanni Dicanio

                              #29
                              Re: Ambiguous call again


                              "Anna Smidt" <a.smidt@nospam gmail.comha scritto nel messaggio
                              news:uad5kGrNJH A.4928@TK2MSFTN GP05.phx.gbl...
                              >I am not sure if I have found out correctly:
                              >
                              MatView (double other[], size_t nelems, char *sIsRowVec=NULL ): Mat()
                              {
                              sIsRowVec? init(other, 0, 0, 1, nelems, 1): init(other, 0, 0, nelems, 1);
                              }
                              >
                              >
                              Does this tell me what type of nelems are?
                              No.

                              You posted this code:
                              MatView Mat::viewAsSqua re ()
                              {
                              size_t ncols = size_t(sqrt(thi s->nelems()));
                              so: nelems() should be a member function of Mat class or some class from
                              which Mat class is derived.

                              Giovanni


                              Comment

                              • David Wilkinson

                                #30
                                Re: Ambiguous call again

                                Anna Smidt wrote:
                                I am not sure if I have found out correctly:
                                >
                                MatView (double other[], size_t nelems, char *sIsRowVec=NULL ): Mat()
                                {
                                sIsRowVec? init(other, 0, 0, 1, nelems, 1): init(other, 0, 0,
                                nelems, 1);
                                }
                                >
                                >
                                Does this tell me what type of nelems are?
                                Anna:

                                No. This nelems is just a dummy variable name. The nelems in your expression is
                                a method, as you can tell from the parentheses on this->nelems().

                                Anna, you seem a little out of your depth:

                                Math-wise
                                C++-wise
                                Visual Studio-wise

                                What are you trying to do exactly? It seems that you are trying to use an
                                external library that does not appear to be written very well. This is not an
                                easy thing to do. Maybe you should be tackling something simpler?

                                --
                                David Wilkinson
                                Visual C++ MVP

                                Comment

                                Working...