Skip to content

Commit

Permalink
Adding qvm and timer (closes #84 #97)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Dec 17, 2023
1 parent 6fb6933 commit 62214a2
Show file tree
Hide file tree
Showing 39 changed files with 36,626 additions and 0 deletions.
11 changes: 11 additions & 0 deletions inst/include/boost/qvm.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef BOOST_QVM_HPP_INCLUDED
#define BOOST_QVM_HPP_INCLUDED

// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.

// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/qvm/all.hpp>

#endif
7 changes: 7 additions & 0 deletions inst/include/boost/qvm/all.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.

// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/qvm/lite.hpp>
#include <boost/qvm/swizzle.hpp>
94 changes: 94 additions & 0 deletions inst/include/boost/qvm/deduce_quat.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#ifndef BOOST_QVM_DEDUCE_QUAT_HPP_INCLUDED
#define BOOST_QVM_DEDUCE_QUAT_HPP_INCLUDED

// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.

// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/qvm/deduce_scalar.hpp>
#include <boost/qvm/quat_traits.hpp>
#include <boost/qvm/static_assert.hpp>

namespace boost { namespace qvm {

template <class T>
struct quat;

namespace
qvm_detail
{
template <class Q,class S,
class QS=typename quat_traits<Q>::scalar_type>
struct
deduce_q_default
{
BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
typedef quat<typename quat_traits<Q>::scalar_type> type;
};

template <class Q,class S>
struct
deduce_q_default<Q,S,S>
{
BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
typedef Q type;
};
}

template <class Q,class S=typename quat_traits<Q>::scalar_type>
struct
deduce_quat
{
BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
typedef typename qvm_detail::deduce_q_default<Q,S>::type type;
};

namespace
qvm_detail
{
template <class A,class B,class S,
bool IsScalarA=is_scalar<A>::value,
bool IsScalarB=is_scalar<B>::value>
struct
deduce_q2_default
{
typedef quat<S> type;
};

template <class Q,class S>
struct
deduce_q2_default<Q,Q,S,false,false>
{
BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
typedef Q type;
};

template <class A,class B,class S>
struct
deduce_q2_default<A,B,S,false,true>
{
BOOST_QVM_STATIC_ASSERT(is_quat<A>::value);
typedef typename deduce_quat<A,S>::type type;
};

template <class A,class B,class S>
struct
deduce_q2_default<A,B,S,true,false>
{
BOOST_QVM_STATIC_ASSERT(is_quat<B>::value);
typedef typename deduce_quat<B,S>::type type;
};
}

template <class A,class B,class S=typename deduce_scalar<typename scalar<A>::type,typename scalar<B>::type>::type>
struct
deduce_quat2
{
BOOST_QVM_STATIC_ASSERT(is_quat<A>::value || is_quat<B>::value);
typedef typename qvm_detail::deduce_q2_default<A,B,S>::type type;
};

} }

#endif
31 changes: 31 additions & 0 deletions inst/include/boost/qvm/detail/quat_assign.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef BOOST_QVM_DETAIL_QUAT_ASSIGN_HPP_INCLUDED
#define BOOST_QVM_DETAIL_QUAT_ASSIGN_HPP_INCLUDED

// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.

// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/qvm/config.hpp>
#include <boost/qvm/enable_if.hpp>
#include <boost/qvm/quat_traits.hpp>

namespace boost { namespace qvm {

template <class A,class B>
BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
typename enable_if_c<
is_quat<A>::value && is_quat<B>::value,
A &>::type
assign( A & a, B const & b )
{
write_quat_element<0>(a,quat_traits<B>::template read_element<0>(b));
write_quat_element<1>(a,quat_traits<B>::template read_element<1>(b));
write_quat_element<2>(a,quat_traits<B>::template read_element<2>(b));
write_quat_element<3>(a,quat_traits<B>::template read_element<3>(b));
return a;
}

} }

#endif
Loading

0 comments on commit 62214a2

Please sign in to comment.