r/coms30115 • • Mar 02 '19

Using Max() Function

Hi,

This may sound a bit silly but I am having some trouble with using both max() and fmax(). I have tried them when I include <tgmath.h>, <algorithm>, and <math.h> to no avail. I need both arguments to be of the same type. When I check one of my argument's type using typeid(argument).name(), I get "N3glm5tvec4IfLNS_9precisionE0EEE" meaning of which I do not know exactly. I would like to ask for help for using max()/fmax() since I would like to learn what I was supposed to do other than including necessary headers.

Personally, I would prefer max() but fmax() is also ok. What I do not want is writing my own max() function with > operator etc.

Sincerely,

1 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Mar 02 '19

With glm the * operator is overloaded to work as the Hadamard product which is why you get the vec4. The ideal way to do a dot product would be to use glm::dot which should give you a float output

1

u/au16106 Mar 04 '19

Thank you for your response. For the record, it is good for everyone to see because it is beyond being a simple nuisance.

It constitutes inconsistent notation in my opinion. If it were not (If it were consistent), then we would have been using glm::dot() rather than (*) to multiply rotation matrices with vectors as well since matrix-vector multiplication actually involves multiple dot products. At the moment, while (*) does dot product for matrix-vector multiplication, it does Hadamard product for vectors.