boost::shared_ptr<fba2_interface<sig, real, real2> > fba2_factory<sig, real, real2>::get_instance(bool fss, bool thresholding, bool lazy, bool globalstore) { boost::shared_ptr<fba2_interface<sig, real, real2> > fba_ptr; #ifdef USE_CUDA # define FBA_TYPE cuda::fba2 # define RECV_TYPE cuda::tvb_receiver<sig, real, real2> #else # define FBA_TYPE fba2 # define RECV_TYPE tvb_receiver<sig, real, real2> #endif #define FLAG_SEQ \ (true)(false) #define CONDITIONAL(r, args) \ if (BOOST_PP_SEQ_ELEM(0,args) == thresholding && \ BOOST_PP_SEQ_ELEM(1,args) == lazy && \ BOOST_PP_SEQ_ELEM(2,args) == globalstore) \ fba_ptr.reset(new FBA_TYPE<RECV_TYPE, sig, real, real2, BOOST_PP_SEQ_ENUM(args)>); if (!fss) { BOOST_PP_SEQ_FOR_EACH_PRODUCT(CONDITIONAL, (FLAG_SEQ)(FLAG_SEQ)(FLAG_SEQ)) } else { // check unused flags assertalways(thresholding == false); assertalways(lazy == false); // instantiate required object if (globalstore) fba_ptr.reset( new fba2_fss<tvb_fss_receiver<sig, real, real2>, sig, real, real2, true>); else fba_ptr.reset( new fba2_fss<tvb_fss_receiver<sig, real, real2>, sig, real, real2, false>); } #undef CONDITIONAL assertalways(fba_ptr); return fba_ptr; }
bp::object calc_axis_std( ndhist const & h , intptr_t const axis ) { // Determine the correct axis index and get the Axis object. intptr_t const axis_idx = ::ndhist::detail::adjust_axis_index(h.get_nd(), axis); Axis const & theaxis = *h.get_axes()[axis_idx]; // Check that the axis and weight types are not bp::object. if( theaxis.has_object_value_dtype() || h.has_object_weight_dtype() ) { std::stringstream ss; ss << "The axis and weight data types must be POD types. Non-POD types " << "are not supported by the var function!"; throw TypeError(ss.str()); } #define NDHIST_MULTPLEX(r, seq) \ if( bn::dtype::equivalent(theaxis.get_dtype(), bn::dtype::get_builtin<BOOST_PP_SEQ_ELEM(0,seq)>())\ && bn::dtype::equivalent(h.get_weight_dtype(), bn::dtype::get_builtin<BOOST_PP_SEQ_ELEM(1,seq)>())\ ) \ { \ BOOST_PP_SEQ_ELEM(0,seq) std = ::ndhist::stats::detail::calc_axis_std_impl<BOOST_PP_SEQ_ELEM(0,seq), BOOST_PP_SEQ_ELEM(1,seq)>(h, axis_idx);\ return bp::object(std); \ } BOOST_PP_SEQ_FOR_EACH_PRODUCT(NDHIST_MULTPLEX, (NDHIST_TYPE_SUPPORT_AXIS_VALUE_TYPES_WITHOUT_OBJECT)(NDHIST_TYPE_SUPPORT_WEIGHT_VALUE_TYPES_WITHOUT_OBJECT)) #undef NDHIST_MULTPLEX std::stringstream ss; ss << "The combination of axis value type and weight value type of this " << "ndhist object is not supported for the var function!"; throw TypeError(ss.str()); }