@@ -571,6 +571,126 @@ 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 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_operator< Operator >::value, void
623+ >::type * const = nullptr
624+ ) {
625+
626+ #ifdef _DEBUG
627+ std::cout << " In grb::foldl( nonblocking, matrix, scalar, op )\n " ;
628+ #endif
629+ // nonblocking execution is not supported
630+ // first, execute any computation that is not completed
631+ internal::le.execution ();
632+
633+ // second, delegate to the reference backend
634+ return foldl< descr, Operator >( internal::getRefMatrix ( A ), x, op );
635+ }
636+
637+ template <
638+ Descriptor descr = descriptors::no_operation,
639+ class Operator ,
640+ typename IOType, typename MaskType, typename InputType,
641+ typename RIT_A, typename CIT_A, typename NIT_A,
642+ typename RIT_M, typename CIT_M, typename NIT_M
643+ >
644+ RC foldr (
645+ Matrix< IOType, nonblocking, RIT_A, CIT_A, NIT_A > &A,
646+ const Matrix< MaskType, nonblocking, RIT_M, CIT_M, NIT_M > &mask,
647+ const InputType &x,
648+ const Operator &op = Operator(),
649+ const typename std::enable_if<
650+ !grb::is_object< IOType >::value &&
651+ !grb::is_object< InputType >::value &&
652+ !grb::is_object< MaskType >::value &&
653+ grb::is_operator< Operator >::value, void
654+ >::type * const = nullptr
655+ ) {
656+
657+ #ifdef _DEBUG
658+ std::cout << " In grb::foldr( nonblocking, matrix, scalar, mask, op )\n " ;
659+ #endif
660+ // nonblocking execution is not supported
661+ // first, execute any computation that is not completed
662+ internal::le.execution ();
663+
664+ // second, delegate to the reference backend
665+ return foldr< descr, Operator >( internal::getRefMatrix ( A ), internal::getRefMatrix ( mask ), x, op );
666+ }
667+
668+ template <
669+ Descriptor descr = descriptors::no_operation,
670+ class Operator ,
671+ typename IOType, typename InputType,
672+ typename RIT, typename CIT, typename NIT
673+ >
674+ RC foldr (
675+ Matrix< IOType, nonblocking, RIT, CIT, NIT > &A,
676+ const InputType &x,
677+ const Operator &op = Operator(),
678+ const typename std::enable_if<
679+ !grb::is_object< IOType >::value &&
680+ !grb::is_object< InputType >::value &&
681+ grb::is_operator< Operator >::value, void
682+ >::type * const = nullptr
683+ ) {
684+ #ifdef _DEBUG
685+ std::cout << " In grb::foldr( nonblocking, matrix, scalar, op )\n " ;
686+ #endif
687+ // nonblocking execution is not supported
688+ // first, execute any computation that is not completed
689+ internal::le.execution ();
690+
691+ // second, delegate to the reference backend
692+ return foldr< descr, Operator >( internal::getRefMatrix ( A ), x, op );
693+ }
574694} // namespace grb
575695
576696#undef NO_CAST_ASSERT
0 commit comments