text:
#ifndef VPYTHON_SIMPLE_DISPLAYOBJECT_HPP
#define VPYTHON_SIMPLE_DISPLAYOBJECT_HPP

// Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others.
// Copyright (c) 2003, 2004 by Jonathan Brandmeyer and others.
// See the file license.txt for complete license terms.
// See the file authors.txt for a complete list of contributors.

#include "renderable.hpp"
#include "util/tmatrix.hpp"

#include <typeinfo>

#include <boost/python/object.hpp>

namespace cvisual {

using boost::python::object;

// All primitive subclasses should use this pair of macros to help with standard
// error messages.  This allows functions to use the exact name of a virtual class.
#define PRIMITIVE_TYPEINFO_DECL virtual const std::type_info& get_typeid() const
#define PRIMITIVE_TYPEINFO_IMPL(base) \
	const std::type_info& \
	base::get_typeid() const \
	{ return typeid(*this); }

class primitive : public renderable
{
 protected:
	// The position and orientation of the body in World space.
	shared_vector axis;
	shared_vector up;
	shared_vector pos;

	bool make_trail, trail_initialized, obj_initialized;
	boost::python::object primitive_object;

	// Returns a tmatrix that performs reorientation of the object from model
	// orientation to world (and view) orientation.
	tmatrix model_world_transform( double world_scale = 0.0, const vector& object_scale = vector(1,1,1) ) const;

	// Generate a displayobject at the origin, with up pointing along +y and
	// an axis = vector(1, 0, 0).
	primitive();
	primitive( const primitive& other);

	// See above for PRIMITIVE_TYPEINFO_DECL/IMPL.
	virtual const std::type_info& get_typeid() const;

	// Used when obtaining the center of the body.
	virtual vector get_center() const;

 public:
	virtual ~primitive();

	// Manually overload this member since the default arguments are variables.
    void rotate( double angle, const vector& axis, const vector& origin);

	void set_pos( const vector& n_pos);
	shared_vector& get_pos();

	void set_x( double x);
	double get_x();

	void set_y( double y);
	double get_y();

	void set_z( double z);
	double get_z();

	void set_axis( const vector& n_axis);
	shared_vector& get_axis();

	void set_up( const vector& n_up);
	shared_vector& get_up();

	void set_color( const rgb& n_color);
	rgb get_color();

	void set_red( float x);
	double get_red();

	void set_green( float x);
	double get_green();

	void set_blue( float x);
	double get_blue();

	void set_opacity( float x);
	double get_opacity();

	void set_make_trail( bool x);
	bool get_make_trail();

	void set_primitive_object( boost::python::object x);
	boost::python::object get_primitive_object();
};

} // !namespace cvisual

#endif // !defined VPYTHON_SIMPLE_DISPLAYOBJECT_HPP

max_stars_repo_name: lebarsfa/vpython-wx

max_issues_repo_name: lebarsfa/vpython-wx

max_forks_repo_name: lebarsfa/vpython-wx


text:
/*=============================================================================
    Copyright (c) 2001-2008 Joel de Guzman
    Copyright (c) 2001-2003 Daniel Nuffer
    http://spirit.sourceforge.net/

  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)
=============================================================================*/
#ifndef BOOST_SPIRIT_BASIC_CHSET_APRIL_17_2008
#define BOOST_SPIRIT_BASIC_CHSET_APRIL_17_2008

///////////////////////////////////////////////////////////////////////////////
#include <bitset>
#include <climits>
#include <boost/spirit/home/qi/char/detail/range_run.hpp>

namespace boost { namespace spirit { namespace qi { namespace detail
{
    ///////////////////////////////////////////////////////////////////////////
    //
    //  basic_chset: basic character set implementation using range_run
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename Char>
    struct basic_chset
    {
        basic_chset() {}
        basic_chset(basic_chset const& arg_)
          : rr(arg_.rr) {}

        bool
        test(Char v) const
        {
            return rr.test(v);
        }

        void
        set(Char from, Char to)
        {
            rr.set(range<Char>(from, to));
        }

        void
        set(Char c)
        {
            rr.set(range<Char>(c, c));
        }

        void
        clear(Char from, Char to)
        {
            rr.clear(range<Char>(from, to));
        }

        void
        clear(Char c)
        {
            rr.clear(range<Char>(c, c));
        }

        void
        clear()
        {
            rr.clear();
        }

        void
        inverse()
        {
            basic_chset inv;
            inv.set(
                (std::numeric_limits<Char>::min)(),
                (std::numeric_limits<Char>::max)()
            );
            inv -= *this;
            swap(inv);
        }

        void
        swap(basic_chset& x)
        {
            rr.swap(x.rr);
        }

        basic_chset&
        operator|=(basic_chset const& x)
        {
            typedef typename range_run<Char>::const_iterator const_iterator;
            for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
                rr.set(*iter);
            return *this;
        }

        basic_chset&
        operator&=(basic_chset const& x)
        {
            basic_chset inv;
            inv.set(
                (std::numeric_limits<Char>::min)(),
                (std::numeric_limits<Char>::max)()
            );
            inv -= x;
            *this -= inv;
            return *this;
        }

        basic_chset&
        operator-=(basic_chset const& x)
        {
            typedef typename range_run<Char>::const_iterator const_iterator;
            for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
                rr.clear(*iter);
            return *this;
        }

        basic_chset&
        operator^=(basic_chset const& x)
        {
            basic_chset bma = x;
            bma -= *this;
            *this -= x;
            *this |= bma;
            return *this;
        }

        private: range_run<Char> rr;
    };

#if (CHAR_BIT == 8)

    ///////////////////////////////////////////////////////////////////////////
    //
    //  basic_chset: specializations for 8 bit chars using std::bitset
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename Char>
    struct basic_chset_8bit
    {
        basic_chset_8bit() {}
        basic_chset_8bit(basic_chset_8bit const& arg_)
          : bset(arg_.bset) {}

        bool
        test(Char v) const
        {
            return bset.test((unsigned char)v);
        }

        void
        set(Char from, Char to)
        {
            for (int i = from; i <= to; ++i)
                bset.set((unsigned char)i);
        }

        void
        set(Char c)
        {
            bset.set((unsigned char)c);
        }

        void
        clear(Char from, Char to)
        {
            for (int i = from; i <= to; ++i)
                bset.reset((unsigned char)i);
        }

        void
        clear(Char c)
        {
            bset.reset((unsigned char)c);
        }

        void
        clear()
        {
            bset.reset();
        }

        void
        inverse()
        {
            bset.flip();
        }

        void
        swap(basic_chset_8bit& x)
        {
            std::swap(bset, x.bset);
        }

        basic_chset_8bit&
        operator|=(basic_chset_8bit const& x)
        {
            bset |= x.bset;
            return *this;
        }

        basic_chset_8bit&
        operator&=(basic_chset_8bit const& x)
        {
            bset &= x.bset;
            return *this;
        }

        basic_chset_8bit&
        operator-=(basic_chset_8bit const& x)
        {
            bset &= ~x.bset;
            return *this;
        }

        basic_chset_8bit&
        operator^=(basic_chset_8bit const& x)
        {
            bset ^= x.bset;
            return *this;
        }

        private: std::bitset<256> bset;
    };

    /////////////////////////////////
    template <>
    struct basic_chset<char>
      : basic_chset_8bit<char> {};

    /////////////////////////////////
    template <>
    struct basic_chset<signed char>
      : basic_chset_8bit<signed char> {};

    /////////////////////////////////
    template <>
    struct basic_chset<unsigned char>
      : basic_chset_8bit<unsigned char> {};

#endif // #if (CHAR_BIT == 8)

}}}}

#endif

ext: hpp

max_stars_repo_name: TE-tatuonagamatu/boost


text:
// Copyright (c) 2012-2018 The Elastos Open Source Project
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <set>

#include "secp256k1.h"
#include <SDK/Common/Utils.h>
#include <boost/bind.hpp>
#include <SDK/Wrapper/ByteStream.h>
#include <BigIntegerLibrary.hh>
#include <SDK/Common/Log.h>
#include <SDK/Common/ParamChecker.h>
#include "MultiSignAccount.h"
#include "AccountFactory.h"

namespace Elastos {
	namespace ElaWallet {

		MultiSignAccount::MultiSignAccount(IAccount *me, const std::vector<std::string> &coSigners,
										   uint32_t requiredSignCount) :
			_me(me),
			_requiredSignCount(requiredSignCount),
			_coSigners(coSigners) {
		}

		MultiSignAccount::MultiSignAccount(const std::string &rootPath) : _rootPath(rootPath) {

		}

		Key MultiSignAccount::DeriveKey(const std::string &payPassword) {
			checkSigners();
			return _me->DeriveKey(payPassword);
		}

		UInt512 MultiSignAccount::DeriveSeed(const std::string &payPassword) {
			checkSigners();
			return _me->DeriveSeed(payPassword);
		}

		void MultiSignAccount::ChangePassword(const std::string &oldPassword, const std::string &newPassword) {
			if (_me != nullptr)
				_me->ChangePassword(oldPassword, newPassword);
		}

		nlohmann::json MultiSignAccount::ToJson() const {
			nlohmann::json j;
			to_json(j, *this);
			return j;
		}

		void MultiSignAccount::FromJson(const nlohmann::json &j) {
			from_json(j, *this);
		}

		const std::string &MultiSignAccount::GetEncryptedKey() const {
			checkSigners();
			return _me->GetEncryptedKey();
		}

		const std::string &MultiSignAccount::GetEncryptedMnemonic() const {
			checkSigners();
			return _me->GetEncryptedMnemonic();
		}

		const std::string &MultiSignAccount::GetEncryptedPhrasePassword() const {
			checkSigners();
			return _me->GetEncryptedPhrasePassword();
		}

		const std::string &MultiSignAccount::GetPublicKey() const {
			checkSigners();
			return _me->GetPublicKey();
		}

		const MasterPubKey &MultiSignAccount::GetIDMasterPubKey() const {
			checkSigners();
			return _me->GetIDMasterPubKey();
		}

		bool MultiSignAccount::Compare(const std::string &a, const std::string &b) const {
			secp256k1_pubkey pk;

			CMBlock cbA = Utils::decodeHex(a);
			ParamChecker::checkCondition(0 == BRKeyPubKeyDecode(&pk, cbA, cbA.GetSize()), Error::PubKeyFormat,
										 "Public key decode error");
			BigInteger bigIntA = dataToBigInteger(pk.data, sizeof(pk.data) / 2, BigInteger::Sign::positive);

			CMBlock cbB = Utils::decodeHex(b);
			ParamChecker::checkCondition(0 == BRKeyPubKeyDecode(&pk, cbB, cbB.GetSize()), Error::PubKeyFormat,
										 "Public key decode error");
			BigInteger bigIntB = dataToBigInteger(pk.data, sizeof(pk.data) / 2, BigInteger::Sign::positive);

			return bigIntA <= bigIntB;
		}

		void MultiSignAccount::checkSigners() const {
			ParamChecker::checkCondition(_me == nullptr, Error::WrongAccountType,
										 "Readonly account do not support this operation.");
		}

		std::string MultiSignAccount::GetAddress() const {
			if (_address.empty()) {
				// redeem script -> program hash
				UInt168 programHash = Utils::codeToProgramHash(GenerateRedeemScript());

				// program hash -> address
				_address = Utils::UInt168ToAddress(programHash);
			}
			return _address;
		}

		CMBlock MultiSignAccount::GenerateRedeemScript() const {
			std::set<std::string> uniqueSigners(_coSigners.begin(), _coSigners.end());
			if (_me != nullptr)
				uniqueSigners.insert(_me->GetPublicKey());

			ParamChecker::checkCondition(uniqueSigners.size() < _requiredSignCount, Error::MultiSignersCount,
										 "Required sign count greater than signers");

			ParamChecker::checkCondition(uniqueSigners.size() > sizeof(uint8_t) - OP_1, Error::MultiSignersCount,
										 "Signers should less than 205.");

			std::vector<std::string> sortedSigners(uniqueSigners.begin(), uniqueSigners.end());

			std::sort(sortedSigners.begin(), sortedSigners.end(),
					  boost::bind(&MultiSignAccount::Compare, this, _1, _2));

			ByteStream stream;
			stream.writeUint8(uint8_t(OP_1 + _requiredSignCount - 1));
			for (size_t i = 0; i < sortedSigners.size(); i++) {
				CMBlock pubKey = Utils::decodeHex(sortedSigners[i]);
				stream.writeUint8(uint8_t(pubKey.GetSize()));
				stream.writeBytes(pubKey, pubKey.GetSize());
			}

			stream.writeUint8(uint8_t(OP_1 + sortedSigners.size() - 1));
			stream.writeUint8(ELA_MULTISIG);

			return stream.getBuffer();
		}

		void to_json(nlohmann::json &j, const MultiSignAccount &p) {
			if (p._me != nullptr) {
				j["InnerAccount"] = p._me->ToJson();
				j["InnerAccountType"] = p._me->GetType();
			}
			j["CoSigners"] = p._coSigners;
			j["RequiredSignCount"] = p._requiredSignCount;
		}

		void from_json(const nlohmann::json &j, MultiSignAccount &p) {
			p._me = AccountPtr(AccountFactory::CreateFromJson(p._rootPath, j, "InnerAccount", "InnerAccountType"));
			p._coSigners = j["CoSigners"].get<std::vector<std::string>>();
			p._requiredSignCount = j["RequiredSignCount"].get<uint32_t>();
		}

		nlohmann::json MultiSignAccount::GetBasicInfo() const {
			nlohmann::json j;
			j["Type"] = "Multi-Sign";
			nlohmann::json details;
			std::vector<std::string> signers = _coSigners;
			std::string innerType;
			if (_me != nullptr) {
				nlohmann::json basicInfo = _me->GetBasicInfo();
				innerType = basicInfo["Type"];
				signers.push_back(_me->GetPublicKey());
			} else {
				innerType = "Readonly";
			}
			j["InnerType"] = innerType;

			details["Signers"] = signers;
			details["RequiredSignCount"] = _requiredSignCount;
			j["Details"] = details;
			return j;
		}

		std::string MultiSignAccount::GetType() const {
			return "MultiSign";
		}

		IAccount *MultiSignAccount::GetInnerAccount() const {
			return _me.get();
		}

		const std::vector<std::string> &MultiSignAccount::GetCoSigners() const {
			return _coSigners;
		}

		uint32_t MultiSignAccount::GetRequiredSignCount() const {
			return _requiredSignCount;
		}

		bool MultiSignAccount::IsReadOnly() const {
			return _me == nullptr;
		}

		bool MultiSignAccount::IsEqual(const IAccount &account) const {
			if (account.GetType() != GetType() || IsReadOnly() != account.IsReadOnly())
				return false;

			if (!IsReadOnly() && !account.IsReadOnly()) {
				return account.GetPublicKey() == GetPublicKey();
			}

			return account.GetAddress() == GetAddress();
		}

	}
}

ext: cpp


text:
#ifndef NWNFEAT_H
#define NWNFEAT_H

#include <Nwn/base.hpp>
#include <string>
#include <unordered_map>
#include <map>

#include <boost/serialization/nvp.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <boost/serialization/unordered_map.hpp>
#include <boost/serialization/map.hpp>

namespace Nwn {

static constexpr int INVALID_FEAT_ID = -1;

static constexpr int FEAT_ID_QUICK_TO_MASTER = 258;
static constexpr int FEAT_ID_TOUGHNESS = 40;
static constexpr int FEAT_ID_STEADFAST_DETERMINATION = 2170;

class AblBlock;

enum class FeatEffectType
{
    InvalidEffect,
    HpBonus,
    FortSave,
    RefSave,
    WillSave,
    StrBonus,
    DexBonus,
    ConBonus,
    IntBonus,
    WisBonus,
    ChaBonus
};

using FeatEffectMap = std::map<FeatEffectType, int>;

class Feat
{
public:
    explicit Feat( int id = -1, const std::string& n = "" );
    ~Feat();

    int getId() const { return id; }
    void setId( int id ) { this->id = id; }

    const std::string& getName() const { return name; }
    void setName( const std::string& n ) { name = n; }

    const std::string& getDescription() const { return description; }
    void setDescription( const std::string& d ) { description = d; }

    bool hasColumn(const std::string& col) const;
    int getColumn(const std::string& col) const;
    void setColumn(const std::string& col, int val);

    void addEffect(FeatEffectType type, int val);
    bool hasEffect(FeatEffectType type) const;
    int getEffect(FeatEffectType type) const;

private:
    friend class boost::serialization::access;

    template<class Archive>
    void serialize( Archive & ar, const unsigned int /* file_version */ )
    {
        ar & boost::serialization::make_nvp( "id", id )
           & boost::serialization::make_nvp( "name", name )
           & boost::serialization::make_nvp( "description", description )
           & boost::serialization::make_nvp( "columns", columns )
           & boost::serialization::make_nvp( "effects", effects );
    }

    int id = INVALID_FEAT_ID;
    std::string name;
    std::string description;
    std::unordered_map<std::string, int> columns;
    FeatEffectMap effects;
};

} // namespace Nwn

#endif // NWNFEAT_H

max_stars_repo_name: rkibria/NwnCharGen

max_issues_repo_name: rkibria/NwnCharGen

max_forks_repo_name: rkibria/NwnCharGen


text:
/*
 * MIT License
 *
 * Copyright (c) 2018 Hippolyte Barraud
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#pragma once

#include <memory>
#include <unordered_map>
#include <boost/core/noncopyable.hpp>
#include <seastar/core/reactor.hh>
#include "impl/directory.hpp"
#include "impl/macro.hpp"

namespace ultramarine {

    /// Base template class defining an actor
    /// \unique_name ultramarine::actor
    /// \tparam Derived The derived actor class for CRTP purposes
    /// \tparam LocalPlacementStrategy Optional. Allows to specify a custom local placement strategy. Defaults to [ultramarine::default_local_placement_strategy]()
    /// \requires `Derived` should implement actor behavior using [ULTRAMARINE_DEFINE_ACTOR]()
    template<typename Derived, typename LocalPlacementStrategy = impl::default_local_placement_strategy>
    struct actor : private boost::noncopyable {

        /// Default key type (unsigned long integer)
        /// \unique_name ultramarine::actor::KeyType
        /// See [ultramarine::actor_id]()
        using KeyType = actor_id;

        /// Default placement strategy
        using PlacementStrategy = LocalPlacementStrategy;

        /// \exclude
        static inline thread_local std::unique_ptr<impl::directory<Derived>> directory = std::make_unique<impl::directory<Derived>>();

        /// \effects Clears all actors of type Derived in all shards
        /// \returns A future available when all instances of this actor type have been purged
        static seastar::future<> clear_directory() {
            return seastar::smp::invoke_on_all([] {
                directory->clear();
                return seastar::make_ready_future();
            });
        }
    };
}

max_stars_repo_name: HippoBaro/Ultramarine

max_issues_repo_name: HippoBaro/Ultramarine

max_forks_repo_name: HippoBaro/Ultramarine


text:
#include "duck.h"
#include "vertices.h"

#include <GL/glew.h>
#include <GL/glfw.h>
#include "opengp.h"

#include <Eigen/Geometry>

#include "duck_vshader.h"
#include "duck_fshader.h"

RenderedDuck::RenderedDuck(unsigned int width, unsigned int height):
	RenderingContext(width, height) {
}

void RenderedDuck::init(Vertices* vertices) {

	/// Common initialization.
    preinit(vertices, duck_vshader, duck_fshader, NULL, "vertexPosition3DWorld", "normal_mv");

    /// Light properties. (no specular)
	/// Define light properties and pass them to the shaders.
    vec3 Ia(1.0f, 1.0f, 1.0f);
    vec3 Id(1.0f, 1.0f, 1.0f);
    vec3 Is(1.0f, 1.0f, 1.0f);
    GLuint _IaID = glGetUniformLocation(_programID, "Ia");
    GLuint _IdID = glGetUniformLocation(_programID, "Id");
    glUniform3fv( _IaID, 1, Ia.data());
    glUniform3fv( _IdID, 1, Id.data());

    /// Set uniform IDs.
    _viewID = glGetUniformLocation(_programID, "view");
    _projectionID = glGetUniformLocation(_programID, "projection");
	_transID = glGetUniformLocation(_programID, "translation");
	_lightPositionWorldID = glGetUniformLocation(_programID, "lightPositionWorld");

	_aniMatID = glGetUniformLocation(_programID, "animation");
}

void RenderedDuck::draw(const mat4& projection, const mat4 views[], const vec3& lightPositionWorld) {

	 /// Common drawing.
    predraw();

    /// Update the content of the uniforms.
    glUniformMatrix4fv( _projectionID, 1, GL_FALSE, projection.data());
	glUniform3fv(_lightPositionWorldID, 1, lightPositionWorld.data());

    /// Do not clear the framebuffers : done by Terrain.
    /// Otherwise already drawn pixels will be cleared.

    /// Flip the terrain by multiplying the Z coordinate by -1 in world space.
    //mat4 flip = mat4::Identity();
    //flip(2,2) = -1.0f;
    //mat4 viewFlip = view * flip;

    /// Render the terrain from camera point of view to the reflection FBO.
 /*   glUniformMatrix4fv(_viewID, 1, GL_FALSE, viewFlip.data());
    _vertices->draw();*/

	/* Translation matrix */
	mat4 trans_mat;
	trans_mat << 1,0,0, -0.55,
				 0,1,0, 0.15,
				 0,0,1, 0,
				 0,0,0,1;
	glUniformMatrix4fv(_transID, 1, GL_FALSE, trans_mat.data());

	/* For Animation: Move circular around a fixed point */
	//float radius =
	static int step = 0;
	mat4 ani_mat;
	ani_mat << 1,0,0, 0 ,
			   0,1,0,float(step%1000)*0.0005,
			   0,0,1, 0,
			   0,0,0,1;
	glUniformMatrix4fv(_aniMatID, 1, GL_FALSE, ani_mat.data());
	step++;

    /// Render from camera point of view to 'normal' FBOs.
    glUniformMatrix4fv(_viewID, 1, GL_FALSE, views[0].data());
    glBindFramebuffer(GL_FRAMEBUFFER, framebufferIDs["controllerView"]);
    _vertices->draw();
    glUniformMatrix4fv(_viewID, 1, GL_FALSE, views[1].data());
    glBindFramebuffer(GL_FRAMEBUFFER, framebufferIDs["cameraView"]);
    _vertices->draw();

    /// Flip the world by multiplying the Z coordinate by -1 in world space.
    mat4 flip = mat4::Identity();
    flip(2,2) = -1.0f;
    mat4 viewFlip[] = {views[0]*flip, views[1]*flip};

    /// Render from flipped camera point of view to 'reflection' FBOs.
    glUniformMatrix4fv(_viewID, 1, GL_FALSE, viewFlip[0].data());
    glBindFramebuffer(GL_FRAMEBUFFER, framebufferIDs["controllerViewReflected"]);
    _vertices->draw();
    glUniformMatrix4fv(_viewID, 1, GL_FALSE, viewFlip[1].data());
    glBindFramebuffer(GL_FRAMEBUFFER, framebufferIDs["cameraViewReflected"]);
    _vertices->draw();
}

max_stars_repo_name: mdeff/terrain

max_issues_repo_name: mdeff/terrain

max_forks_repo_name: mdeff/terrain


text:
#define BOOST_TEST_MODULE
#include <boost/test/included/unit_test.hpp>

max_stars_repo_name: tr-takatsuka/rlib-Json

max_issues_repo_name: tr-takatsuka/rlib-StringFormat

max_forks_repo_name: tr-takatsuka/rlib-StringFormat


text:
#include <gtest/gtest.h>
#include <gmock/gmock.h>

#include <waypoint_control/waypoint_controller.h>
#include <boost/math/constants/constants.hpp>

using boost::math::double_constants::pi;
using std::abs;
using std::sqrt;
using std::pow;

using namespace waypoint_control;

TEST(FeedbackTests, invalidOrientation)
{
  tf2::Transform robot;
  Waypoint goal;

  // Throw error if robot quaternion is invalid
  ASSERT_THROW(Feedback(robot, goal), std::runtime_error);

  // Set default orientation if waypoint quaternion is invalid
  robot.setRotation(tf2::Quaternion(0.0, 0.0, 0.0, 1.0));
  Feedback feedback(robot, goal);
  EXPECT_NEAR(feedback.theta(), 0.0, 1.0e-6);
}

TEST(FeedbackTests, goalPoses)
{
  tf2::Transform robot;
  robot.setRotation(tf2::Quaternion(0.0, 0.0, 0.0, 1.0));
  Waypoint goal;
  goal.pose.orientation.w = 1.0;
  Feedback feedback;

  goal.pose.position.x =  1.0;
  goal.pose.position.y =  0.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),     1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),     0.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     1.0, 1e-6);
  EXPECT_NEAR(feedback.theta(), 0.0, 1e-6);

  goal.pose.position.x =  1.0;
  goal.pose.position.y =  1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),           1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),           1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),      pi/4, 1e-6);

  goal.pose.position.x =  0.0;
  goal.pose.position.y =  1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),           0.0, 1e-6);
  EXPECT_NEAR(feedback.y(),           1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),      pi/2, 1e-6);

  goal.pose.position.x = -1.0;
  goal.pose.position.y =  1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),          -1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),           1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),    3*pi/4, 1e-6);

  goal.pose.position.x = -1.0;
  goal.pose.position.y =  0.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),          -1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),           0.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),        pi, 1e-6);

  goal.pose.position.x = -1.0;
  goal.pose.position.y = -1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),          -1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),          -1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),   -3*pi/4, 1e-6);

  goal.pose.position.x =  0.0;
  goal.pose.position.y = -1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),           0.0, 1e-6);
  EXPECT_NEAR(feedback.y(),          -1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),     -pi/2, 1e-6);

  goal.pose.position.x =  1.0;
  goal.pose.position.y = -1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),           1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),          -1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),     -pi/4, 1e-6);
}

TEST(Feedback, robotPoses)
{
  tf2::Transform robot;
  robot.setRotation(tf2::Quaternion(0.0, 0.0, 0.0, 1.0));
  Waypoint goal;
  goal.pose.position.x =  1.0;
  goal.pose.position.y =  0.0;
  goal.pose.orientation.w = 1.0;
  Feedback feedback;

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi/2));
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),         0.0, 1e-6);
  EXPECT_NEAR(feedback.y(),        -1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),         1.0, 1e-6);
  EXPECT_NEAR(feedback.theta(),   -pi/2, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), -pi/2));
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),         0.0, 1e-6);
  EXPECT_NEAR(feedback.y(),         1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),         1.0, 1e-6);
  EXPECT_NEAR(feedback.theta(),    pi/2, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), 3*pi/4));
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(), cos(-3*pi/4), 1e-6);
  EXPECT_NEAR(feedback.y(), sin(-3*pi/4), 1e-6);
  EXPECT_NEAR(feedback.r(),          1.0, 1e-6);
  EXPECT_NEAR(feedback.theta(),  -3*pi/4, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), -3*pi/4));
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),  cos(3*pi/4), 1e-6);
  EXPECT_NEAR(feedback.y(),  sin(3*pi/4), 1e-6);
  EXPECT_NEAR(feedback.r(),         1.0, 1e-6);
  EXPECT_NEAR(feedback.theta(),  3*pi/4, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi));
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),    -1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),     0.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     1.0, 1e-6);
  EXPECT_NEAR(feedback.theta(), -pi, 1e-6);
}

TEST(Feedback, robotAndGoalPoses)
{
  tf2::Transform robot;
  robot.setRotation(tf2::Quaternion(0.0, 0.0, 0.0, 1.0));
  Waypoint goal;
  goal.pose.orientation.w = 1.0;
  Feedback feedback;

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi/4));
  goal.pose.position.x =  1.0;
  goal.pose.position.y =  1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.y(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),       0.0, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi/2));
  goal.pose.position.x =  0.0;
  goal.pose.position.y =  1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.y(),     sqrt(0.0), 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),       0.0, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), -pi/2));
  goal.pose.position.x =   0.0;
  goal.pose.position.y =  -1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),           1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),           0.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),       0.0, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi));
  goal.pose.position.x =  -1.0;
  goal.pose.position.y =   0.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.y(),     sqrt(0.0), 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),       0.0, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi));
  goal.pose.position.x =  -1.0;
  goal.pose.position.y =  -1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.y(),     sqrt(1.0), 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),      pi/4, 1e-6);

  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi));
  goal.pose.position.x =  -1.0;
  goal.pose.position.y =   1.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),           1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),          -1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),     -pi/4, 1e-6);

  robot.setOrigin(tf2::Vector3(2.0, 3.0, 0.0));
  robot.setRotation(tf2::Quaternion(tf2::Vector3(0, 0, 1), pi));
  goal.pose.position.x =  1.0;
  goal.pose.position.y =  2.0;
  feedback = Feedback(robot, goal);
  EXPECT_NEAR(feedback.x(),         -1.0, 1e-6);
  EXPECT_NEAR(feedback.y(),         -1.0, 1e-6);
  EXPECT_NEAR(feedback.r(),     sqrt(2.0), 1e-6);
  EXPECT_NEAR(feedback.theta(),      pi/4, 1e-6);
}

// Run all the tests that were declared with TEST()
int main(int argc, char **argv)
{
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}


text:
#pragma once

#include <cstddef>
#include <cstdint>
#include <memory>
#include <boost/type_index.hpp>

#include <giecs/memory/context.hpp>
#include <giecs/memory/block.hpp>

namespace giecs
{
namespace memory
{

template <std::size_t page_size, typename align_t, typename val_t, typename Derived>
class Accessor : public ContextSync<page_size, align_t>
{
    public:
        Accessor(Context<page_size, align_t> const& context_, std::uintmax_t flags)
            : ContextSync<page_size, align_t>(context_,
        {
            boost::typeindex::type_id<Derived>(), flags
        })
        {}

        virtual ~Accessor()
        {}

    protected:
        template <typename CreateSyncFunctor>
        std::shared_ptr<TypeBlock<page_size, align_t, val_t, CreateSyncFunctor> const> getBlock(std::size_t const page_id, std::size_t const block_id, bool dirty, CreateSyncFunctor createSync, std::size_t block_size) const
        {
            BlockKey const key = {page_id, block_id, this->accessor_id};
            std::shared_ptr<TypeBlock<page_size, align_t, val_t, CreateSyncFunctor> const> block = std::static_pointer_cast<TypeBlock<page_size, align_t, val_t, CreateSyncFunctor> const>(this->context.getBlock(key));
            if(block == nullptr)
            {
                block = std::make_shared<TypeBlock<page_size, align_t, val_t, CreateSyncFunctor> const>(block_size, createSync);
                this->context.addBlock(block, static_cast<Derived const*>(this)->blockKeys(block_id));
            }
            if(dirty)
                this->context.markPageDirty(key, block);

            return block;
        }
};

} // namespace memory

} // namespace giecs

max_stars_repo_name: michaelsippel/cautious-potato

max_issues_repo_name: michaelsippel/cautious-potato

max_forks_repo_name: michaelsippel/cautious-potato


text:
#include "InputFileOperator.h"
#include "CommandLineHandlers/PredicateCommandLineHandler.h"
#include <boost/algorithm/string/trim.hpp>

USING_NAMESPACE(std);
USING_NAMESPACE(clu);

class SystemOperator : public InputFileOperator {
public:
	virtual bool OnLineRead(string& line)
	{
		string cmd = line;
		boost::algorithm::trim(cmd);
		if (!cmd.empty())
		{
			if (system(cmd.c_str())) {};
		}

		return true;
	}
};

REGISTER_PREDICATE("system", SystemOperator)->SetHelp("Run the command as system command");

max_stars_repo_name: ShaiRoitman/clu

max_issues_repo_name: ShaiRoitman/clu

max_forks_repo_name: ShaiRoitman/clu


text:
/*
 Copyright (C) 2018 Quaternion Risk Management Ltd
 All rights reserved.

 This file is part of ORE, a free-software/open-source library
 for transparent pricing and risk analysis - http://opensourcerisk.org

 ORE is free software: you can redistribute it and/or modify it
 under the terms of the Modified BSD License.  You should have received a
 copy of the license along with this program.
 The license is also available online at <http://opensourcerisk.org>

 This program is distributed on the basis that it will form a useful
 contribution to risk analytics and model standardisation, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
*/

#include <boost/test/unit_test.hpp>
#include <oret/toplevelfixture.hpp>

#include <boost/make_shared.hpp>

#include <ored/configuration/curveconfigurations.hpp>
#include <ored/marketdata/commodityvolcurve.hpp>
#include <ored/marketdata/curvespec.hpp>
#include <ored/marketdata/loader.hpp>

using namespace std;
using namespace boost::unit_test_framework;
using namespace QuantLib;
using namespace QuantExt;
using namespace ore::data;

namespace {

// testTolerance for Real comparison
Real testTolerance = 1e-10;

class MockLoader : public Loader {
public:
    MockLoader();
    const vector<boost::shared_ptr<MarketDatum>>& loadQuotes(const Date&) const { return data_; }
    const boost::shared_ptr<MarketDatum>& get(const string& name, const Date&) const { return dummyDatum_; }
    const vector<Fixing>& loadFixings() const { return dummyFixings_; }
    const vector<Fixing>& loadDividends() const { return dummyDividends_; }

private:
    vector<boost::shared_ptr<MarketDatum>> data_;
    boost::shared_ptr<MarketDatum> dummyDatum_;
    vector<Fixing> dummyFixings_;
    vector<Fixing> dummyDividends_;
};

MockLoader::MockLoader() {
    Date asof(5, Feb, 2016);
    data_ = {
        boost::make_shared<CommodityOptionQuote>(0.11, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD/USD/1Y/ATMF",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "1Y", "ATMF"),
        boost::make_shared<CommodityOptionQuote>(0.10, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD/USD/2Y/ATMF",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "2Y", "ATMF"),
        boost::make_shared<CommodityOptionQuote>(0.09, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD/USD/5Y/ATMF",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "5Y", "ATMF"),
        boost::make_shared<CommodityOptionQuote>(0.105, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD_USD_VOLS/USD/1Y/1150",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "1Y", "1150"),
        boost::make_shared<CommodityOptionQuote>(0.115, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD_USD_VOLS/USD/1Y/1190",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "1Y", "1190"),
        boost::make_shared<CommodityOptionQuote>(0.095, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD_USD_VOLS/USD/2Y/1150",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "2Y", "1150"),
        boost::make_shared<CommodityOptionQuote>(0.105, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD_USD_VOLS/USD/2Y/1190",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "2Y", "1190"),
        boost::make_shared<CommodityOptionQuote>(0.085, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD_USD_VOLS/USD/5Y/1150",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "5Y", "1150"),
        boost::make_shared<CommodityOptionQuote>(0.095, asof, "COMMODITY_OPTION/RATE_LNVOL/GOLD_USD_VOLS/USD/5Y/1190",
                                                 MarketDatum::QuoteType::RATE_LNVOL, "GOLD", "USD", "5Y", "1190")};
}

} // namespace

BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)

BOOST_AUTO_TEST_SUITE(CommodityVolCurveTests)

BOOST_AUTO_TEST_CASE(testCommodityVolCurveTypeConstant) {

    BOOST_TEST_MESSAGE("Testing commodity vol curve building with a single configured volatility");

    // As of date
    Date asof(5, Feb, 2016);

    // Volatility configuration with a single quote
    boost::shared_ptr<CommodityVolatilityCurveConfig> curveConfig = boost::make_shared<CommodityVolatilityCurveConfig>(
        "GOLD_USD_VOLS", "", "USD", "COMMODITY_OPTION/RATE_LNVOL/GOLD/USD/2Y/ATMF", "A365", "NullCalendar");

    // Curve configurations
    CurveConfigurations curveConfigs;
    curveConfigs.commodityVolatilityCurveConfig("GOLD_USD_VOLS") = curveConfig;

    // Commodity curve spec
    CommodityVolatilityCurveSpec curveSpec("USD", "GOLD_USD_VOLS");

    // Market data loader
    MockLoader loader;

    // Check commodity volatility construction works
    boost::shared_ptr<CommodityVolCurve> curve;
    BOOST_CHECK_NO_THROW(curve = boost::make_shared<CommodityVolCurve>(asof, curveSpec, loader, curveConfigs));

    // Check volatilities are all equal to the configured volatility regardless of strike and expiry
    Real configuredVolatility = 0.10;
    boost::shared_ptr<BlackVolTermStructure> volatility = curve->volatility();
    BOOST_CHECK_CLOSE(volatility->blackVol(0.25, 1000.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(0.25, 1200.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 3 * Months, 1000.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 3 * Months, 1200.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(50.0, 1000.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(50.0, 1200.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 50 * Years, 1000.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 50 * Years, 1200.0), configuredVolatility, testTolerance);
}

BOOST_AUTO_TEST_CASE(testCommodityVolCurveTypeCurve) {

    BOOST_TEST_MESSAGE("Testing commodity vol curve building with time dependent volatilities");

    // As of date
    Date asof(5, Feb, 2016);

    // Volatility configuration with time dependent volatilities
    bool extrapolate = true;
    vector<string> quotes{"COMMODITY_OPTION/RATE_LNVOL/GOLD/USD/1Y/ATMF",
                          "COMMODITY_OPTION/RATE_LNVOL/GOLD/USD/2Y/ATMF",
                          "COMMODITY_OPTION/RATE_LNVOL/GOLD/USD/5Y/ATMF"};
    boost::shared_ptr<CommodityVolatilityCurveConfig> curveConfig = boost::make_shared<CommodityVolatilityCurveConfig>(
        "GOLD_USD_VOLS", "", "USD", quotes, "A365", "NullCalendar", extrapolate);

    // Curve configurations
    CurveConfigurations curveConfigs;
    curveConfigs.commodityVolatilityCurveConfig("GOLD_USD_VOLS") = curveConfig;

    // Commodity curve spec
    CommodityVolatilityCurveSpec curveSpec("USD", "GOLD_USD_VOLS");

    // Market data loader
    MockLoader loader;

    // Check commodity volatility construction works
    boost::shared_ptr<CommodityVolCurve> curve;
    BOOST_CHECK_NO_THROW(curve = boost::make_shared<CommodityVolCurve>(asof, curveSpec, loader, curveConfigs));

    // Check time depending volatilities are as expected
    boost::shared_ptr<BlackVolTermStructure> volatility = curve->volatility();
    Real configuredVolatility;

    // Check configured pillar points: { (1Y, 0.11), (2Y, 0.10), (5Y, 0.09) }
    // Check also strike independence
    configuredVolatility = 0.11;
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 1 * Years, 1000.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 1 * Years, 1200.0), configuredVolatility, testTolerance);

    configuredVolatility = 0.10;
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 2 * Years, 1000.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 2 * Years, 1200.0), configuredVolatility, testTolerance);

    configuredVolatility = 0.09;
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 5 * Years, 1000.0), configuredVolatility, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 5 * Years, 1200.0), configuredVolatility, testTolerance);

    // Check briefly the default linear interpolation and extrapolation
    Time t_s = volatility->dayCounter().yearFraction(asof, asof + 2 * Years);
    Real v_s = 0.10;
    Time t_e = volatility->dayCounter().yearFraction(asof, asof + 5 * Years);
    Real v_e = 0.09;
    // at 3 years
    Time t = volatility->dayCounter().yearFraction(asof, asof + 3 * Years);
    Real v = sqrt((v_s * v_s * t_s + (v_e * v_e * t_e - v_s * v_s * t_s) * (t - t_s) / (t_e - t_s)) / t);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 3 * Years, 1000.0), v, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 3 * Years, 1200.0), v, testTolerance);
    // at 6 years, extrapolation is with a flat vol
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 6 * Years, 1000.0), v_e, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 6 * Years, 1200.0), v_e, testTolerance);
}

BOOST_AUTO_TEST_CASE(testCommodityVolCurveTypeSurface) {

    BOOST_TEST_MESSAGE("Testing commodity vol curve building with time and strike dependent volatilities");

    // As of date
    Date asof(5, Feb, 2016);

    // Volatility configuration with time dependent volatilities
    bool extrapolate = true;
    vector<string> expiries{"1Y", "2Y", "5Y"};
    vector<string> strikes{"1150", "1190"};
    boost::shared_ptr<CommodityVolatilityCurveConfig> curveConfig = boost::make_shared<CommodityVolatilityCurveConfig>(
        "GOLD_USD_VOLS", "", "USD", expiries, strikes, "A365", "NullCalendar", extrapolate);

    // Curve configurations
    CurveConfigurations curveConfigs;
    curveConfigs.commodityVolatilityCurveConfig("GOLD_USD_VOLS") = curveConfig;

    // Commodity curve spec
    CommodityVolatilityCurveSpec curveSpec("USD", "GOLD_USD_VOLS");

    // Market data loader
    MockLoader loader;

    // Check commodity volatility construction works
    boost::shared_ptr<CommodityVolCurve> curve;
    BOOST_CHECK_NO_THROW(curve = boost::make_shared<CommodityVolCurve>(asof, curveSpec, loader, curveConfigs));

    // Check time and strike depending volatilities are as expected
    boost::shared_ptr<BlackVolTermStructure> volatility = curve->volatility();

    // Check configured pillar points
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 1 * Years, 1150.0), 0.105, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 1 * Years, 1190.0), 0.115, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 2 * Years, 1150.0), 0.095, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 2 * Years, 1190.0), 0.105, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 5 * Years, 1150.0), 0.085, testTolerance);
    BOOST_CHECK_CLOSE(volatility->blackVol(asof + 5 * Years, 1190.0), 0.095, testTolerance);
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()

max_stars_repo_name: PiotrSiejda/Engine

max_issues_repo_name: PiotrSiejda/Engine

max_forks_repo_name: PiotrSiejda/Engine


text:
/*!
@file
Defines `boost::hana::detail::create`.

@copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
 */

#ifndef BOOST_HANA_DETAIL_CREATE_HPP
#define BOOST_HANA_DETAIL_CREATE_HPP

#include <boost/hana/config.hpp>
#include <boost/hana/detail/decay.hpp>

BOOST_HANA_NAMESPACE_BEGIN namespace detail {
    //! @ingroup group-details
    //! Implementation of the generic `std::make_xxx` pattern for arbitrary
    //! `xxx`s.
    template <template <typename ...> class T>
    struct create {
        template <typename ...X>
        constexpr T<typename detail::decay<X>::type...>
        operator()(X&& ...x) const {
            return T<typename detail::decay<X>::type...>{
                static_cast<X&&>(x)...
            };
        }
    };
} BOOST_HANA_NAMESPACE_END

#endif // !BOOST_HANA_DETAIL_CREATE_HPP

max_stars_repo_name: kindlychung/mediasoup-sfu-cpp

max_issues_repo_name: kindlychung/mediasoup-sfu-cpp

max_forks_repo_name: kindlychung/mediasoup-sfu-cpp


text:
/*!
 * @file
 * @brief
 * @copyright alphya 2021
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
 */

#ifndef NYARUGA_UTIL_GROUP_HPP
#define NYARUGA_UTIL_GROUP_HPP

#include <nyaruga_util/algebra.hpp>
#include <Eigen/Dense>
#include <complex>
#include <cmath>
#include <concepts>
#include <numbers>

namespace nyaruga {

namespace util {

namespace detail {

template <std::floating_point T = double>
struct SU1
{
    using value_type = std::complex<T> ;
private:
    std::complex<T> val_;
    constexpr SU1(const std::complex<T>& v) noexcept : val_(v) {}
public:
    constexpr void set_val(const T& theta) noexcept { val_ = exp(std::complex<T>{0,-1}*theta); }
    constexpr std::complex<T> val(const T& theta) const noexcept { val_  = exp(std::complex<T>{0,-1}*theta); return val_; }
    constexpr std::complex<T> val() const noexcept{ return val_; }
    constexpr operator std::complex<T>() const noexcept{ return val_; }
    constexpr SU1() noexcept = default;
    constexpr SU1(const SU1& v) noexcept : val_(v.val_) {}
    constexpr SU1(const T& theta) noexcept : val_(exp(std::complex<T>{0,-1}*theta)) {}
    friend SU1 operator*(const SU1& lhs, const SU1 & rhs) noexcept { return SU1(lhs.val()*rhs.val()); }
    constexpr SU1 conj() { return std::conj(val_); }
};

template <std::floating_point T = double>
struct SO2
{
    using value_type = Eigen::Matrix<T,2,2> ;
private:
    Eigen::Matrix<T,2,2> val_;
    constexpr SO2(const Eigen::Matrix<T,2,2>& v) noexcept : val_(v) {}
public:
    constexpr void set_val(const T& theta) noexcept { val_ << cos(theta), -sin(theta), sin(theta), cos(theta); }
    constexpr Eigen::Matrix<T,2,2> val(const T& theta) const noexcept { val_ << cos(theta), -sin(theta), sin(theta), cos(theta); return val_; };
    constexpr Eigen::Matrix<T,2,2> val() const noexcept{ return val_; };
    constexpr operator Eigen::Matrix<T,2,2>() const noexcept { return val_; }
    constexpr SO2() noexcept = default;
    constexpr SO2(const SO2& v) noexcept : val_(v.val_) {}
    constexpr SO2(const T& theta) noexcept { val_ << cos(theta), -sin(theta), sin(theta), cos(theta);}
    friend SO2 operator*(const SO2& lhs, const SO2 & rhs) noexcept { return SO2(lhs.val()*rhs.val()); }
    constexpr SO2 transpose() { return SO2(val_.transpose()); }
};

template <std::floating_point T = double>
struct SO3 // http://www.tuhep.phys.tohoku.ac.jp/~watamura/kougi/GP2012_4.pdf
{
    using value_type = Eigen::Matrix<T,3,3> ;
private:
    Eigen::Matrix<T,3,3> val_;
    constexpr SO3(const Eigen::Matrix<T,3,3>& v) noexcept : val_(v) {}

    // alpha, beta, gamma はオイラー角
    constexpr value_type calc_val(const T& alpha, const T& beta, const T& gamma) noexcept
    {
        value_type RX, RY, RZ;
        RX << 1, 0, 0,  0, cos(alpha), -sin(alpha),  0, sin(alpha), cos(alpha);
        RY << cos(beta), 0, sin(beta),  0, 1, 0,  -sin(beta), 0, cos(beta);
        RZ << cos(gamma), -sin(gamma), 0,  sin(gamma), cos(gamma), 0,  0, 0, 1;
        return RX*(RY*RZ);
    }

public:
    // alpha, beta, gamma はオイラー角
    constexpr void set_val(const T& alpha, const T& beta, const T& gamma) noexcept { val_ = calc_val(alpha, beta, gamma); }
    constexpr value_type val(const T& alpha, const T& beta, const T& gamma) const noexcept { val_ = calc_val(alpha, beta, gamma); return val_; };
    constexpr value_type val() const noexcept{ return val_; };
    constexpr operator value_type() const noexcept { return val_; }
    constexpr SO3() noexcept = default;
    constexpr SO3(const SO3& v) noexcept : val_(v.val_) {}
    constexpr SO3(const T& alpha, const T& beta, const T& gamma) noexcept : val_(calc_val(alpha, beta, gamma)) {}
    friend SO3 operator*(const SO3& lhs, const SO3 & rhs) noexcept { return SO3(lhs.val()*rhs.val()); }
    constexpr SO3 transpose() { return SO3(val_.transpose()); }
};

} // detail

using detail::SU1;
using detail::SO2;
using detail::SO3;

} // util

} // nyaruga

/* how to use

# include "group.hpp"

using namespace nyaruga::util;
using namespace std::numbers;

int main(){
    SU1 a(pi/2*23);
    SU1 b(pi/32);
    std::cout << norm((a*b).val()) << "\n"; // 1
    std::cout << (a.conj()*(a)).val() << "\n\n"; // E

    SO2 c(pi/2+2);
    SO2 d(pi/2*24+4);
    std::cout << (c*d).val() << "\n";
    std::cout << (c*c.transpose()).val() << "\n"; // E
    std::cout << (c*d).val().determinant() << "\n\n"; //1

    SO3 e(pi/2+2, 23., 4.);
    SO3 f(pi/2*24+4, 3., 42.);
    std::cout << (e*f).val() << "\n";
    std::cout << (e*e.transpose()).val() << "\n"; // E
    std::cout << (e*f).val().determinant() << "\n"; //1
}

*/

#endif // #ifndef NYARUGA_UTIL_GROUP_HPP


text:
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////

#ifndef BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP
#define BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP

#if (defined _MSC_VER) && (_MSC_VER >= 1200)
#  pragma once
#endif

#include "config_begin.hpp"
#include <boost/container/detail/workaround.hpp>
#include <boost/container/allocator_traits.hpp>
#include <boost/container/detail/destroyers.hpp>
#include <boost/aligned_storage.hpp>
#include <boost/move/move.hpp>
#include <iterator>  //std::iterator_traits
#include <boost/assert.hpp>

namespace boost { namespace container { namespace container_detail {

//This class will be interface for operations dependent on FwdIt types used advanced_insert_aux_impl
template<class Iterator>
struct advanced_insert_aux_int
{
   typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
   virtual void copy_remaining_to(Iterator p) = 0;
   virtual void uninitialized_copy_remaining_to(Iterator p) = 0;
   virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first) = 0;
   virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first) = 0;
   virtual ~advanced_insert_aux_int() {}
};

//This class template will adapt each FwIt types to advanced_insert_aux_int
template<class A, class FwdIt, class Iterator>
struct advanced_insert_aux_proxy
   :  public advanced_insert_aux_int<Iterator>
{
   typedef typename allocator_traits<A>::size_type size_type;
   typedef typename allocator_traits<A>::value_type value_type;
   typedef typename advanced_insert_aux_int<Iterator>::difference_type difference_type;

   advanced_insert_aux_proxy(A& a, FwdIt first, FwdIt last)
      :  a_(a), first_(first), last_(last)
   {}

   virtual ~advanced_insert_aux_proxy()
   {}

   virtual void copy_remaining_to(Iterator p)
   {  ::boost::copy_or_move(this->first_, this->last_, p);  }

   virtual void uninitialized_copy_remaining_to(Iterator p)
   {  ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, this->last_, p);  }

   virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
   {
      FwdIt mid = this->first_;
      std::advance(mid, division_count);
      if(first_n){
         ::boost::container::uninitialized_copy_or_move_alloc(this->a_, this->first_, mid, pos);
         this->first_ = mid;
      }
      else{
         ::boost::container::uninitialized_copy_or_move_alloc(this->a_, mid, this->last_, pos);
         this->last_ = mid;
      }
   }

   virtual void copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
   {
      FwdIt mid = this->first_;
      std::advance(mid, division_count);
      if(first_n){
         ::boost::copy_or_move(this->first_, mid, pos);
         this->first_ = mid;
      }
      else{
         ::boost::copy_or_move(mid, this->last_, pos);
         this->last_ = mid;
      }
   }
   A &a_;
   FwdIt first_, last_;
};

//This class template will adapt default construction insertions to advanced_insert_aux_int
template<class A, class Iterator>
struct default_construct_aux_proxy
   :  public advanced_insert_aux_int<Iterator>
{
   typedef ::boost::container::allocator_traits<A> alloc_traits;
   typedef typename allocator_traits<A>::size_type size_type;
   typedef typename allocator_traits<A>::value_type value_type;
   typedef typename advanced_insert_aux_int<Iterator>::difference_type difference_type;

   default_construct_aux_proxy(A &a, size_type count)
      :  a_(a), count_(count)
   {}

   virtual ~default_construct_aux_proxy()
   {}

   virtual void copy_remaining_to(Iterator)
   {  //This should never be called with any count
      BOOST_ASSERT(this->count_ == 0);
   }

   virtual void uninitialized_copy_remaining_to(Iterator p)
   {  this->priv_uninitialized_copy(p, this->count_); }

   virtual void uninitialized_copy_some_and_update(Iterator pos, difference_type division_count, bool first_n)
   {
      size_type new_count;
      if(first_n){
         new_count = division_count;
      }
      else{
         BOOST_ASSERT(difference_type(this->count_)>= division_count);
         new_count = this->count_ - division_count;
      }
      this->priv_uninitialized_copy(pos, new_count);
   }

   virtual void copy_some_and_update(Iterator , difference_type division_count, bool first_n)
   {
      BOOST_ASSERT(this->count_ == 0);
      size_type new_count;
      if(first_n){
         new_count = division_count;
      }
      else{
         BOOST_ASSERT(difference_type(this->count_)>= division_count);
         new_count = this->count_ - division_count;
      }
      //This function should never called with a count different to zero
      BOOST_ASSERT(new_count == 0);
      (void)new_count;
   }

   private:
   void priv_uninitialized_copy(Iterator p, const size_type n)
   {
      BOOST_ASSERT(n <= this->count_);
      Iterator orig_p = p;
      size_type i = 0;
      try{
         for(; i < n; ++i, ++p){
            alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p));
         }
      }
      catch(...){
         while(i--){
            alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++));
         }
         throw;
      }
      this->count_ -= n;
   }
   A &a_;
   size_type count_;
};

}}}   //namespace boost { namespace container { namespace container_detail {

#ifdef BOOST_CONTAINER_PERFECT_FORWARDING

#include <boost/container/detail/variadic_templates_tools.hpp>
#include <boost/container/detail/stored_ref.hpp>
#include <boost/move/move.hpp>
#include <typeinfo>
//#include <iostream> //For debugging purposes

namespace boost {
namespace container {
namespace container_detail {

//This class template will adapt emplace construction insertions of movable types
//to advanced_insert_aux_int
template<class A, class Iterator, class ...Args>
struct advanced_insert_aux_non_movable_emplace
   :  public advanced_insert_aux_int<Iterator>
{
   typedef boost::container::allocator_traits<A> alloc_traits;
   typedef typename allocator_traits<A>::size_type size_type;
   typedef typename allocator_traits<A>::value_type value_type;
   typedef typename advanced_insert_aux_int<Iterator>::difference_type difference_type;
   typedef typename build_number_seq<sizeof...(Args)>::type             index_tuple_t;

   explicit advanced_insert_aux_non_movable_emplace(A &a, Args&&... args)
      : a_(a)
      , args_(args...)
      , used_(false)
   {}

   ~advanced_insert_aux_non_movable_emplace()
   {}

   virtual void copy_remaining_to(Iterator)
   //This code can't be called since value_type is not movable or copyable
   {  BOOST_ASSERT(false);   }

   virtual void uninitialized_copy_remaining_to(Iterator p)
   {  this->priv_uninitialized_copy_remaining_to(index_tuple_t(), p);   }

   virtual void uninitialized_copy_some_and_update(Iterator p, difference_type division_count, bool first_n)
   {  this->priv_uninitialized_copy_some_and_update(index_tuple_t(), p, division_count, first_n);  }

   virtual void copy_some_and_update(Iterator, difference_type, bool )
   //This code can't be called since value_type is not movable or copyable
   {  BOOST_ASSERT(false);   }

   private:
   template<int ...IdxPack>
   void priv_uninitialized_copy_some_and_update(const index_tuple<IdxPack...>&, Iterator p, difference_type division_count, bool first_n)
   {
      BOOST_ASSERT(division_count <=1);
      if((first_n && division_count == 1) || (!first_n && division_count == 0)){
         if(!this->used_){
            alloc_traits::construct( this->a_
                                   , container_detail::to_raw_pointer(&*p)
                                   , ::boost::container::container_detail::
                                       stored_ref<Args>::forward(get<IdxPack>(this->args_))...
                                   );
            this->used_ = true;
         }
      }
   }

   template<int ...IdxPack>
   void priv_uninitialized_copy_remaining_to(const index_tuple<IdxPack...>&, Iterator p)
   {
      if(!this->used_){
         alloc_traits::construct( this->a_
                                , container_detail::to_raw_pointer(&*p)
                                , ::boost::container::container_detail::
                                    stored_ref<Args>::forward(get<IdxPack>(this->args_))...
                                );
         this->used_ = true;
      }
   }

   protected:
   A &a_;
   tuple<Args&...> args_;
   bool used_;
};

//This class template will adapt emplace construction insertions of movable types
//to advanced_insert_aux_int
template<class A, class Iterator, class ...Args>
struct advanced_insert_aux_emplace
   :  public advanced_insert_aux_non_movable_emplace<A, Iterator, Args...>
{
   typedef advanced_insert_aux_non_movable_emplace<A, Iterator, Args...> base_t;
   typedef boost::container::allocator_traits<A> alloc_traits;
   typedef typename base_t::value_type       value_type;
   typedef typename base_t::difference_type  difference_type;
   typedef typename base_t::index_tuple_t    index_tuple_t;

   explicit advanced_insert_aux_emplace(A &a, Args&&... args)
      : base_t(a, ::boost::forward<Args>(args)...)
   {}

   ~advanced_insert_aux_emplace()
   {}

   //Override only needed functions
   virtual void copy_remaining_to(Iterator p)
   {  this->priv_copy_remaining_to(index_tuple_t(), p);   }

   virtual void copy_some_and_update(Iterator p, difference_type division_count, bool first_n)
   {  this->priv_copy_some_and_update(index_tuple_t(), p, division_count, first_n);  }

   private:
   template<int ...IdxPack>
   void priv_copy_remaining_to(const index_tuple<IdxPack...>&, Iterator p)
   {
      if(!this->used_){
         aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
         value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));
         alloc_traits::construct(this->a_, vp,
            ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...);
         scoped_destructor<A> d(this->a_, vp);
         *p = ::boost::move(*vp);
         d.release();
         this->used_ = true;
      }
   }

   template<int ...IdxPack>
   void priv_copy_some_and_update(const index_tuple<IdxPack...>&, Iterator p, difference_type division_count, bool first_n)
   {
      BOOST_ASSERT(division_count <=1);
      if((first_n && division_count == 1) || (!first_n && division_count == 0)){
         if(!this->used_){
            aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
            value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));
            alloc_traits::construct(this->a_, vp,
               ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...);
            try {
               *p = ::boost::move(*vp);
            } catch (...) {
               alloc_traits::destroy(this->a_, vp);
               throw;
            }
            alloc_traits::destroy(this->a_, vp);
            this->used_ = true;
         }
      }
   }
};

}}}   //namespace boost { namespace container { namespace container_detail {

#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING

#include <boost/container/detail/preprocessor.hpp>
#include <boost/container/detail/value_init.hpp>

namespace boost {
namespace container {
namespace container_detail {

#define BOOST_PP_LOCAL_MACRO(n)                                                     \
template<class A, class Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) >        \
struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), arg)  \
   :  public advanced_insert_aux_int<Iterator>                                      \
{                                                                                \
   typedef boost::container::allocator_traits<A> alloc_traits;                      \
   typedef typename allocator_traits<A>::size_type size_type;                       \
   typedef typename allocator_traits<A>::value_type value_type;                     \
   typedef typename advanced_insert_aux_int<Iterator>::difference_type              \
      difference_type;                                                              \
                                                                                \
   BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_non_movable_emplace, n), arg)      \
      ( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )          \
      : a_(a)                                                                       \
      , used_(false)                                                                \
      BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_INIT, _)                   \
    {}                                                                              \
                                                                                \
   virtual void copy_remaining_to(Iterator)                                         \
   {  BOOST_ASSERT(false);   }                                                      \
                                                                                \
   virtual void uninitialized_copy_remaining_to(Iterator p)                         \
   {                                                                                \
      if(!this->used_){                                                             \
         alloc_traits::construct                                                    \
            ( this->a_                                                              \
            , container_detail::to_raw_pointer(&*p)                                 \
            BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)         \
            );                                                                      \
         this->used_ = true;                                                        \
      }                                                                             \
   }                                                                                \
                                                                                \
   virtual void uninitialized_copy_some_and_update                                  \
      (Iterator p, difference_type division_count, bool first_n)                    \
   {                                                                                \
      BOOST_ASSERT(division_count <=1);                                             \
      if((first_n && division_count == 1) || (!first_n && division_count == 0)){    \
         if(!this->used_){                                                          \
            alloc_traits::construct                                                 \
               ( this->a_                                                           \
               , container_detail::to_raw_pointer(&*p)                              \
               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)      \
               );                                                                   \
            this->used_ = true;                                                     \
         }                                                                          \
      }                                                                             \
   }                                                                                \
                                                                                \
   virtual void copy_some_and_update(Iterator, difference_type, bool)               \
   {  BOOST_ASSERT(false);   }                                                      \
                                                                                \
   A &a_;                                                                           \
   bool used_;                                                                      \
   BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _)                           \
};                                                                                \
                                                                                \
template<class A, class Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) >        \
struct BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)              \
   : BOOST_PP_CAT(BOOST_PP_CAT(                                                     \
      advanced_insert_aux_non_movable_emplace, n), arg)                             \
         < A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P) >                        \
{                                                                                \
   typedef BOOST_PP_CAT(BOOST_PP_CAT(                                               \
      advanced_insert_aux_non_movable_emplace, n), arg)                             \
         <A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P) > base_t;                 \
   typedef typename base_t::value_type       value_type;                            \
   typedef typename base_t::difference_type  difference_type;                       \
   typedef boost::container::allocator_traits<A> alloc_traits;                      \
                                                                                \
   BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg)                  \
      ( A &a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) )          \
      : base_t(a BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) )   \
    {}                                                                              \
                                                                                \
   virtual void copy_remaining_to(Iterator p)                                       \
   {                                                                                \
      if(!this->used_){                                                             \
         aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;    \
         value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));       \
         alloc_traits::construct(this->a_, vp                                       \
            BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));       \
         scoped_destructor<A> d(this->a_, vp);                                      \
         *p = ::boost::move(*vp);                                                     \
         d.release();                                                               \
         this->used_ = true;                                                        \
      }                                                                             \
   }                                                                                \
                                                                                \
   virtual void copy_some_and_update                                                \
      (Iterator p, difference_type division_count, bool first_n)                    \
   {                                                                                \
      BOOST_ASSERT(division_count <=1);                                             \
      if((first_n && division_count == 1) || (!first_n && division_count == 0)){    \
         if(!this->used_){                                                          \
            aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v; \
            value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));    \
            alloc_traits::construct(this->a_, vp                                    \
               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _));    \
            scoped_destructor<A> d(this->a_, vp);                                   \
            *p = ::boost::move(*vp);                                                  \
            d.release();                                                            \
            this->used_ = true;                                                     \
         }                                                                          \
      }                                                                             \
   }                                                                                \
};                                                                                \
//!

#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
#include BOOST_PP_LOCAL_ITERATE()

}}}   //namespace boost { namespace container { namespace container_detail {

#endif   //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING

#include <boost/container/detail/config_end.hpp>

#endif //#ifndef BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP


text:
/*
 * Distrubuted under The MIT License (MIT)
 *
 * Copyright (c) 2016 Aaron Bishop
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/*
 * Much of this code was altered from AsyncSerial and BufferedAsyncSerial by
 * Terraneo Federico which was distributed under the Boost Software License, Version 1.0.
 */

#ifndef BREWPIPP_UTIL_BUFFERED_SERIAL_HPP
#define BREWPIPP_UTIL_BUFFERED_SERIAL_HPP

#include "util/BufferedIO.hpp"
#include <boost/asio/serial_port_base.hpp>

namespace brewpipp {
	namespace util {
		class BufferedSerial : public BufferedIO {
		public:
			BufferedSerial();
			BufferedSerial(const std::string& devname,
										const unsigned int& baud,
										const boost::asio::serial_port_base::parity& opt_parity = boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none),
										const boost::asio::serial_port_base::character_size& opt_csize = boost::asio::serial_port_base::character_size(8),
										const boost::asio::serial_port_base::flow_control& opt_flow = boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none),
										const boost::asio::serial_port_base::stop_bits& opt_stop = boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one)
										) throw(boost::system::system_error);
			void open(const std::string& devname,
								const unsigned int baud,
								const boost::asio::serial_port_base::parity& opt_parity = boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none),
								const boost::asio::serial_port_base::character_size& opt_csize = boost::asio::serial_port_base::character_size(8),
								const boost::asio::serial_port_base::flow_control& opt_flow = boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none),
								const boost::asio::serial_port_base::stop_bits& opt_stop = boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one)
								) throw(boost::system::system_error);
		};
	}
}

#endif //BREWPIPP_UTIL_BUFFERED_SERIAL_HPP


text:
//==================================================================================================
/*!
  @file

  Copyright 2016 NumScale SAS

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#include <boost/simd/pack.hpp>
#include <boost/simd/function/tenpower.hpp>
#include <boost/simd/function/bits.hpp>
#include <boost/simd/meta/cardinal_of.hpp>
#include <simd_test.hpp>
#include <boost/simd/constant/inf.hpp>
#include <boost/simd/constant/minf.hpp>
#include <boost/simd/constant/mone.hpp>
#include <boost/simd/constant/zero.hpp>
#include <boost/simd/constant/nan.hpp>
#include <boost/simd/constant/one.hpp>
#include <boost/simd/constant/two.hpp>
#include <boost/simd/constant/mtwo.hpp>
#include <boost/simd/constant/constant.hpp>
#include <boost/simd/constant/ratio.hpp>

template <typename T, int N, typename Env>
void test(Env& $)
{
  namespace bs = boost::simd;
  namespace bd = boost::dispatch;
  using p_t = bs::pack<T, N>;
  using fT =  bd::as_floating_t<T>;
  using f_t = bs::pack<fT, N>;

  T a1[N];
  fT b[N];
  for(int i = 0; i < N; ++i)
  {
    a1[i] = (i%2) ? T(i) : T(-i);
    b[i] = bs::tenpower(a1[i]) ;
  }
  p_t aa1(&a1[0], &a1[0]+N);
  f_t bb (&b[0], &b[0]+N);
  STF_ULP_EQUAL(bs::tenpower(aa1), bb, 0.5);
}

STF_CASE_TPL("Check tenpower on pack" , (int32_t)(int64_t)(uint32_t)(uint64_t))//STF_NUMERIC_TYPES)
{
  namespace bs = boost::simd;
  using p_t = bs::pack<T>;
  static const std::size_t N = bs::cardinal_of<p_t>::value;
  test<T, N>($);
  test<T, N/2>($);
  test<T, N*2>($);
}

STF_CASE_TPL (" tenpower unsigned_int", STF_UNSIGNED_INTEGRAL_TYPES)
{
  namespace bs = boost::simd;
  namespace bd = boost::dispatch;
  using bs::tenpower;
  using p_t = bs::pack<T>;
  using r_t = decltype(tenpower(p_t()));

  STF_TYPE_IS(r_t, bd::as_floating_t<p_t>);

  // specific values tests
  STF_ULP_EQUAL(tenpower(bs::One<p_t>()), r_t(10), 0.5);
  STF_ULP_EQUAL(tenpower(bs::Two<p_t>()), r_t(100), 0.5);
  STF_ULP_EQUAL(tenpower(bs::Zero<p_t>()), bs::One<r_t>(), 0.5);
} // end of test for unsigned_int_

STF_CASE_TPL (" tenpower signed_int",  STF_SIGNED_INTEGRAL_TYPES)
{
  namespace bs = boost::simd;
  namespace bd = boost::dispatch;
  using bs::tenpower;
  using p_t = bs::pack<T>;
  using r_t = decltype(tenpower(p_t()));

  STF_TYPE_IS(r_t, bd::as_floating_t<p_t>);

  // specific values tests
  STF_ULP_EQUAL(tenpower(bs::Mone<p_t>()), r_t(1.0/10), 0.5);
  STF_ULP_EQUAL(tenpower(bs::One<p_t>()), bs::Ten<r_t>(), 0.5);
  STF_ULP_EQUAL(tenpower(bs::Two<p_t>()), r_t(100), 0.5);
  STF_ULP_EQUAL(tenpower(bs::Mtwo<p_t>()), r_t(1.0/100), 0.5);
  STF_ULP_EQUAL(tenpower(bs::Zero<p_t>()), bs::One<r_t>(), 0.5);
} // end of test for signed_int_

max_stars_repo_name: nickporubsky/boost-simd-clone

max_issues_repo_name: nickporubsky/boost-simd-clone

max_forks_repo_name: nickporubsky/boost-simd-clone


text:
#pragma once
#include <steemit/app/plugin.hpp>
#include <steemit/chain/database.hpp>

#include <graphene/db/generic_index.hpp>
#include <boost/multi_index/composite_key.hpp>

#include <fc/thread/future.hpp>
#include <fc/api.hpp>

namespace steemit { namespace follow {
using namespace chain;

#ifndef PRIVATE_MESSAGE_SPACE_ID
#define PRIVATE_MESSAGE_SPACE_ID 8
#endif

enum follow_object_type
{
   key_account_object_type = 0,
   bucket_object_type = 1,///< used in market_history_plugin
   follow_object_type = 6,
   feed_object_type   = 7
};

namespace detail { class follow_plugin_impl; }

class  follow_object : public abstract_object<follow_object> {
   public:
      static const uint8_t space_id = PRIVATE_MESSAGE_SPACE_ID;
      static const uint8_t type_id  = follow_object_type;

      string        follower;
      string        following;
      set<string>   what; /// post, comments, votes, ignore
};

class feed_object : public abstract_object<feed_object> {
   public:
      static const uint8_t space_id = PRIVATE_MESSAGE_SPACE_ID;
      static const uint8_t type_id  = feed_object_type;
      account_id_type account;
      comment_id_type comment;
};

struct follow_operation {
    string          follower;
    string          following;
    set<string>     what; /// post, comments, votes
};

struct by_following_follower;
struct by_follower_following;
struct by_id;

using namespace boost::multi_index;

typedef multi_index_container<
   follow_object,
   indexed_by<
      ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > >,
      ordered_unique< tag< by_following_follower >,
            composite_key< follow_object,
               member< follow_object, string, &follow_object::following >,
               member< follow_object, string, &follow_object::follower >
            >,
            composite_key_compare< std::less<string>, std::less<string> >
      >,
      ordered_unique< tag< by_follower_following >,
            composite_key< follow_object,
               member< follow_object, string, &follow_object::follower >,
               member< follow_object, string, &follow_object::following >
            >,
            composite_key_compare< std::less<string>, std::less<string> >
      >
   >
> follow_multi_index_type;

typedef graphene::db::generic_index< follow_object, follow_multi_index_type> follow_index;

struct by_account;
typedef multi_index_container<
    feed_object,
    indexed_by<
      ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > >,
      ordered_unique< tag< by_account >,
            composite_key< feed_object,
               member< feed_object, account_id_type, &feed_object::account >,
               member< object, object_id_type, &object::id >
            >
      >
   >
> feed_multi_index_type;

typedef graphene::db::generic_index< feed_object, feed_multi_index_type> feed_index;

class follow_plugin : public steemit::app::plugin
{
   public:
      follow_plugin();

      std::string plugin_name()const override;
      virtual void plugin_initialize(const boost::program_options::variables_map& options) override;
      virtual void plugin_startup() override{};

      friend class detail::follow_plugin_impl;
      std::unique_ptr<detail::follow_plugin_impl> my;
};

class follow_api : public std::enable_shared_from_this<follow_api> {
   public:
      follow_api(){};
      follow_api(const app::api_context& ctx):_app(&ctx.app){} void on_api_startup(){}

      vector<follow_object> get_followers( string to, string start, uint16_t limit )const;
      vector<follow_object> get_following( string from, string start, uint16_t limit )const;

   private:
      app::application* _app = nullptr;
};

} } //steemit::follow

FC_API( steemit::follow::follow_api, (get_followers)(get_following) );

FC_REFLECT_DERIVED( steemit::follow::follow_object, (graphene::db::object), (follower)(following)(what) );
FC_REFLECT( steemit::follow::follow_operation, (follower)(following)(what) )
FC_REFLECT_DERIVED( steemit::follow::feed_object, (graphene::db::object), (account)(comment) )

max_stars_repo_name: btscube/steem

max_issues_repo_name: btscube/steem

max_forks_repo_name: btscube/steem