Ejemplo n.º 1
0
    ::testing::AssertionResult assert_same(const char* exp_expr,
        const char* act_expr,
        const Eigen::EigenBase<DerivedExp>& exp,
        const Eigen::EigenBase<DerivedAct>& act)
    {
        if (exp.rows() == act.rows() &&
            exp.cols() == act.cols() &&
            exp.derived() == act.derived())
        {
            return ::testing::AssertionSuccess();
        }

        // if eigen did not define the == operator, you could use
        // exp.derived().cwiseEqual(act.derived()).all();

        ::testing::AssertionResult result = ::testing::AssertionFailure()
            << "Eigen objects are not the same: ("
            << exp_expr << ", " << act_expr << ")\n"
            << exp_expr << ":\n"
            << ::testing::PrintToString(exp)
            << "\n---and\n" << act_expr << ":\n"
            << ::testing::PrintToString(act)
            << "\n---are not equal!\n";

        return result;
    }
Ejemplo n.º 2
0
 void PrintTo(const Eigen::EigenBase<Derived>& mat, ::std::ostream* os)
 {
     (*os) << mat.derived() << "\n";
 }
Ejemplo n.º 3
0
 T operator()(const Eigen::EigenBase<Derived>& x) const {
   return T(1) / (T(1) + std::exp(- bias - x.derived().dot(weight)));
 }