Skip to content

Instantly share code, notes, and snippets.

template<class T>
inline auto create_fftw_iodim64(xt::xarray<T> const& input, std::size_t axis)
-> std::conditional_t<(std::is_same_v<T, double> || std::is_same_v<T, std::complex<double>>), fftw_iodim64, fftwf_iodim64>
{
if constexpr(std::is_same_v<T, double> || std::is_same_v<T, std::complex<double>>)
{
return fftw_iodim64{static_cast<int>(input.shape(axis)), static_cast<int>(input.strides()[axis]),
static_cast<int>(input.strides()[axis])};
}
namespace xt
{
template<typename Tensor>
inline auto moveaxis(Tensor&& t, std::size_t source, std::size_t destination)
{
using shape_type = typename std::decay_t<Tensor>::shape_type;
if(source >= t.dimension() || destination >= t.dimension())
{
throw std::runtime_error("Cant't move axis, source has not the same length as destination.");
template<typename Tensor>
inline auto moveaxis(Tensor&& t, std::size_t source, std::size_t destination)
{
using size_type = typename std::decay_t<Tensor>::size_type;
if(source >= t.dimension() || destination >= t.dimension())
{
throw std::runtime_error("Cant't move axis, source has not the same length as destination.");
}
// In a header file
#include <user_main_fwd.hpp>
#define main nt2::user_main
//In a library
#include <...>
int hpx_main(boost::program_options::variables_map& vm)
{
@pesterie
pesterie / functor.cpp
Created July 5, 2012 21:58
register functor
#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/runtime/actions/plain_action.hpp>
#include <hpx/components/dataflow/dataflow.hpp>
#include <iostream>
#include <cstdlib>
template<class T>
struct add_
40734e: 0f 84 93 01 00 00 je 4074e7 <_ZN3nt24unit17perform_benchmarkINS_7example14diffusion_simdIfEEmEEvT_dRNS0_16benchmark_resultIT0_EE+0x3447>
407354: f3 0f 10 8c 24 50 09 movss 0x950(%rsp),%xmm1
40735b: 00 00
40735d: 48 89 c8 mov %rcx,%rax
407360: 31 d2 xor %edx,%edx
407362: 48 f7 b4 24 30 09 00 divq 0x930(%rsp)
407369: 00
40736a: 8b bc 24 d0 08 00 00 mov 0x8d0(%rsp),%edi
407371: 01 d7 add %edx,%edi
407373: 31 d2 xor %edx,%edx
#include <vector>
#include <iostream>
#include <algorithm>
template<int N>
struct unroll
{
template<class InputIterator, class OutputIterator, class Op>
inline static OutputIterator
apply( InputIterator& i, OutputIterator o, Op f)
@pesterie
pesterie / saxpi.cpp
Created January 9, 2012 17:07
Bench problem
//==============================================================================
// Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2009 - 2011 LRI UMR 8623 CNRS/Univ Paris Sud XI
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#include <cstdlib>
template<class Iterator>
iterator<typename boost::pointee<Iterator>::value_type>
begin(Iterator p)
{ return iterator<typename boost::pointee<Iterator>::value_type>(p); }
template<class Iterator, std::size_t C>
iterator<typename boost::pointee<Iterator>::value_type,C>
begin(Iterator p)
{ return iterator<typename boost::pointee<Iterator>::value_type,C>(p); }
/home/pesterie-lin64/Documents/dev/nt2/metascale/nt2/modules/core/unit/container/dsl/run.cpp:65: instantiated from here
/usr/local/include/boost/mpl/at.hpp:42: error: ‘template<class Sequence, long int N> struct boost::mpl::at_c’ is not a function,
/usr/local/include/boost/fusion/sequence/intrinsic/at.hpp:99: error: conflict with ‘template<int N, class Sequence> typename boost::fusion::result_of::at_c<const Sequence, N>::type boost::fusion::at_c(const Sequence&)’
/home/pesterie-lin64/Documents/dev/nt2/metascale/nt2/modules/core/include/nt2/core/container/meta/loop_nest.hpp:87: error: in call to ‘at_c’
/usr/local/include/boost/mpl/at.hpp:42: error: ‘template<class Sequence, long int N> struct boost::mpl::at_c’ is not a function,
/usr/local/include/boost/fusion/sequence/intrinsic/at.hpp:99: error: conflict with ‘template<int N, class Sequence> typename boost::fusion::result_of::at_c<const Sequence, N>::type boost::fusion::at_c(const Sequence&)’
/home/pesterie-lin64/Documents/dev/nt2/metascale/nt2/module