@@ -205,6 +205,140 @@ namespace grb {
205205 return internal::checkGlobalErrorStateOrClear ( C, ret );
206206 }
207207
208+ template <
209+ Descriptor descr = descriptors::no_operation,
210+ class Operator ,
211+ typename IOType, typename MaskType, typename InputType,
212+ typename RIT, typename CIT, typename NIT
213+ >
214+ RC foldl (
215+ Matrix< IOType, BSP1D, RIT, CIT, NIT > &A,
216+ const InputType &x,
217+ const Operator &op = Operator(),
218+ const typename std::enable_if<
219+ !grb::is_object< IOType >::value &&
220+ !grb::is_object< InputType >::value &&
221+ !grb::is_object< MaskType >::value &&
222+ grb::is_operator< Operator >::value, void
223+ >::type * const = nullptr
224+ ) {
225+
226+ #ifdef _DEBUG
227+ std::cout << " In grb::foldl( BSP1D, matrix, scalar, op )\n " ;
228+ #endif
229+ RC rc = SUCCESS;
230+
231+ if ( grb::nnz ( A ) == 0 ) {
232+ return rc;
233+ }
234+
235+ // Do local folding
236+ rc = foldl< descr >( internal::getLocal ( A ), x, op );
237+
238+ return rc;
239+ }
240+
241+ template <
242+ Descriptor descr = descriptors::no_operation,
243+ class Operator ,
244+ typename IOType, typename MaskType, typename InputType,
245+ typename RIT_A, typename CIT_A, typename NIT_A,
246+ typename RIT_M, typename CIT_M, typename NIT_M
247+ >
248+ RC foldl (
249+ Matrix< IOType, BSP1D, RIT_A, CIT_A, NIT_A > &A,
250+ const Matrix< MaskType, BSP1D, RIT_M, CIT_M, NIT_M > &mask,
251+ const InputType &x,
252+ const Operator &op = Operator(),
253+ const typename std::enable_if<
254+ !grb::is_object< IOType >::value &&
255+ !grb::is_object< InputType >::value &&
256+ !grb::is_object< MaskType >::value &&
257+ grb::is_operator< Operator >::value, void
258+ >::type * const = nullptr
259+ ) {
260+
261+ #ifdef _DEBUG
262+ std::cout << " In grb::foldl( BSP1D, matrix, mask, scalar, op )\n " ;
263+ #endif
264+ RC rc = SUCCESS;
265+
266+ if ( grb::nnz ( A ) == 0 ) {
267+ return rc;
268+ }
269+
270+ // Do local folding
271+ rc = foldl< descr >( internal::getLocal ( A ), internal::getLocal ( mask ), x, op );
272+
273+ return rc;
274+ }
275+
276+ template <
277+ Descriptor descr = descriptors::no_operation,
278+ class Operator ,
279+ typename IOType, typename MaskType, typename InputType,
280+ typename RIT_A, typename CIT_A, typename NIT_A,
281+ typename RIT_M, typename CIT_M, typename NIT_M
282+ >
283+ RC foldr (
284+ Matrix< IOType, BSP1D, RIT_A, CIT_A, NIT_A > &A,
285+ const Matrix< MaskType, BSP1D, RIT_M, CIT_M, NIT_M > &mask,
286+ const InputType &x,
287+ const Operator &op = Operator(),
288+ const typename std::enable_if<
289+ !grb::is_object< IOType >::value &&
290+ !grb::is_object< InputType >::value &&
291+ !grb::is_object< MaskType >::value &&
292+ grb::is_operator< Operator >::value, void
293+ >::type * const = nullptr
294+ ) {
295+
296+ #ifdef _DEBUG
297+ std::cout << " In grb::foldr( BSP1D, matrix, scalar, mask, op )\n " ;
298+ #endif
299+ RC rc = SUCCESS;
300+
301+ if ( grb::nnz ( A ) == 0 ) {
302+ return rc;
303+ }
304+
305+ // Do local folding
306+ rc = foldr< descr >( internal::getLocal ( A ), internal::getLocal ( mask ), x, op );
307+
308+ return rc;
309+ }
310+
311+ template <
312+ Descriptor descr = descriptors::no_operation,
313+ class Operator ,
314+ typename IOType, typename InputType,
315+ typename RIT, typename CIT, typename NIT
316+ >
317+ RC foldr (
318+ Matrix< IOType, BSP1D, RIT, CIT, NIT > &A,
319+ const InputType &x,
320+ const Operator &op = Operator(),
321+ const typename std::enable_if<
322+ !grb::is_object< IOType >::value &&
323+ !grb::is_object< InputType >::value &&
324+ grb::is_operator< Operator >::value, void
325+ >::type * const = nullptr
326+ ) {
327+ #ifdef _DEBUG
328+ std::cout << " In grb::foldr( BSP1D, matrix, scalar, op )\n " ;
329+ #endif
330+ RC rc = SUCCESS;
331+
332+ if ( grb::nnz ( A ) == 0 ) {
333+ return rc;
334+ }
335+
336+ // Do local folding
337+ rc = foldr< descr >( internal::getLocal ( A ), x, op );
338+
339+ return rc;
340+ }
341+
208342} // namespace grb
209343
210344#endif
0 commit comments