# ifndef CPPAD_DET_BY_MINOR_HPP
# define CPPAD_DET_BY_MINOR_HPP
# include <cppad/speed/det_of_minor.hpp>
# include <vector>
// BEGIN CppAD namespace
namespace CppAD {
template <class Scalar>
class det_by_minor {
private:
size_t m_;
// made mutable because modified and then restored
mutable std::vector<size_t> r_;
mutable std::vector<size_t> c_;
// make mutable because its value does not matter
mutable std::vector<Scalar> a_;
public:
det_by_minor(size_t m) : m_(m) , r_(m + 1) , c_(m + 1), a_(m * m)
{
size_t i;
// values for r and c that correspond to entire matrix
for(i = 0; i < m; i++)
{ r_[i] = i+1;
c_[i] = i+1;
}
r_[m] = 0;
c_[m] = 0;
}
template <class Vector>
Scalar operator()(const Vector &x) const
{ size_t i = m_ * m_;
while(i--)
a_[i] = x[i];
return det_of_minor(a_, m_, m_, r_, c_);
}
};
} // END CppAD namespace
# endif