ALP User Documentation  0.8.preview
Algebraic Programming User Documentation
utils.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
26 #ifndef _H_GRB_ITERATOR_UTILS
27 #define _H_GRB_ITERATOR_UTILS
28 
29 #include <cstddef>
30 
31 #include <graphblas/rc.hpp>
33 
34 #include "type_traits.hpp"
35 
36 
37 namespace grb {
38 
39  namespace utils {
40 
57  template< typename IterT >
59  const IterT &it,
60  const typename IterT::RowIndexType rows,
61  const typename IterT::ColumnIndexType cols
62  ) {
64  "IterT is not an ALP matrix iterator" );
65  if( it.i() >= rows ) {
66 #ifndef NDEBUG
67  std::cerr << "Error: " << rows << " x " << cols
68  << " matrix nonzero ingestion encounters row "
69  << "index at " << it.i() << std::endl;
70 #endif
71  return MISMATCH;
72  }
73  if( it.j() >= cols ) {
74 #ifndef NDEBUG
75  std::cerr << "Error: " << rows << " x " << cols
76  << " matrix nonzero ingestion encounters column "
77  << "input at " << it.j() << std::endl;
78 #endif
79  return MISMATCH;
80  }
81  return SUCCESS;
82  }
83 
84  } // end namespace utils
85 
86 } // end namespace grb
87 
88 #endif // end _H_GRB_ITERATOR_UTILS
89 
Defines the ALP error codes.
unsigned int RowIndexType
What data type should be used to store row indices.
Definition: base/config.hpp:436
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
RC check_input_coordinates(const IterT &it, const typename IterT::RowIndexType rows, const typename IterT::ColumnIndexType cols)
Checks whether the input iterator it stores valid row and column coordinates.
Definition: utils.hpp:58
Specifies the ALP algebraic type traits.
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:477
Indicates the primitive has executed successfully.
Definition: rc.hpp:54
One or more of the ALP/GraphBLAS objects passed to the primitive that returned this error have mismat...
Definition: rc.hpp:90
Used to gauge whether a given type is an ALP matrix iterator.
Definition: utils/iterators/type_traits.hpp:112