ALP User Documentation 0.7.0
Algebraic Programming User Documentation
vector.hpp
Go to the documentation of this file.
1
2/*
3 * Copyright 2021 Huawei Technologies Co., Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
27#ifndef _H_GRB_VECTOR_BASE
28#define _H_GRB_VECTOR_BASE
29
30#include <cstdlib> //size_t
31#include <iterator> //std::iterator
32#include <stdexcept>
33#include <utility> //pair
34
37#include <graphblas/ops.hpp>
38#include <graphblas/rc.hpp>
39
40
41namespace grb {
42
63 template< typename D, enum Backend implementation, typename C >
64 class Vector {
65
66 public :
67
69 typedef D value_type;
70
125
141 public std::iterator<
142 std::forward_iterator_tag,
143 std::pair< const size_t, const D >,
144 size_t
145 >
146 {
147
148 public :
149
151 bool operator==( const const_iterator &other ) const {
152 (void) other;
153 return false;
154 }
155
157 bool operator!=( const const_iterator &other ) const {
158 (void) other;
159 return true;
160 }
161
173 std::pair< const size_t, const D > operator*() const {
174 return std::pair< const size_t, const D >();
175 }
176
191 return *this;
192 }
193
194 };
195
226 Vector( const size_t n, const size_t nz ) {
227 (void) n;
228 (void) nz;
229 }
230
235 Vector( const size_t n ) {
236 (void) n;
237 }
238
260 (void) x;
261 }
262
280 ) noexcept {
281 (void) x;
282 return *this;
283 }
284
308
310
341 const_iterator ret;
342 return ret;
343 }
344
352 const_iterator ret;
353 return ret;
354 }
355
357
359
381 const_iterator ret;
382 return ret;
383 }
384
392 const_iterator ret;
393 return ret;
394 }
396
480 template<
482 class Accum = typename operators::right_assign< D, D, D >,
483 typename fwd_iterator = const D * __restrict__
484 >
486 const Accum &accum,
487 const fwd_iterator start, const fwd_iterator end,
488 fwd_iterator npos
489 ) {
490 (void) accum;
491 (void) start;
492 (void) end;
493 (void) npos;
494 return PANIC;
495 }
496
595 template<
598 typename ind_iterator = const size_t * __restrict__,
599 typename nnz_iterator = const D * __restrict__,
601 >
603 const Accum &accum,
604 const ind_iterator ind_start, const ind_iterator ind_end,
605 const nnz_iterator nnz_start, const nnz_iterator nnz_end,
606 const Dup &dup = Dup()
607 ) {
608 (void) accum;
609 (void) ind_start;
610 (void) ind_end;
611 (void) nnz_start;
612 (void) nnz_end;
613 (void) dup;
614 return PANIC;
615 }
616
720 template<
722 typename mask_type,
723 class Accum,
724 typename ind_iterator = const size_t * __restrict__,
725 typename nnz_iterator = const D * __restrict__,
727 >
730 const Accum &accum,
731 const ind_iterator ind_start,
732 const ind_iterator ind_end,
733 const nnz_iterator nnz_start,
734 const nnz_iterator nnz_end,
735 const Dup &dup = Dup()
736 ) {
737 (void) mask;
738 (void) accum;
739 (void) ind_start;
740 (void) ind_end;
741 (void) nnz_start;
742 (void) nnz_end;
743 (void) dup;
744 return PANIC;
745 }
746
771 template< typename T >
772 RC size( T &size ) const {
773 (void) size;
774 return PANIC;
775 }
776
801 template< typename T >
802 RC nnz( T &nnz ) const {
803 (void) nnz;
804 return PANIC;
805 }
806
866 template< class Monoid >
868 const size_t i, const Monoid &monoid = Monoid()
869 ) {
870 (void) i;
871 (void) monoid;
872 return PANIC;
873 }
874
919 lambda_reference operator[]( const size_t i ) {
920 (void) i;
921 #ifndef _GRB_NO_EXCEPTIONS
922 throw std::runtime_error(
923 "Requesting lambda reference of unimplemented Vector backend."
924 );
925 #endif
926 }
927 };
928
929} // end namespace ``grb''
930
931#endif // _H_GRB_VECTOR_BASE
932
This file contains a register of all backends that are either implemented, under implementation,...
A generalised monoid.
Definition: monoid.hpp:54
A standard iterator for the Vector< D > class.
Definition: vector.hpp:146
bool operator!=(const const_iterator &other) const
Definition: vector.hpp:157
std::pair< const size_t, const D > operator*() const
Dereferences the current position of this iterator.
Definition: vector.hpp:173
bool operator==(const const_iterator &other) const
Standard equals operator.
Definition: vector.hpp:151
const_iterator & operator++()
Advances the position of this iterator by one.
Definition: vector.hpp:190
A GraphBLAS vector.
Definition: vector.hpp:64
RC build(const Vector< mask_type, implementation, C > &mask, const Accum &accum, const ind_iterator ind_start, const ind_iterator ind_end, const nnz_iterator nnz_start, const nnz_iterator nnz_end, const Dup &dup=Dup())
Copy from raw user-supplied data into a vector.
Definition: vector.hpp:728
Vector(const size_t n)
Creates an ALP/GraphBLAS vector.
Definition: vector.hpp:235
Vector(Vector< D, implementation, C > &&x) noexcept
Move constructor.
Definition: vector.hpp:259
D value_type
The type of elements stored in this vector.
Definition: vector.hpp:69
const_iterator begin() const
Same as cbegin().
Definition: vector.hpp:351
const_iterator cbegin() const
Provides the only mechanism to extract data from this GraphBLAS vector.
Definition: vector.hpp:340
RC nnz(T &nnz) const
Return the number of nonzeroes in this vector.
Definition: vector.hpp:802
RC build(const Accum &accum, const ind_iterator ind_start, const ind_iterator ind_end, const nnz_iterator nnz_start, const nnz_iterator nnz_end, const Dup &dup=Dup())
Copy from raw user-supplied data into a vector.
Definition: vector.hpp:602
const_iterator cend() const
Indicates the end to the elements in this container.
Definition: vector.hpp:380
lambda_reference operator()(const size_t i, const Monoid &monoid=Monoid())
Returns a lambda reference to an element of this sparse vector.
Definition: vector.hpp:867
RC size(T &size) const
Return the dimension of this vector.
Definition: vector.hpp:772
Vector(const size_t n, const size_t nz)
Creates an ALP/GraphBLAS vector.
Definition: vector.hpp:226
~Vector()
Default destructor.
Definition: vector.hpp:307
lambda_reference operator[](const size_t i)
Returns a lambda reference to an element of this vector.
Definition: vector.hpp:919
Vector< D, implementation, C > & operator=(Vector< D, implementation, C > &&x) noexcept
Move-from-temporary assignment.
Definition: vector.hpp:278
const_iterator end() const
Same as cend().
Definition: vector.hpp:391
D & lambda_reference
Defines a reference to a value of type D.
Definition: vector.hpp:124
RC build(const Accum &accum, const fwd_iterator start, const fwd_iterator end, fwd_iterator npos)
Copy from raw user-supplied data into a vector.
Definition: vector.hpp:485
This operator discards all left-hand side input and simply copies the right-hand side input to the ou...
Definition: ops.hpp:117
Defines all ALP/GraphBLAS descriptors.
static constexpr Descriptor no_operation
Indicates no additional pre- or post-processing on any of the GraphBLAS function arguments.
Definition: descriptors.hpp:63
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:452
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
@ PANIC
Generic fatal error code.
Definition: rc.hpp:68
unsigned int Descriptor
Descriptors indicate pre- or post-processing for some or all of the arguments to an ALP/GraphBLAS cal...
Definition: descriptors.hpp:54
Provides a set of standard binary operators.
Defines the ALP error codes.