1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef UUID_995547FAAE0E11DE8CF511E755D89593
7 #define UUID_995547FAAE0E11DE8CF511E755D89593
9 #include <boost/qvm/detail/determinant_impl.hpp>
10 #include <boost/qvm/mat_traits.hpp>
11 #include <boost/qvm/static_assert.hpp>
23 BOOST_QVM_INLINE_OPERATIONS
24 typename deduce_mat<A>::type
25 cofactor_impl( A const & a )
27 BOOST_QVM_STATIC_ASSERT(mat_traits<A>::rows==mat_traits<A>::cols);
28 int const N=mat_traits<A>::rows;
29 typedef typename mat_traits<A>::scalar_type T;
31 typedef typename deduce_mat<A>::type R;
33 for( int j=0; j!=N; ++j )
35 for( int i=0; i!=N; ++i )
38 for( int ii=0; ii!=N; ++ii )
43 for( int jj=0; jj!=N; ++jj )
47 c[i1][j1] = mat_traits<A>::read_element_idx(ii,jj,a);
52 T det = determinant_impl(c);
55 mat_traits<R>::write_element_idx(i,j,b) = det;