[QVM] Help with small example
I am trying to run boost::qvm on my machine. I am using MS Visual Studio
2013 with Boost 1.59 as the backend.
#include
On Wed, Dec 9, 2015 at 5:13 PM, Rajaditya Mukherjee < rajaditya.mukherjee@gmail.com> wrote:
I am trying to run boost::qvm on my machine. I am using MS Visual Studio 2013 with Boost 1.59 as the backend.
#include
#include <iostream> class float4 { public: float4(float a, float b, float c, float d) { container[0] = a; container[1] = b; container[2] = c; container[3] = d; } float container[4]; };
namespace boost { namespace qvm { template<> struct v_traits<float4> { static int const dim = 3; typedef float scalar_type;
template <int I> static inline scalar_type &w(float4 & v) { return v.container[I]; } template <int I> static inline scalar_type r(float4 const & v) { return v.container[I]; }
static inline scalar_type &iw(int i, float4 &v) { return v.container[i]; } static inline scalar_type ir(int i, float4 const & v) { return v.container[i]; } }; } }
int main() { float4 vec(11.0,0.0,5.0,-6.0); std::cout << boost::qvm::mag(vec); (vec,boost::qvm::A<1>) = 112.0; std::cout << boost::qvm::mag(vec); }
In the line *(vec,boost::qvm::A<1>) = 112.0, *I am getting an compiler error that says
error C2563: mismatch in formal parameter list error C2568: ',' : unable to resolve function overload 1> d:\dropbox\programs\boost_qvm\include\boost\qvm\v_access.hpp(79): could be 'boost::qvm::vector_access_tag<I> boost::qvm::A(void)' 1> d:\dropbox\programs\boost_qvm\include\boost\qvm\m_access.hpp(78): or 'boost::qvm::matrix_access_tag
boost::qvm::A(void)' Any help ? Maybe I am doing something stupid ? Any help by Emil or anyone else is appreciated.
You're doing everything right, and I actually know about this issue. It's a bug in MSVC, I suspect a parsing bug related to incorrectly interpreting < as less than. This is not a problem in other compilers, as far as I am aware. For MSVC, the workaround if you need A<N> is to use parentheses like so: (vec,boost::qvm::A<1>()) (In this particular case you could also use (vec,boost::qvm::A1) which doesn't require the workaround.) By the way, generally it's safe to put using namespace boost::qvm in global scope rather than qualifying identifiers because the function overloads defined by QVM use SFINAE to "disappear" unless used with types properly registered to QVM. Thank you! Emil
Thanks Emil for your prompt response. I was wondering if I can use an
Eigen::Vector class instead of float array. Rather my question is : "is
there any restriction on the container class that I can use with v_traits
type???"
*Rajaditya Mukherjee *
*3rd Year Graduate Student*
Dept. of Computer Science and Engineering
The Ohio State University
Columbus, Ohio
Tel :- +1-(614)-271-4439
email :- rajaditya.mukherjee@gmail.com
On Wed, Dec 9, 2015 at 6:03 PM, Emil Dotchevski
wrote: (vec,boost::qvm::A<1>())
(In this particular case you could also use (vec,boost::qvm::A1) which doesn't require the workaround.)
Better yet, (vec,Y).
Emil
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On Thu, Dec 10, 2015 at 6:35 AM, Rajaditya Mukherjee < rajaditya.mukherjee@gmail.com> wrote:
Thanks Emil for your prompt response. I was wondering if I can use an Eigen::Vector class instead of float array. Rather my question is : "is there any restriction on the container class that I can use with v_traits type???"
No, there isn't, though keep in mind that QVM does not support dynamically sized objects. Yes you should be able to use Eigen vectors, in fact this is the main design goal of QVM: to let users bring together various QVM types in a single, coherent, type-safe environment. In fact it would probably make sense to include QVM headers to introduce quaternion, vector and matrix types from various other libraries. Thanks! Emil
participants (3)
-
Emil Dotchevski
-
Emil Dotchevski
-
Rajaditya Mukherjee