Skip to content

Commit

Permalink
Removed system functor test
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbales2 committed Apr 17, 2021
1 parent f49c28f commit f92741f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 71 deletions.
53 changes: 0 additions & 53 deletions stan/math/rev/functor/algebra_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,6 @@
namespace stan {
namespace math {

/**
* A functor that allows us to treat either x or y as
* the independent variable. If x_is_iv = true, than the
* Jacobian is computed w.r.t x, else it is computed
* w.r.t y.
*
* @tparam F type for algebraic system functor
* @tparam T0 type for unknowns
* @tparam T1 type for auxiliary parameters
* @tparam x_is_iv true if x is the independent variable
*/
template <typename F, typename T0, typename T1, bool x_is_iv>
struct system_functor {
/** algebraic system functor */
F f_;
/** unknowns */
Eigen::Matrix<T0, Eigen::Dynamic, 1> x_;
/** auxiliary parameters */
Eigen::Matrix<T1, Eigen::Dynamic, 1> y_;
/** real data */
std::vector<double> dat_;
/** integer data */
std::vector<int> dat_int_;
/** stream message */
std::ostream* msgs_;

system_functor() {}

system_functor(const F& f, const Eigen::Matrix<T0, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<T1, Eigen::Dynamic, 1>& y,
const std::vector<double>& dat,
const std::vector<int>& dat_int, std::ostream* msgs)
: f_(f), x_(x), y_(y), dat_(dat), dat_int_(dat_int), msgs_(msgs) {}

/**
* An operator that takes in an independent variable. The
* independent variable is either passed as the unknown x,
* or the auxiliary parameter y. The x_is_iv template parameter
* allows us to determine whether the jacobian is computed
* with respect to x or y.
* @tparam T the scalar type of the independent variable
*/
template <typename T>
inline Eigen::Matrix<T, Eigen::Dynamic, 1> operator()(
const Eigen::Matrix<T, Eigen::Dynamic, 1>& iv) const {
if (x_is_iv) {
return f_(iv, y_, dat_, dat_int_, msgs_);
} else {
return f_(x_, iv, dat_, dat_int_, msgs_);
}
}
};

/**
* A structure which gets passed to Eigen's dogleg
* algebraic solver.
Expand Down
18 changes: 0 additions & 18 deletions test/unit/math/rev/functor/algebra_solver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,24 +347,6 @@ TEST_F(degenerate_eq_test, powell_guess_saddle_point_dbl) {
EXPECT_FLOAT_EQ(100, theta(1));
}

// unit test to demo issue #696
// system functor init bug issue #696
TEST(MathMatrixRevMat, system_functor_constructor) {
using stan::math::system_functor;

Eigen::VectorXd y(2);
y << 5, 8;
Eigen::VectorXd x(2);
x << 10, 1;
std::vector<double> dat{0.0, 0.0};
std::vector<int> dat_int{0, 0};
std::ostream* msgs = 0;
int f = 99;

system_functor<int, double, double, true> fs(f, x, y, dat, dat_int, msgs);

EXPECT_EQ(fs.f_, f);
}
//////////////////////////////////////////////////////////////////////////
// Tests for newton solver.

Expand Down

0 comments on commit f92741f

Please sign in to comment.