Prev Next det_by_minor.hpp Headings

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
Source: det_by_minor
# 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

Input File: omh/det_by_minor_hpp.omh