Opened 12 years ago

Closed 12 years ago

#5369 closed Bugs (fixed)

quaternion/octonion pow() not working

Reported by: Eduardo de Mattos Kalinowski <eduardo@…> Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost 1.46.0 Severity: Problem
Keywords: Cc:

Description

The pow() functions for quaternions/octonions do not work as they call quaternion<T>(1) instead of quaternion<T>(T(1)).

The attached patches fixes this.

Attachments (3)

quat.patch (511 bytes ) - added by Eduardo de Mattos Kalinowski <eduardo@…> 12 years ago.
Patch for quaternion.hpp
oc.patch (499 bytes ) - added by Eduardo de Mattos Kalinowski <eduardo@…> 12 years ago.
Patch for octonion.hpp
testpow.cpp (1.0 KB ) - added by Eduardo de Mattos Kalinowski <eduardo@…> 12 years ago.
Test showing multiple levels of indirection

Download all attachments as: .zip

Change History (6)

by Eduardo de Mattos Kalinowski <eduardo@…>, 12 years ago

Attachment: quat.patch added

Patch for quaternion.hpp

by Eduardo de Mattos Kalinowski <eduardo@…>, 12 years ago

Attachment: oc.patch added

Patch for octonion.hpp

comment:1 by John Maddock, 12 years ago

Works for me - what compiler are you using, and do you have a test case please?

Note that quaternion<T>(1) and quaternion<T>(T(1)) should be exactly equivalent as in the former case the argument will be promoted to T anyway.

comment:2 by Eduardo de Mattos Kalinowski <eduardo@…>, 12 years ago

g++ 4.5.2

For simple types it works, but if there are multiple levels of indirection, it does not. The attached example shows that. A quaternion<Wrapper<int> > works, a quaternion<Wrapper<Wrapper<int> > > does not.

Of course that example is somewhat silly, but I stumbled across this in a case where I do have more than one level of indirection - and not of the same class, naturally.

by Eduardo de Mattos Kalinowski <eduardo@…>, 12 years ago

Attachment: testpow.cpp added

Test showing multiple levels of indirection

comment:3 by John Maddock, 12 years ago

Resolution: fixed
Status: newclosed

(In [70569]) Cast arguments to quaternion/octonion constructors so they still work when there's no implicit conversion available. Fixes #5369.

Note: See TracTickets for help on using tickets.