text:
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2018 Sylko Olzscher
 *
 */

#include "close_connection.h"
#include <smf/cluster/generator.h>
#include <smf/ipt/response.hpp>
#include <cyng/async/task/base_task.h>
#include <cyng/io/serializer.h>
#include <cyng/dom/reader.h>
#include <cyng/vm/generator.h>
#include <boost/uuid/random_generator.hpp>

namespace node
{
	close_connection::close_connection(cyng::async::base_task* btp
		, cyng::logging::log_ptr logger
		, cyng::controller& vm
		, std::chrono::seconds timeout)
	: base_(*btp)
		, logger_(logger)
		, vm_(vm)
		, timeout_(timeout)
		, start_(std::chrono::system_clock::now())
		, is_waiting_(false)
	{
		CYNG_LOG_INFO(logger_, "task #"
			<< base_.get_id()
			<< " <"
			<< base_.get_class_name()
			<< "> "
			<< vm_.tag()
			<< " is running until "
			<< cyng::to_str(start_ + timeout_));
	}

	cyng::continuation close_connection::run()
	{
		if (!is_waiting_)
		{
			//
			//	update task state
			//
			is_waiting_ = true;

			//
			//	* forward connection close request to device
			//	* store sequence - task relation
			//	* start timer to check connection setup
			//

			//	prepare IP-T command: close connection request
			vm_.async_run({ cyng::generate_invoke("req.close.connection")

				//	tie IP-T sequence with this task id
				, cyng::generate_invoke("session.store.relation", cyng::invoke("ipt.seq.push"), base_.get_id(), 0u)

				//	send IP-T request
				, cyng::generate_invoke("stream.flush")

				//	logging
				, cyng::generate_invoke("log.msg.info", "client.req.close.connection.forward", cyng::invoke("ipt.seq.push"), timeout_) });

			//
			//	start monitor
			//
			base_.suspend(timeout_);
			return cyng::continuation::TASK_CONTINUE;

		}

		//
		//	timeout
		//
		CYNG_LOG_WARNING(logger_, "task #"
			<< base_.get_id()
			<< " <"
			<< base_.get_class_name()
			<< "> "
			<< vm_.tag()
			<< " timeout after "
			<< cyng::to_str(std::chrono::system_clock::now() - start_));

		if (vm_.is_halted()) {

			CYNG_LOG_WARNING(logger_, "task #"
				<< base_.get_id()
				<< " <"
				<< base_.get_class_name()
				<< "> stop (session already halted) "
				<< vm_.tag());

		}
		else
		{
			//
			//	Safe way to intentionally close this session.
			//
			//	* set session in shutdown state
			//	* close socket
			//	* update cluster master state and
			//	* remove session from IP-T masters client_map
			//
			vm_.async_run({ cyng::generate_invoke("session.state.pending")
				, cyng::generate_invoke("ip.tcp.socket.shutdown")
				, cyng::generate_invoke("ip.tcp.socket.close") });
		}

		//
		//	stop this task
		//
		return cyng::continuation::TASK_STOP;
	}

	void close_connection::stop()
	{
		//
		//	terminate task
		//
		CYNG_LOG_INFO(logger_, "task #"
			<< base_.get_id()
			<< " <"
			<< base_.get_class_name()
			<< "> is stopped");

	}

	//	slot 0
	cyng::continuation close_connection::process(ipt::response_type res)
	{
		CYNG_LOG_INFO(logger_, "task #"
			<< base_.get_id()
			<< " <"
			<< base_.get_class_name()
			<< "> received response ["
			<< ipt::tp_res_close_connection_policy::get_response_name(res)
			<< "]");

		return cyng::continuation::TASK_STOP;
	}
}

max_stars_repo_name: solosTec/node

max_issues_repo_name: solosTec/node

max_forks_repo_name: solosTec/node


text:
//----------------------------------------------------------------------------
/// @file test_spinsort.cpp
/// @brief test program of the spinsort algorithm
///
/// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n
///         Distributed under the Boost Software License, Version 1.0.\n
///         ( See accompanying file LICENSE_1_0.txt or copy at
///           http://www.boost.org/LICENSE_1_0.txt  )
/// @version 0.1
///
/// @remarks
//-----------------------------------------------------------------------------
#include <ciso646>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <random>
#include <boost/sort/spinsort/spinsort.hpp>
#include <boost/test/included/test_exec_monitor.hpp>
#include <boost/test/test_tools.hpp>

using namespace boost::sort;
using spin_detail::check_stable_sort;
using spin_detail::range_sort;
using common::range;

void test1 ( );
void test2 ( );
void test3 ( );
void test4 ( );

//---------------- stability test -----------------------------------
struct xk
{
    unsigned tail : 4;
    unsigned num : 28;
    xk ( uint32_t n =0 , uint32_t t =0): tail (t), num(n){};
    bool operator< (xk A) const { return (num < A.num); };
};

void test1 ( )
{
    typedef std::less< xk > compare_t;
    std::mt19937_64 my_rand (0);

    const uint32_t NMAX = 100000;

    std::vector< xk > V1, V2;
    V1.reserve (NMAX);
    for (uint32_t i = 0; i < 8; ++i) {
        for (uint32_t k = 0; k < NMAX; ++k) {
            uint32_t NM = my_rand ( );
            xk G;
            G.num = NM >> 3;
            G.tail = i;
            V1.push_back (G);
        };
    };
    V2 = V1;
    spinsort (V1.begin ( ), V1.end ( ), compare_t ( ));
    std::stable_sort (V2.begin ( ), V2.end ( ));

    BOOST_CHECK (V1.size ( ) == V2.size ( ));
    for (uint32_t i = 0; i < V1.size ( ); ++i) {
        BOOST_CHECK (V1[ i ].num == V2[ i ].num and
                     V1[ i ].tail == V2[ i ].tail);
    };
};

void test2 (void)
{
    typedef std::less< uint64_t > compare_t;

    const uint32_t NElem = 100000;
    std::vector< uint64_t > V1,V2;
    std::mt19937_64 my_rand (0);
    compare_t comp;

    // ------------------------ random elements -------------------------------
    for (uint32_t i = 0; i < NElem; ++i) V1.push_back (my_rand ( ) % NElem);
    V2 = V1;
    spinsort (V1.begin ( ), V1.end ( ), comp);
    std::stable_sort (V2.begin ( ), V2.end ( ), comp);
    for (unsigned i = 0; i < NElem; i++) {
        BOOST_CHECK (V2[ i ] == V1[ i ]);
    };

    // --------------------------- sorted elements ----------------------------
    V1.clear ( );
    for (uint32_t i = 0; i < NElem; ++i) V1.push_back (i);
    spinsort (V1.begin ( ), V1.end ( ), comp);
    for (unsigned i = 1; i < NElem; i++) {
        BOOST_CHECK (V1[ i - 1 ] <= V1[ i ]);
    };

    //-------------------------- reverse sorted elements ----------------------
    V1.clear ( );
    for (uint32_t i = 0; i < NElem; ++i) V1.push_back (NElem - i);
    spinsort (V1.begin ( ), V1.end ( ), comp);
    for (unsigned i = 1; i < NElem; i++) {
        BOOST_CHECK (V1[ i - 1 ] <= V1[ i ]);
    };

    //---------------------------- equal elements ----------------------------
    V1.clear ( );
    for (uint32_t i = 0; i < NElem; ++i) V1.push_back (1000);
    spinsort (V1.begin ( ), V1.end ( ), comp);
    for (unsigned i = 1; i < NElem; i++) {
        BOOST_CHECK (V1[ i - 1 ] == V1[ i ]);
    };
};

void test3 (void)
{
    typedef typename std::vector<uint64_t>::iterator    iter_t ;
    typedef range<iter_t>                               range_it ;
    std::less<uint64_t> comp ;

    std::vector<uint64_t> V = { 1,  3,  5,  7,  9, 11, 13, 15, 17, 19,
                               21, 23, 25, 27, 29, 31, 33, 35, 37, 39,
                               41, 43, 45, 47, 49, 51, 53, 55, 57, 59,
                               14,  2,  4,  6,  8, 10, 12, 16, 18, 20};
    range_it rdata (V.begin() , V.end());
    std::vector<uint64_t> aux (40,0 );
    range_it raux ( aux.begin() , aux.end());

    check_stable_sort ( rdata, raux, comp );
    for ( uint32_t i =0 ; i < V.size() ; ++i)
        std::cout<<V[i]<<", ";
    std::cout<<std::endl;

    V = {59, 57, 55, 53, 51, 49, 47, 45, 43, 41,
         39, 37, 35, 33, 31, 29, 27, 25, 23, 21,
         19, 17, 15, 13, 11,  9,  7,  5,  3,  1,
         14,  2,  6, 16, 18, 20, 12,  4,  8, 10};
    rdata = range_it (V.begin() , V.end());
    aux.assign (40,0);
    raux = range_it ( aux.begin() , aux.end());
    check_stable_sort ( rdata, raux, comp );
    for ( uint32_t i =0 ; i < V.size() ; ++i)
        std::cout<<V[i]<<", ";
    std::cout<<std::endl;

}
void test4 (void)
{
    typedef typename std::vector<xk>::iterator  iter_t;
    typedef std::less<xk>        compare_t;
    std::mt19937 my_rand (0);
    std::vector<xk> V ;
    const uint32_t NELEM = 100000;
    V.reserve(NELEM * 10);

    for (uint32_t k =0 ; k < 10 ; ++k)
    {   for ( uint32_t i =0 ; i < NELEM ; ++i)
        {   V.emplace_back(i , k);
        };
        iter_t first = V.begin() + (k * NELEM);
        iter_t last = first + NELEM ;
        std::shuffle( first, last, my_rand);
    };
    spinsort( V.begin() , V.end(), compare_t());
    for ( uint32_t i =0 ; i < ( NELEM * 10); ++i)
    {   BOOST_CHECK ( V[i].num == (i / 10) and V[i].tail == (i %10) );
    };
}
int test_main (int, char *[])
{
    test1 ( );
    test2 ( );
    test3 ( );
    test4 ( );
    return 0;
};

ext: cpp


text: #include <boost/units/dimensionless_type.hpp>

ext: hpp

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
//=======================================================================
// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
//
// 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/config.hpp>
#include <vector>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>

using namespace boost;

template < typename Graph, typename ParentMap >
struct edge_writer
{
  edge_writer(const Graph & g, const ParentMap & p)
  : m_g(g), m_parent(p)
  {
  }

  template < typename Edge >
    void operator() (std::ostream & out, const Edge & e) const
  {
    out << "[label=\"" << get(edge_weight, m_g, e) << "\"";
    typename graph_traits < Graph >::vertex_descriptor
      u = source(e, m_g), v = target(e, m_g);
    if (m_parent[v] == u)
        out << ", color=\"black\"";
    else
        out << ", color=\"grey\"";
      out << "]";
  }
  const Graph & m_g;
  ParentMap m_parent;
};
template < typename Graph, typename Parent >
edge_writer < Graph, Parent >
make_edge_writer(const Graph & g, const Parent & p)
{
  return edge_writer < Graph, Parent > (g, p);
}

struct EdgeProperties {
  int weight;
};

int
main()
{
  enum { u, v, x, y, z, N };
  char name[] = { 'u', 'v', 'x', 'y', 'z' };
  typedef std::pair < int, int >E;
  const int n_edges = 10;
  E edge_array[] = { E(u, y), E(u, x), E(u, v), E(v, u),
      E(x, y), E(x, v), E(y, v), E(y, z), E(z, u), E(z,x) };
  int weight[n_edges] = { -4, 8, 5, -2, 9, -3, 7, 2, 6, 7 };

  typedef adjacency_list < vecS, vecS, directedS,
    no_property, EdgeProperties> Graph;
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
  // VC++ can't handle the iterator constructor
  Graph g(N);
  for (std::size_t j = 0; j < n_edges; ++j)
    add_edge(edge_array[j].first, edge_array[j].second, g);
#else
  Graph g(edge_array, edge_array + n_edges, N);
#endif
  graph_traits < Graph >::edge_iterator ei, ei_end;
  property_map<Graph, int EdgeProperties::*>::type
    weight_pmap = get(&EdgeProperties::weight, g);
  int i = 0;
  for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i)
    weight_pmap[*ei] = weight[i];

  std::vector<int> distance(N, (std::numeric_limits < short >::max)());
  std::vector<std::size_t> parent(N);
  for (i = 0; i < N; ++i)
    parent[i] = i;
  distance[z] = 0;

#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
  bool r = bellman_ford_shortest_paths
    (g, int(N), weight_pmap, &parent[0], &distance[0],
     closed_plus<int>(), std::less<int>(), default_bellman_visitor());
#else
  bool r = bellman_ford_shortest_paths
    (g, int (N), weight_map(weight_pmap).distance_map(&distance[0]).
     predecessor_map(&parent[0]));
#endif

  if (r)
    for (i = 0; i < N; ++i)
      std::cout << name[i] << ": " << std::setw(3) << distance[i]
        << " " << name[parent[i]] << std::endl;
  else
    std::cout << "negative cycle" << std::endl;

  std::ofstream dot_file("figs/bellman-eg.dot");
  dot_file << "digraph D {\n"
    << "  rankdir=LR\n"
    << "  size=\"5,3\"\n"
    << "  ratio=\"fill\"\n"
    << "  edge[style=\"bold\"]\n" << "  node[shape=\"circle\"]\n";

  {
    for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
      graph_traits < Graph >::edge_descriptor e = *ei;
      graph_traits < Graph >::vertex_descriptor
        u = source(e, g), v = target(e, g);
      // VC++ doesn't like the 3-argument get function, so here
      // we workaround by using 2-nested get()'s.
      dot_file << name[u] << " -> " << name[v]
        << "[label=\"" << get(get(&EdgeProperties::weight, g), e) << "\"";
      if (parent[v] == u)
        dot_file << ", color=\"black\"";
      else
        dot_file << ", color=\"grey\"";
      dot_file << "]";
    }
  }
  dot_file << "}";
  return EXIT_SUCCESS;
}

max_stars_repo_name: zyiacas/boost-doc-zh

max_issues_repo_name: sdfict/boost-doc-zh

max_forks_repo_name: sdfict/boost-doc-zh


text:
/**
* This file is part of ORB-SLAM2.
*
* Copyright (C) 2014-2016 Raúl Mur-Artal <raulmur at unizar dot es> (University of Zaragoza)
* For more information see <https://github.com/raulmur/ORB_SLAM2>
*
* ORB-SLAM2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ORB-SLAM2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ORB-SLAM2. If not, see <http://www.gnu.org/licenses/>.
*/

#include<iostream>
#include<algorithm>
#include<fstream>
#include<chrono>

#include<ros/ros.h>
#include <cv_bridge/cv_bridge.h>

#include<opencv2/core/core.hpp>

#include"../../ORB_SLAM2/include/System.h"
#include <geometry_msgs/PoseStamped.h>

//Eigen
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/Geometry>

#include <opencv2/core/eigen.hpp>

using namespace std;

class ImageGrabber
{
public:
    ImageGrabber(ORB_SLAM2::System* pSLAM):mpSLAM(pSLAM){}

    void GrabImage(const sensor_msgs::ImageConstPtr& msg);

    ORB_SLAM2::System* mpSLAM;
};

ros::Publisher  pose_pub;

int main(int argc, char **argv)
{
    ros::init(argc, argv, "Mono");
    ros::start();

    if(argc != 3)
    {
        cerr << endl << "Usage: rosrun ORB_SLAM2 Mono path_to_vocabulary path_to_settings" << endl;
        ros::shutdown();
        return 1;
    }

    // Create SLAM system. It initializes all system threads and gets ready to process frames.
    ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true);

    ImageGrabber igb(&SLAM);

    ros::NodeHandle nodeHandler;

    pose_pub = nodeHandler.advertise<geometry_msgs::PoseStamped>("/cam_pose",1);
    ros::Subscriber sub = nodeHandler.subscribe("/image_raw", 1, &ImageGrabber::GrabImage,&igb);

    ros::spin();

    // Stop all threads
    SLAM.Shutdown();

    // Save camera trajectory
    SLAM.SaveKeyFrameTrajectoryTUM("KeyFrameTrajectory.txt");

    ros::shutdown();

    return 0;
}

void ImageGrabber::GrabImage(const sensor_msgs::ImageConstPtr& msg)
{
    // Copy the ros image message to cv::Mat.
    cv_bridge::CvImageConstPtr cv_ptr;
    try
    {
        cv_ptr = cv_bridge::toCvShare(msg);
    }
    catch (cv_bridge::Exception& e)
    {
        ROS_ERROR("cv_bridge exception: %s", e.what());
        return;
    }

    cv::Mat Tcw = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());

    Eigen::Matrix4f cam_pose_temp;
    cv2eigen(Tcw,cam_pose_temp);

    Eigen::Matrix3f Rwc = cam_pose_temp.block<3,3>(0,0);
	Eigen::Quaternionf q(Rwc);

    geometry_msgs::PoseStamped pose_msg;
    pose_msg.pose.position.x = cam_pose_temp(0,3);
    pose_msg.pose.position.y = cam_pose_temp(1,3);
    pose_msg.pose.position.z = cam_pose_temp(2,3);
    pose_msg.pose.orientation.x = q.x();
    pose_msg.pose.orientation.y = q.y();
    pose_msg.pose.orientation.z = q.z();
    pose_msg.pose.orientation.w = q.w();
    pose_msg.header = msg->header;
    pose_pub.publish(pose_msg);
}

ext: cc


text:
/**
 * Copyright (C) 2020 Xilinx, Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License"). You may
 * not use this file except in compliance with the License. A copy of the
 * License is located at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

// ------ I N C L U D E   F I L E S -------------------------------------------
// Local - Include Files
#include "SubCmdStatus.h"

#include "common/system.h"
#include "common/device.h"
#include "common/xclbin_parser.h"
#include "flash/flasher.h"
#include "core/common/error.h"
#include "core/common/query_requests.h"
#include "core/common/utils.h"
#include "core/common/message.h"

#include "tools/common/XBUtilities.h"
namespace XBU = XBUtilities;

// 3rd Party Library - Include Files
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include <boost/program_options.hpp>
namespace po = boost::program_options;

// System - Include Files
#include <iostream>

// ----- C L A S S   M E T H O D S -------------------------------------------

namespace {

static bool
same_config(DSAInfo& board, DSAInfo& installed) {
  if (!board.name.empty()) {
    bool same_dsa = ((installed.name == board.name) &&
      (installed.matchId(board)));
    bool same_bmc = ((board.bmcVer.empty()) ||
      (installed.bmcVer == board.bmcVer));
    return same_dsa && same_bmc;
  }
  return false;
}

}
//end unnamed namespace

SubCmdStatus::SubCmdStatus(bool _isHidden, bool _isDepricated, bool _isPreliminary)
    : SubCmd("status",
             "Returns detail information for the specified device.")
{
  const std::string longDescription = "This command will 'examine' the state of the system/device and will"
                                      " generate a report of interest in a text or JSON format.";
  setLongDescription(longDescription);
  setExampleSyntax("");
  setIsHidden(_isHidden);
  setIsDeprecated(_isDepricated);
  setIsPreliminary(_isPreliminary);
}

void
SubCmdStatus::execute(const SubCmdOptions& _options) const
{
  XBU::verbose("SubCommand: status");

  XBU::verbose("Option(s):");
  for (auto & aString : _options) {
    std::string msg = "   ";
    msg += aString;
    XBU::verbose(msg);
  }

  // -- Retrieve and parse the subcommand options -----------------------------
  std::string device = "";
  std::string report = "";
  std::string format = "text";
  std::string output;
  bool help = false;

  po::options_description queryDesc("Options");  // Note: Boost will add the colon.
  queryDesc.add_options()
    ("device,d", boost::program_options::value<decltype(device)>(&device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest.  A value of 'all' (default) indicates that every found device should be examined.")
    ("report,r", boost::program_options::value<decltype(report)>(&report)->implicit_value("scan"), "The type of report to be produced. Reports currently available are:\n"
                                                                           "  all         - All known reports are produced\n"
                                                                           "  scan        - Terse report of found devices (default)\n"
                                                                           "  electrical  - Voltages, currents, and power\n"
                                                                           "                consumption on the device\n"
                                                                           "  temperature - Temperatures across the device\n"
                                                                           "  os-info     - Information relating to the operating\n"
                                                                           "                system and drivers\n"
                                                                           "  debug-ip    - Debug IP Status\n"
                                                                           "  fans        - Fan status")
    ("format,f", boost::program_options::value<decltype(format)>(&format), "Report output format. Valid values are:\n"
                                                                           "  text        - Human readable report (default)\n"
                                                                           "  json-2020.1 - JSON 2020.1 schema")
    ("output,o", boost::program_options::value<decltype(output)>(&output), "Direct the output to the given file")
    ("help,h", boost::program_options::bool_switch(&help), "Help to use this sub-command")
  ;

  // Parse sub-command ...
  po::variables_map vm;

  try {
    po::store(po::command_line_parser(_options).options(queryDesc).run(), vm);
    po::notify(vm); // Can throw
  } catch (po::error& e) {
    std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
    printHelp(queryDesc);
    throw; // Re-throw exception
  }

  // Check to see if help was requested or no command was found
  if (help == true)  {
    printHelp(queryDesc);
    return;
  }

  // -- Now process the subcommand --------------------------------------------
  // get all device IDs to be processed
  std::vector<uint16_t> device_indices;
  XBU::parse_device_indices(device_indices, device);

  if(!report.empty()) {

    if(report.compare("all") == 0)
      std::cout << "TODO: implement ALL report\n";
    else if(report.compare("temperature") == 0)
      std::cout << "TODO: implement TEMP report\n";
    else if(report.compare("electrical") == 0)
      std::cout << "TODO: implement ELECTRICAL report\n";
    else if(report.compare("os-info") == 0)
      std::cout << "TODO: implement OS-INFO report\n";
    else if(report.compare("debug-ip") == 0)
      std::cout << "TODO: implement DEBUG-IP report\n";
    else if(report.compare("fans") == 0)
      std::cout << "TODO: implement FANS report\n";
    else if(report.compare("scan") == 0) {
      std::vector<std::string> bdf_list;
      XBU::verbose("Sub command: --report");

      std::vector<Flasher> flasher_list;
      for(auto& idx : device_indices) {
        Flasher f(idx);
        if(!f.isValid()) {
          xrt_core::error(boost::str(boost::format("%d is an invalid index") % idx));
          continue;
        }
        DSAInfo board = f.getOnBoardDSA();
        std::vector<DSAInfo> installedDSA = f.getInstalledDSA();

        BoardInfo info;
        f.getBoardInfo(info);
        std::cout << boost::format("%s : %d\n") % "Device BDF" % f.sGetDBDF();
        std::cout << boost::format("  %-20s : %s\n") % "Card type" % board.board;
        std::cout << boost::format("  %-20s : %s\n") % "Flash type" % f.sGetFlashType();

        std::cout << "Flashable partition running on FPGA\n";
        std::cout << boost::format("  %-20s : %s\n") % "Platform" % board.name;
        std::cout << boost::format("  %-20s : %s\n") % "SC Version" % board.bmcVer;
        std::cout << boost::format("  %-20s : 0x%x\n") % "Platform ID" % board.timestamp;

        std::cout << "\nFlashable partitions installed in system\n";
        std::cout << boost::format("  %-20s : %s\n") % "Platform" % installedDSA.front().name;
        std::cout << boost::format("  %-20s : %s\n") % "SC Version" % installedDSA.front().bmcVer;
        std::cout << boost::format("  %-20s : 0x%x\n") % "Platform ID" % installedDSA.front().timestamp;
        std::cout << "----------------------------------------------------\n";

        //check if the platforms on the machine and card match
        if(!same_config(board, installedDSA.front())) {
          bdf_list.push_back(f.sGetDBDF());
        }
      }

      //if the device configuration doesn't match the config on the machine, warn the user
      for(const auto& bdf : bdf_list)
        std::cout << boost::format("%-8s : %s %s\n") % "WARNING" % bdf % "is not up-to-date." ;
    }
    else
      throw xrt_core::error("Please specify a valid value");
  }
}


text:
//=======================================================================
// Copyright 2001 University of Notre Dame.
// Author: Jeremy G. Siek
//
// 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/config.hpp>
#include <boost/test/minimal.hpp>
#include <stdlib.h>

#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_archetypes.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/random.hpp>

#include <boost/random/mersenne_twister.hpp>

template <typename ColorMap, typename ParentMap,
  typename DiscoverTimeMap, typename FinishTimeMap>
class dfs_test_visitor {
  typedef typename boost::property_traits<ColorMap>::value_type ColorValue;
  typedef typename boost::color_traits<ColorValue> Color;
public:
  dfs_test_visitor(ColorMap color, ParentMap p, DiscoverTimeMap d,
                   FinishTimeMap f)
    : m_color(color), m_parent(p),
    m_discover_time(d), m_finish_time(f), m_time(0) { }

  template <class Vertex, class Graph>
  void initialize_vertex(Vertex u, Graph&) {
    BOOST_CHECK( boost::get(m_color, u) == Color::white() );
  }
  template <class Vertex, class Graph>
  void start_vertex(Vertex u, Graph&) {
    BOOST_CHECK( boost::get(m_color, u) == Color::white() );
  }
  template <class Vertex, class Graph>
  void discover_vertex(Vertex u, Graph&) {
    using namespace boost;
    BOOST_CHECK( get(m_color, u) == Color::gray() );
    BOOST_CHECK( get(m_color, get(m_parent, u)) == Color::gray() );

    put(m_discover_time, u, m_time++);
  }
  template <class Edge, class Graph>
  void examine_edge(Edge e, Graph& g) {
    using namespace boost;
    BOOST_CHECK( get(m_color, source(e, g)) == Color::gray() );
  }
  template <class Edge, class Graph>
  void tree_edge(Edge e, Graph& g) {
    using namespace boost;
    BOOST_CHECK( get(m_color, target(e, g)) == Color::white() );

    put(m_parent, target(e, g), source(e, g));
  }
  template <class Edge, class Graph>
  void back_edge(Edge e, Graph& g) {
    using namespace boost;
    BOOST_CHECK( get(m_color, target(e, g)) == Color::gray() );
  }
  template <class Edge, class Graph>
  void forward_or_cross_edge(Edge e, Graph& g) {
    using namespace boost;
    BOOST_CHECK( get(m_color, target(e, g)) == Color::black() );
  }
  template <class Vertex, class Graph>
  void finish_vertex(Vertex u, Graph&) {
    using namespace boost;
    BOOST_CHECK( get(m_color, u) == Color::black() );

    put(m_finish_time, u, m_time++);
  }
private:
  ColorMap m_color;
  ParentMap m_parent;
  DiscoverTimeMap m_discover_time;
  FinishTimeMap m_finish_time;
  typename boost::property_traits<DiscoverTimeMap>::value_type m_time;
};

template <typename Graph>
struct dfs_test
{
  typedef boost::graph_traits<Graph> Traits;
  typedef typename Traits::vertices_size_type
    vertices_size_type;

  static void go(vertices_size_type max_V) {
    using namespace boost;
    typedef typename Traits::vertex_descriptor vertex_descriptor;
    typedef typename boost::property_map<Graph,
      boost::vertex_color_t>::type ColorMap;
    typedef typename boost::property_traits<ColorMap>::value_type ColorValue;
    typedef typename boost::color_traits<ColorValue> Color;

    vertices_size_type i, k;
    typename Traits::edges_size_type j;
    typename Traits::vertex_iterator vi, vi_end, ui, ui_end;

    boost::mt19937 gen;

    for (i = 0; i < max_V; ++i)
      for (j = 0; j < i*i; ++j) {
        Graph g;
        generate_random_graph(g, i, j, gen);

        ColorMap color = get(boost::vertex_color, g);
        std::vector<vertex_descriptor> parent(num_vertices(g));
        for (k = 0; k < num_vertices(g); ++k)
          parent[k] = k;
        std::vector<int> discover_time(num_vertices(g)),
          finish_time(num_vertices(g));

        dfs_test_visitor<ColorMap, vertex_descriptor*,
          int*, int*> vis(color, &parent[0],
                          &discover_time[0], &finish_time[0]);

        boost::depth_first_search(g, visitor(vis).color_map(color));

        // all vertices should be black
        for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
          BOOST_CHECK(get(color, *vi) == Color::black());

        // check parenthesis structure of discover/finish times
        // See CLR p.480
        for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui)
          for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
            vertex_descriptor u = *ui, v = *vi;
            if (u != v) {
              BOOST_CHECK( finish_time[u] < discover_time[v]
                          || finish_time[v] < discover_time[u]
                          || (discover_time[v] < discover_time[u]
                               && finish_time[u] < finish_time[v]
                               && boost::is_descendant(u, v, &parent[0]))
                          || (discover_time[u] < discover_time[v]
                               && finish_time[v] < finish_time[u]
                               && boost::is_descendant(v, u, &parent[0]))
                        );
            }
          }
      }

  }
};

// usage: dfs.exe [max-vertices=15]

int test_main(int argc, char* argv[])
{
  int max_V = 7;
  if (argc > 1)
    max_V = atoi(argv[1]);

  // Test directed graphs.
  dfs_test< boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,
           boost::property<boost::vertex_color_t, boost::default_color_type> >
    >::go(max_V);
  // Test undirected graphs.
  dfs_test< boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
           boost::property<boost::vertex_color_t, boost::default_color_type> >
    >::go(max_V);

  return 0;
}

max_stars_repo_name: randolphwong/mcsema

max_issues_repo_name: randolphwong/mcsema

max_forks_repo_name: randolphwong/mcsema


text:
#include "trajopt/collision_checker.hpp"
#include "trajopt/rave_utils.hpp"
#include <boost/foreach.hpp>
#include "utils/eigen_conversions.hpp"
#include "utils/logging.hpp"
using namespace OpenRAVE;

namespace trajopt {

#if 0
void CollisionPairIgnorer::AddExcludes(const CollisionPairIgnorer& other) {
  m_pairs.insert(other.m_pairs.begin(), other.m_pairs.end());
}
#endif

boost::shared_ptr<CollisionChecker> CollisionChecker::GetOrCreate(OR::EnvironmentBase& env) {
  UserDataPtr ud = GetUserData(env, "trajopt_cc");
  if (!ud) {
    LOG_INFO("creating bullet collision checker for environment");
    ud =  CreateCollisionChecker(env.shared_from_this());
    SetUserData(env, "trajopt_cc", ud);
  }
  else {
    LOG_DEBUG("already have a collision checker for this environment");
  }
  return boost::dynamic_pointer_cast<CollisionChecker>(ud);
}

#if 0
void CollisionPairIgnorer::ExcludePair(const KinBody::Link& link1, const KinBody::Link& link2) {

  m_pairs.insert(LinkPair(&link1, &link2));
  m_pairs.insert(LinkPair(&link2, &link1));
}
bool CollisionPairIgnorer::CanCollide(const KinBody::Link& link1, const KinBody::Link& link2) const {
  return m_pairs.find(LinkPair(&link1, &link2)) == m_pairs.end();
}
#endif

void CollisionChecker::IgnoreSelfCollisions(OpenRAVE::KinBodyPtr body) {
  LOG_DEBUG("IgnoreSelfCollisions for %s", body->GetName().c_str());
  const std::vector<KinBody::LinkPtr>& links = body->GetLinks();

  // Copy self-collision link information from the kinbody.
  const std::vector<int> &non_adjacent_links = body->GetNonAdjacentLinks(0);
  BOOST_FOREACH(int link_pair, non_adjacent_links) {
    int const i = ((link_pair >> 0) & 0xFFFF);
    int const j = ((link_pair >> 16) & 0xFFFF);

    LOG_DEBUG("ignoring self-collision: %s %s",
              links[i]->GetName().c_str(), links[j]->GetName().c_str());
    ExcludeCollisionPair(*links[i], *links[j]);
  }

  // Add grabbed-object adjacency information if the object is a robot.
  if (body->IsRobot()) {
    OpenRAVE::RobotBasePtr robot = boost::dynamic_pointer_cast<RobotBase>(body);

    std::vector<OpenRAVE::KinBodyPtr> grabbed_bodies;
    robot->GetGrabbed(grabbed_bodies);

    BOOST_FOREACH(const OpenRAVE::KinBodyPtr &grabbed_body, grabbed_bodies) {
      std::list<KinBody::LinkConstPtr> ignore_links;
      robot->GetIgnoredLinksOfGrabbed(grabbed_body, ignore_links);

      BOOST_FOREACH(const KinBody::LinkConstPtr& robot_link, ignore_links) {
        LOG_DEBUG("ignoring grabbed-collision: %s %s",
                  grabbed_body->GetName().c_str(),
                  robot_link->GetName().c_str());

        BOOST_FOREACH(const KinBody::LinkPtr& grabbed_link,
                      grabbed_body->GetLinks()) {
          ExcludeCollisionPair(*grabbed_link, *robot_link);
        }
      }
    }
  }

  LOG_DEBUG("------");
}

void CollisionChecker::IgnoreSelfCollisions() {

  vector<KinBodyPtr> bodies;
  GetEnv()->GetBodies(bodies);

  BOOST_FOREACH(const KinBodyPtr& body, bodies) {
    IgnoreSelfCollisions(body);
  }
}

std::ostream& operator<<(std::ostream& o, const Collision& c) {
  o << (c.linkA ? c.linkA->GetName() : "NULL") << "--" <<  (c.linkB ? c.linkB->GetName() : "NULL") <<
      " distance: " << c.distance <<
      " normal: " << c.normalB2A <<
      " ptA: " << c.ptA <<
      " ptB: " << c.ptB <<
      " time: " << c.time <<
      " weight: " << c.weight;
  return o;
}

}

max_stars_repo_name: nehagarg/trajopt

max_issues_repo_name: nehagarg/trajopt

max_forks_repo_name: nehagarg/trajopt


text:
/* Copyright John Reid 2007
*/

#include "bio-pch.h"

#include "bio/application.h"
#include "bio/remo.h"
#include "bio/remo_analysis.h"
#include "bio/pair_analysis.h"
#include "bio/biobase_binding_model.h"
#include "bio/biobase_score.h"
USING_BIO_NS

#include <boost/foreach.hpp>
#include <boost/regex.hpp>
namespace po = boost::program_options;

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

struct BinderRegexFilter
{
	const boost::regex r;
	BinderRegexFilter( const std::string & pattern )
		: r( pattern )
	{
	}

	bool
	operator()( const BindingModel::hit_t & hit )
	{
		return regex_search( hit.get_binder()->get_name(), r );
	}

	bool
	operator()( const Matrix::map_t::value_type & v )
	{
		return regex_search( BiobaseDb::singleton().get_entry< MATRIX_DATA >( v.first )->get_name(), r );
	}

	bool
	operator()( const Site::map_t::value_type & v )
	{
		Site * site = BiobaseDb::singleton().get_entry< SITE_DATA >( v.first );

		//make sure it is a consensus sequence
		return "CONS" == site->id.factor && regex_search( site->get_name(), r );
	}
};

struct PairAnalysisApp : Application, AnalysisVisitor
{
	unsigned num_output;
	PairStatistics< BindingModel > pair_statistics;
	std::string binder_regex_pattern;
	std::string input;
	std::string output;
	bool analyse_distances;
	bool analyse_singles;
	bool analyse_clusters;
	boost::scoped_ptr< BinderRegexFilter > binder_filter;

	PairAnalysisApp()
	{
		get_options().add_options()
			( "input,i", po::value( &input )->default_value( "" ), "serialised statistics" )
			( "regex,r", po::value( &binder_regex_pattern )->default_value( "." ), "regex to match binder names" )
			( "distance,d", po::value( &pair_statistics.distance) ->default_value( 15 ), "distance apart pairs can be" )
			( "num_output,n", po::value( &num_output )->default_value( 16 ), "how many pairs to output" )
			( "output,o", po::value( &output )->default_value( "" ), "where to serialise statistics to" )
			( "distances", po::value( &analyse_distances )->default_value( true ), "analyse distances between pairs" )
			( "clusters", po::value( &analyse_clusters )->default_value( true ), "analyse clusters" )
			( "singles", po::value( &analyse_singles )->default_value( true ), "analyse singles" )
			;

		add_analysis_options(get_options());
	}

	bool visit_sequence_group(const std::string & seq_group_name)
	{
		return true;
	}

	void visit_remo(
		const std::string & seq_group_name,
		ReMoLocation location,
		const ReMoRange & range,
		const std::string & remo_name,
		bifa_hits_t & results,
		const seq_t & sequence)
	{
		typedef bifa_hits_t::index< BindingHitSet< BindingModel >::position >::type by_position_t;
		const by_position_t & by_position = results.get< BindingHitSet< BindingModel >::position >();
		pair_statistics.add_hits(
			seq_group_name,
			make_filter_iterator( *binder_filter, by_position.begin(), by_position.end() ),
			make_filter_iterator( *binder_filter, by_position.end(), by_position.end() ),
			sequence.length() );
	}

	int task()
	{
		cout << "Finding doubles not further than " << pair_statistics.distance << " apart\n";
		cout << "Outputting " << num_output << " most significant doubles\n";

		if( "." != binder_regex_pattern )
		{
			cout << "Using filter on binders: \"" << binder_regex_pattern << "\"\n";
		}
		binder_filter.reset( new BinderRegexFilter( binder_regex_pattern ) );
		//check we match some pssms
		{
			BindingModel::set_t model_universe;
			transform_biobase_sites_and_matrices(
				*binder_filter,
				Link2BiobaseBindingModel( BioEnvironment::singleton().get_tf_binding_prior(), false ),
				std::inserter( model_universe, model_universe.begin() ) );
			if( model_universe.empty() )
			{
				throw std::logic_error( "Regex pattern does not match any PSSMs" );
			}
			cout << "PSSMS that match filter:\n";
			BOOST_FOREACH( BindingModel * model, model_universe )
			{
				cout << model->get_name() << "\n";
			}
		}

		//deserialise analysis and examine unless have already done so
		if ("" == input)
		{
			deserialise_analysis();

			visit_remo_analysis();
			pair_statistics.num_remos = num_remos;
			pair_statistics.num_bases = num_bases;
		}
		else
		{
			cout << "Deserialising statistics from \"" << input << "\"\n";
			std::ifstream stream(input.c_str(), std::ios::binary);

			boost::archive::binary_iarchive(stream) >> pair_statistics;
		}

		if( analyse_distances )
		{
			cout << "Analysing distances\n";
			pair_statistics.analyse_distances( num_output );
		}

		if( analyse_singles )
		{
			cout << "Analysing singles\n";
			pair_statistics.analyse_singles( num_output );
		}

		if( analyse_clusters )
		{
			cout << "Analysing clusters\n";
			pair_statistics.analyse_clusters( num_output );
		}

		if ("" != output)
		{
			cout << "Serialising statistics to \"" << output << "\"\n";
			std::ofstream stream(output.c_str(), std::ios::binary);

			boost::archive::binary_oarchive(stream) << const_cast< const PairStatistics< BindingModel > & >(pair_statistics);
		}

		return 0;
	}
};

int
main(int argc, char * argv[])
{
	return PairAnalysisApp().main(argc, argv);
}

max_stars_repo_name: JohnReid/biopsy

max_issues_repo_name: JohnReid/biopsy

max_forks_repo_name: JohnReid/biopsy


text:
/* boost random/exponential_distribution.hpp header file
 *
 * Copyright Jens Maurer 2000-2001
 * Permission to use, copy, modify, sell, and distribute this software
 * is hereby granted without fee provided that the above copyright notice
 * appears in all copies and that both that copyright notice and this
 * permission notice appear in supporting documentation,
 *
 * Jens Maurer makes no representations about the suitability of this
 * software for any purpose. It is provided "as is" without express or
 * implied warranty.
 *
 * See http://www.boost.org for most recent version including documentation.
 *
 * $Id: exponential_distribution.hpp 11696 2001-11-14 21:53:38Z jmaurer $
 *
 * Revision history
 *  2001-02-18  moved to individual header files
 */

#ifndef BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP
#define BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP

#include <cmath>
#include <cassert>
#include <boost/random/uniform_01.hpp>

namespace boost {

// exponential distribution: p(x) = lambda * exp(-lambda * x)
template<class UniformRandomNumberGenerator, class RealType = double>
class exponential_distribution
{
public:
  typedef UniformRandomNumberGenerator base_type;
  typedef RealType result_type;

  exponential_distribution(base_type& rng, result_type lambda)
    : _rng(rng), _lambda(lambda) { assert(lambda > 0); }
  // compiler-generated copy ctor is fine
  // uniform_01 cannot be assigned, neither can this class
  result_type operator()()
  {
#ifndef BOOST_NO_STDC_NAMESPACE
    using std::log;
#endif
    return -1.0 / _lambda * log(1-_rng());
  }

#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
  friend bool operator==(const exponential_distribution& x,
                         const exponential_distribution& y)
  { return x._lambda == y._lambda && x._rng == y._rng; }
#else
  // Use a member function
  bool operator==(const exponential_distribution& rhs) const
  { return _lambda == rhs._lambda && _rng == rhs._rng;  }
#endif
private:
  uniform_01<base_type, RealType> _rng;
  const result_type _lambda;
};

} // namespace boost

#endif // BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP


text:
/* Unit testing for outcomes
(C) 2013-2021 Niall Douglas <http://www.nedproductions.biz/> (1 commit)

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

#include <boost/outcome/outcome.hpp>
#include <boost/outcome/try.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_monitor.hpp>

namespace issues247
{
  namespace outcome = BOOST_OUTCOME_V2_NAMESPACE;

  outcome::result<int> foo1()
  {
    outcome::result<int> ret(boost::system::errc::invalid_argument);
    outcome::hooks::set_spare_storage(&ret, 43);
    return ret;
  }

  outcome::result<int> test1()
  {
    BOOST_OUTCOME_TRY(foo1());
    return 7;
  }

  outcome::result<int> foo2() { return outcome::success(5, 43); }

  outcome::result<int> test2() { return foo2(); }

  outcome::outcome<int> foo3()
  {
    outcome::outcome<int> ret(boost::copy_exception(std::runtime_error("foo")));
    outcome::hooks::set_spare_storage(&ret, 43);
    return ret;
  }

  outcome::outcome<int> test3()
  {
    BOOST_OUTCOME_TRY(foo3());
    return 7;
  }

}  // namespace issues247

BOOST_OUTCOME_AUTO_TEST_CASE(issues_0247_test, "TRY strips spare storage value")
{
  auto r1 = issues247::test1();
  BOOST_CHECK(issues247::outcome::hooks::spare_storage(&r1) == 43);
  auto r2 = issues247::test2();
  BOOST_CHECK(issues247::outcome::hooks::spare_storage(&r2) == 43);
  auto r3 = issues247::test3();
  BOOST_CHECK(issues247::outcome::hooks::spare_storage(&r3) == 43);
}


text:
#ifndef HITTABLE_HPP
#define	HITTABLE_HPP
#include <armadillo>

using namespace arma;
using namespace std;

class Hittable{

public:
    virtual vec getMin()=0;
    virtual vec getMax()=0;
    virtual vec getCentro()=0;

};

#endif	/* HITTABLE_HPP */

max_stars_repo_name: arthurflor/RayTracing