Exemple #1
0
    BOOST_FORCEINLINE static void conf_bounds(const A0& a0, A1& a1,
                                              const M2x2 pcov,
                                              const value_type& normz,
                                              Out0 & p)
    {
      typedef typename boost::proto::result_of::child_c<A1&,1>::type         Out1;
      typedef typename boost::proto::result_of::child_c<A1&,2>::type         Out2;

      //      NT2_DISPLAY(a0.extent());   NT2_DISPLAY(a1.extent());
      p.resize(a0.extent());
      const In0& x  = boost::proto::child_c<0>(a0);
      //      NT2_DISPLAY(x);
      const In1& a = boost::proto::child_c<1>(a0);
      //      NT2_DISPLAY(a);
      const In2& b = boost::proto::child_c<2>(a0);
      //       NT2_DISPLAY(b);
      BOOST_AUTO_TPL(z, x/b);
      //       NT2_DISPLAY(z);
      //       NT2_DISPLAY(nt2::gammainc(z, a));
      //       NT2_DISPLAY(size(p));
      p =  nt2::exp(z); //nt2::gammainc(z, a);
      //       NT2_DISPLAY(p);
      //      Out0& p = boost::proto::child_c<0>(a1);
      //      NT2_DISPLAY(p);
      BOOST_AUTO_TPL(itp, (p/nt2::oneminus(p)));
      //       NT2_DISPLAY(itp);
      BOOST_AUTO_TPL(dp, nt2::rec(p*oneminus(p))); // derivative of logit(p) w.r.t. p
      //       NT2_DISPLAY(dp);
      BOOST_AUTO_TPL(da, dgammainc(z,a)*dp);       // dlogitp/da = dp/da * dlogitp/dp
      //       NT2_DISPLAY(da);
      BOOST_AUTO_TPL(db, -nt2::exp(a*nt2::log(z)-z-nt2::gammaln(a)-nt2::log(b))* dp); // dlogitp/db = dp/db * dlogitp/dp
      //      NT2_DISPLAY(db);
      BOOST_AUTO_TPL(varLogitp, pcov(1,1)*sqr(da) + (Two<value_type>()*pcov(1,2)*da + pcov(2,2)*db)*db);
      //       NT2_DISPLAY(varLogitp);
      //       NT2_DISPLAY(normz);
      BOOST_AUTO_TPL(exp_halfwidth, nt2::exp(normz*nt2::sqrt(varLogitp)));
      //       NT2_DISPLAY(exp_halfwidth);
      Out1 & plo = boost::proto::child_c<1>(a1);
      Out2 & pup = boost::proto::child_c<2>(a1);
      plo.resize(a0.extent());
      pup.resize(a0.extent());
      //      std::cout << "1" << std::endl;
      plo = itp*exp_halfwidth;
      //      std::cout << "2" << std::endl;
      pup = itp/exp_halfwidth;
      //      std::cout << "3" << std::endl;
      plo /= nt2::oneplus(plo);
      //      std::cout << "4" << std::endl;
      pup /= nt2::oneplus(pup);
      //      std::cout << "5" << std::endl;
    }
Exemple #2
0
 static type call(A0& a0, I const& indices)
 {
   return boost::proto::make_expr<tag::function_,container::domain>
                                 ( boost::reference_wrapper<A0>(a0)
                                 , function_index(indices, a0.extent(), meta::as_<typename A0::indexes_type>())
                                 );
 }
Exemple #3
0
    static type call(A0& a0, I const& indices)
    {
      Idx idx = nt2::function_index(indices, a0.extent(), meta::as_<typename A0::indexes_type>());
      std::size_t b = nt2::run(idx, 0u, meta::as_<std::size_t>());

      return nt2_expr(basic_expr::make(container_ref(boost::proto::value(a0), boost::proto::value(a0).begin()+b, idx.extent())));
    }
Exemple #4
0
    BOOST_FORCEINLINE
    result_type operator()(A0 const& a0, A1 ind, A2 dim) const
    {
      std::size_t along = dim-1;
      typename A0::extent_type ex1 = a0.extent();
      ex1[along] = 1;

      return boost::proto::make_expr< nt2::tag::line_
                                    , container::domain
                                    > ( boost::cref(a0)
                                      , along
                                      , as_index( a0.extent()
                                                , as_subscript(ex1, ind)
                                                )
                                      , nt2::linesstride(a0, dim)
                                      );
    }
Exemple #5
0
    static type call(A0& a0, I const& indices)
    {
      Idx idx = nt2::function_index(indices, a0.extent(), meta::as_<typename A0::indexes_type>());
      std::size_t b = nt2::run(idx, 0u, meta::as_<std::size_t>());
      std::size_t e = nt2::run(idx, nt2::numel(idx.extent())-1u, meta::as_<std::size_t>())+1u;
      typename A0::value_type* p = const_cast<typename A0::value_type*>(a0.raw());

      return type(expr::make(container_ref(boost::make_shared<container>(idx.extent(), nt2::share(p+b, p+e)))));
    }