28 #ifndef REMORA_KERNELS_DEFAULT_MATRIX_FOLD_HPP 29 #define REMORA_KERNELS_DEFAULT_MATRIX_FOLD_HPP 31 #include "../../detail/traits.hpp" 32 #include "../../expression_types.hpp" 33 #include <type_traits> 34 namespace remora{
namespace bindings{
36 template<
class F,
class M,
class Orientation,
class Tag>
37 void matrix_fold(matrix_expression<M, cpu_tag>
const& m,
typename F::result_type& value, Orientation, Tag) {
38 typedef typename std::conditional<
39 std::is_same<Orientation,unknown_orientation>::value,
42 >::type chosen_orientation;
44 std::size_t size = chosen_orientation::index_M(m().size1(),m().size2());
45 for(std::size_t i = 0; i != size; ++i){
46 auto end = major_end(m,i);
47 for(
auto pos = major_begin(m,i);pos != end; ++pos){
48 value = f(value,*pos);