text:
//////////////////////////////////////////////////////////////////////////////
//  Boost.Assign v2                                                         //
//                                                                          //
//  Copyright (C) 2003-2004 Thorsten Ottosen                                //
//  Copyright (C) 2011 Erwann Rogard                                        //
//  Use, modification and distribution are subject to 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_ASSIGN_V2_SUPPORT_TYPE_TRAITS_ADD_REF_CONST_ER_2011_HPP
#define BOOST_ASSIGN_V2_SUPPORT_TYPE_TRAITS_ADD_REF_CONST_ER_2011_HPP
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>

namespace boost{
namespace assign{
namespace v2{
namespace type_traits{

    template<typename T>
    struct add_ref_const
        : boost::add_reference<
            typename boost::add_const<T>::type
        >
    {};

}// type_traits
}// v2
}// assign
}// boost

#endif // BOOST_ASSIGN_V2_SUPPORT_TYPE_TRAITS_ADD_REF_CONST_ER_2011_HPP

ext: hpp


text:
#include <iostream>
#include <fstream>
#include <vector>
#include <Eigen/Core>
#include "../../BenchTimer.h"
using namespace Eigen;

#ifndef SCALAR
#error SCALAR must be defined
#endif

typedef SCALAR Scalar;

template<typename MatA, typename MatB, typename MatC>
inline void lazy_gemm(const MatA &A, const MatB &B, MatC &C)
{
  escape((void*)A.data());
  escape((void*)B.data());
  C.noalias() += A.lazyProduct(B);
  escape((void*)C.data());
}

template<int m, int n, int k, int TA>
EIGEN_DONT_INLINE
double bench()
{
  typedef Matrix<Scalar,m,k,TA> MatA;
  typedef Matrix<Scalar,k,n> MatB;
  typedef Matrix<Scalar,m,n> MatC;

  MatA A(m,k);
  MatB B(k,n);
  MatC C(m,n);
  A.setRandom();
  B.setRandom();
  C.setZero();

  BenchTimer t;

  double up = 1e7*4/sizeof(Scalar);
  double tm0 = 10, tm1 = 20;

  double flops = 2. * m * n * k;
  long rep = std::max(10., std::min(10000., up/flops) );
  long tries = std::max(tm0, std::min(tm1, up/flops) );

  BENCH(t, tries, rep, lazy_gemm(A,B,C));

  return 1e-9 * rep * flops / t.best();
}

template<int m, int n, int k>
double bench_t(int t)
{
  if(t)
    return bench<m,n,k,RowMajor>();
  else
    return bench<m,n,k,0>();
}

EIGEN_DONT_INLINE
double bench_mnk(int m, int n, int k, int t)
{
  int id = m*10000 + n*100 + k;
  switch(id) {
    case  10101 : return bench_t< 1, 1, 1>(t); break;
    case  20202 : return bench_t< 2, 2, 2>(t); break;
    case  30303 : return bench_t< 3, 3, 3>(t); break;
    case  40404 : return bench_t< 4, 4, 4>(t); break;
    case  50505 : return bench_t< 5, 5, 5>(t); break;
    case  60606 : return bench_t< 6, 6, 6>(t); break;
    case  70707 : return bench_t< 7, 7, 7>(t); break;
    case  80808 : return bench_t< 8, 8, 8>(t); break;
    case  90909 : return bench_t< 9, 9, 9>(t); break;
    case 101010 : return bench_t<10,10,10>(t); break;
    case 111111 : return bench_t<11,11,11>(t); break;
    case 121212 : return bench_t<12,12,12>(t); break;
  }
  return 0;
}

int main(int argc, char **argv)
{
  std::vector<double> results;

  std::ifstream settings("lazy_gemm_settings.txt");
  long m, n, k, t;
  while(settings >> m >> n >> k >> t)
  {
    //std::cerr << "  Testing " << m << " " << n << " " << k << std::endl;
    results.push_back( bench_mnk(m, n, k, t) );
  }

  std::cout << RowVectorXd::Map(results.data(), results.size());

  return 0;
}

ext: cpp

max_stars_repo_name: Achierius/SysSim

max_issues_repo_name: Achierius/SysSim

max_forks_repo_name: Achierius/SysSim


text:
#include <math.h>
#include <stdio.h>
#include <iostream>

#include <boost/math/quaternion.hpp>

extern "C" void externalForceG(double t, double* f, unsigned int size_z, double *z){
  // std::cout << "externalForceG at time "<< t << std::endl;
  f[0]=0;
  f[1]=0;
  f[2]=0;

  if (t > 0.04){
    f[2] = +1000.0;
  }
}
extern "C" void externalMomentumY(double t,double *m, unsigned int size_z, double *z){
  // std::cout << "externalMomentumY"<<std::endl;
  m[0]=5000;
  m[1]=0;
  m[2]=0;
}

max_stars_repo_name: bremond/siconos

max_issues_repo_name: bremond/siconos

max_forks_repo_name: bremond/siconos


text:
// 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)

#include <boost/hana/ext/boost/mpl/list.hpp>

#include <boost/hana/assert.hpp>
#include <boost/hana/drop_front_exactly.hpp>
#include <boost/hana/equal.hpp>
#include <boost/hana/front.hpp>
#include <boost/hana/is_empty.hpp>
#include <boost/hana/not.hpp>
#include <boost/hana/tuple.hpp>
#include <boost/hana/type.hpp>

#include <laws/iterable.hpp>

#include <boost/mpl/list.hpp>
namespace hana = boost::hana;
namespace mpl = boost::mpl;

struct t1; struct t2; struct t3; struct t4;

int main() {
    // front
    {
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::front(mpl::list<t1>{}),
            hana::type_c<t1>
        ));
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::front(mpl::list<t1, t2>{}),
            hana::type_c<t1>
        ));
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::front(mpl::list<t1, t2, t3>{}),
            hana::type_c<t1>
        ));
    }

    // drop_front_exactly
    {
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::drop_front_exactly(mpl::list<t1>{}),
            mpl::list<>{}
        ));
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::drop_front_exactly(mpl::list<t1, t2>{}),
            mpl::list<t2>{}
        ));
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::drop_front_exactly(mpl::list<t1, t2, t3>{}),
            mpl::list<t2, t3>{}
        ));

        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::drop_front_exactly(mpl::list<t1, t2, t3>{}, hana::size_c<2>),
            mpl::list<t3>{}
        ));

        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::drop_front_exactly(mpl::list<t1, t2, t3, t4>{}, hana::size_c<2>),
            mpl::list<t3, t4>{}
        ));

        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::drop_front_exactly(mpl::list<t1, t2, t3, t4>{}, hana::size_c<3>),
            mpl::list<t4>{}
        ));
    }

    // is_empty
    {
        BOOST_HANA_CONSTANT_CHECK(hana::is_empty(mpl::list<>{}));
        BOOST_HANA_CONSTANT_CHECK(hana::is_empty(mpl::list0<>{}));

        BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list<t1>{})));
        BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list1<t1>{})));

        BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list<t1, t2>{})));
        BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list2<t1, t2>{})));
    }

    // laws
    auto lists = hana::make_tuple(
          mpl::list<>{}
        , mpl::list<t1>{}
        , mpl::list<t1, t2>{}
        , mpl::list<t1, t2, t3>{}
        , mpl::list<t1, t2, t3, t4>{}
    );
    hana::test::TestIterable<hana::ext::boost::mpl::list_tag>{lists};
}