Thread: no match for overloaded operator

  1. #16
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Bravo!Had thought of it,but before you posted your idea of overloading the function.So i did that to the only version of the function ,so it did not work.
    Bravo again to iMalc and Jim who had the patience to look the problem.ΜΠΡΑΒΟ!!!!

  2. #17
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    The other methods that do not alter members should also be `const'.

    Look at `inverse' for example, it does not mutate data members and so may as well be `const' for the benefit it brings.

    By the by, can you explain to me how the `double& Matrix4d:perator() (int, int, int = 0)' API works?

    What I mean is, can you provide documentation for that function?

    I'm asking because, from my understanding, it is broken as you are relying on client code to keep related data in sync for no reason.

    Soma

  3. #18
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Soma excuse me but i do not fully understand what you want to point out :/

  4. #19
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    excuse me but i do not fully understand what you want to point out
    O_o

    I may not be pointing out anything; as I said, can you provide documentation for the relevant function?

    How would I, writing code as a client of your implementation, use the `double& Matrix4d:perator() (int, int, int = 0)' function?

    Can you give me an example of using the class correctly relevant to that method?

    Code:
    4 3
    3 2
    If I want to represent that matrix and its associated inversion, how would I go about that with code?

    Soma

  5. #20
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    You poor soul. You're designing a matrix class in C++: Armadillo: C++ linear algebra library

  6. #21
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Soma the class is about 4by4 arrays and not 2by2.I have written this above the function .You read it and you find it incomplete or confusing?
    Code:
       /*
        * write,read the matrix element at i,j:
        * element of the matrix when no third parameter is specified
        * the element at [i,j] in the inverse matrix otherwise
        */
    So if i need element i,j from the normal array M i would go for this
    Code:
    M(i,j)
    where if i wanted the i.j element from M^(-1) array i would go for this
    Code:
    M(i,j,-1)
    probably should change it to bool as iMalc stated.
    If you find that overloaded () not a must i would agree with you.I wouldn't overloaded them if my partner wouldn't aks for it.Maybe it has to do with whiteflags said.He knows matlab and i do not so i did not think of it.Also i do not the the armadillo library so thanks whiteflags.You recommend using it at the future?
    So why i use the overloaded parenthesis in my code?To test them more before the the other guy use it

  7. #22
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    You recommend using it at the future?
    Might as well, if the LGPL doesn't present some sort of problem.

  8. #23
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Thank you withiflags for the advice.Very kind of you

  9. #24
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Soma the class is about 4by4 arrays and not 2by2.
    Okay. Fine. Choose a 4x4 matrix and post such code as I've requested.

    Or don't. I've stopped caring. This is the last I'll say about this issue.

    You read it and you find it incomplete or confusing?
    I'm trying to get you to see the problem for yourself. I'm very aware of the code's mechanical problems.

    You have not seen the problem; I assume, probably correctly, that you haven't seen the problem because you haven't explored the implementation from the mindset of a client.

    Soma

  10. #25
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Well what might be obvious to you with so much experience might be not obvious at all for a guy that started programming at 2010(after summer).Anyway let's end this here.I posted the code to access element of the normal and the inverse function.

  11. #26
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Quote Originally Posted by iMalc View Post
    You missed the fact that, as I showed, the const version returns by value, not by reference.
    I decided to go by this prototype at last
    Code:
    const double& operator() (int i, int j, int invFlag = 0) const
    Thank you again for your help

  12. #27
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Well what might be obvious to you with so much experience might be not obvious at all for a guy that started programming at 2010(after summer).
    Which should explain to you why I didn't just post code.

    I was trying to get you to see any faults for yourself so that you could more ably apply what you would learn from exploring those faults in the future.

    Soma

  13. #28
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by std10093 View Post
    I decided to go by this prototype at last
    Code:
    const double& operator() (int i, int j, int invFlag = 0) const
    Thank you again for your help
    Yes that will also work, though most people tend to pass/return built-in types by value, as this has typically generated faster code.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. no match for operator>> !?
    By Spyser in forum C++ Programming
    Replies: 2
    Last Post: 02-21-2012, 08:00 AM
  2. best Overloaded match for method ...
    By deathkosui in forum C# Programming
    Replies: 8
    Last Post: 11-05-2009, 11:23 PM
  3. no match for 'operator>>'
    By Taka in forum C++ Programming
    Replies: 3
    Last Post: 03-30-2009, 12:17 AM
  4. Replies: 3
    Last Post: 12-09-2008, 11:19 AM
  5. no match for operator << ??
    By neoragexxx in forum C++ Programming
    Replies: 6
    Last Post: 05-01-2006, 05:02 PM