@@ -571,6 +571,127 @@ namespace grb {
571571 );
572572 }
573573
574+ template <
575+ Descriptor descr = descriptors::no_operation,
576+ class Operator ,
577+ typename IOType, typename MaskType, typename InputType,
578+ typename RIT_A, typename CIT_A, typename NIT_A,
579+ typename RIT_M, typename CIT_M, typename NIT_M
580+ >
581+ RC foldl (
582+ Matrix< IOType, nonblocking, RIT_A, CIT_A, NIT_A > &A,
583+ const Matrix< MaskType, nonblocking, RIT_M, CIT_M, NIT_M > &mask,
584+ const InputType &x,
585+ const Operator &op = Operator(),
586+ const typename std::enable_if<
587+ !grb::is_object< IOType >::value &&
588+ !grb::is_object< InputType >::value &&
589+ !grb::is_object< MaskType >::value &&
590+ grb::is_operator< Operator >::value, void
591+ >::type * const = nullptr
592+ ) {
593+
594+ #ifdef _DEBUG
595+ std::cout << " In grb::foldl( nonblocking, matrix, mask, scalar, op )\n " ;
596+ #endif
597+ RC rc = SUCCESS;
598+
599+ if ( grb::nnz ( A ) == 0 ) {
600+ return rc;
601+ }
602+
603+ // Do local folding
604+ rc = foldl< descr >( internal::getRefMatrix ( A ), internal::getRefMatrix ( mask ), x, op );
605+
606+ return rc;
607+ }
608+
609+ template <
610+ Descriptor descr = descriptors::no_operation,
611+ class Operator ,
612+ typename IOType, typename MaskType, typename InputType,
613+ typename RIT, typename CIT, typename NIT
614+ >
615+ RC foldl (
616+ Matrix< IOType, nonblocking, RIT, CIT, NIT > &A,
617+ const InputType &x,
618+ const Operator &op = Operator(),
619+ const typename std::enable_if<
620+ !grb::is_object< IOType >::value &&
621+ !grb::is_object< InputType >::value &&
622+ !grb::is_object< MaskType >::value &&
623+ grb::is_operator< Operator >::value, void
624+ >::type * const = nullptr
625+ ) {
626+
627+ #ifdef _DEBUG
628+ std::cout << " In grb::foldl( nonblocking, matrix, scalar, op )\n " ;
629+ #endif
630+ // nonblocking execution is not supported
631+ // first, execute any computation that is not completed
632+ internal::le.execution ();
633+
634+ // second, delegate to the reference backend
635+ return foldl< descr, Operator >( internal::getRefMatrix ( A ), x, op );
636+ }
637+
638+ template <
639+ Descriptor descr = descriptors::no_operation,
640+ class Operator ,
641+ typename IOType, typename MaskType, typename InputType,
642+ typename RIT_A, typename CIT_A, typename NIT_A,
643+ typename RIT_M, typename CIT_M, typename NIT_M
644+ >
645+ RC foldr (
646+ Matrix< IOType, nonblocking, RIT_A, CIT_A, NIT_A > &A,
647+ const Matrix< MaskType, nonblocking, RIT_M, CIT_M, NIT_M > &mask,
648+ const InputType &x,
649+ const Operator &op = Operator(),
650+ const typename std::enable_if<
651+ !grb::is_object< IOType >::value &&
652+ !grb::is_object< InputType >::value &&
653+ !grb::is_object< MaskType >::value &&
654+ grb::is_operator< Operator >::value, void
655+ >::type * const = nullptr
656+ ) {
657+
658+ #ifdef _DEBUG
659+ std::cout << " In grb::foldr( nonblocking, matrix, scalar, mask, op )\n " ;
660+ #endif
661+ // nonblocking execution is not supported
662+ // first, execute any computation that is not completed
663+ internal::le.execution ();
664+
665+ // second, delegate to the reference backend
666+ return foldr< descr, Operator >( internal::getRefMatrix ( A ), internal::getRefMatrix ( mask ), x, op );
667+ }
668+
669+ template <
670+ Descriptor descr = descriptors::no_operation,
671+ class Operator ,
672+ typename IOType, typename InputType,
673+ typename RIT, typename CIT, typename NIT
674+ >
675+ RC foldr (
676+ Matrix< IOType, nonblocking, RIT, CIT, NIT > &A,
677+ const InputType &x,
678+ const Operator &op = Operator(),
679+ const typename std::enable_if<
680+ !grb::is_object< IOType >::value &&
681+ !grb::is_object< InputType >::value &&
682+ grb::is_operator< Operator >::value, void
683+ >::type * const = nullptr
684+ ) {
685+ #ifdef _DEBUG
686+ std::cout << " In grb::foldr( nonblocking, matrix, scalar, op )\n " ;
687+ #endif
688+ // nonblocking execution is not supported
689+ // first, execute any computation that is not completed
690+ internal::le.execution ();
691+
692+ // second, delegate to the reference backend
693+ return foldr< descr, Operator >( internal::getRefMatrix ( A ), x, op );
694+ }
574695} // namespace grb
575696
576697#undef NO_CAST_ASSERT
0 commit comments