From bb91f06535746cc9e01b745c42c1c61979760549 Mon Sep 17 00:00:00 2001 From: Benjamin Brock Date: Thu, 13 Jul 2023 14:35:37 -0700 Subject: [PATCH 1/3] Small update to vector constructor --- markdown/vector.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/markdown/vector.md b/markdown/vector.md index 80e54b4..aaf427a 100644 --- a/markdown/vector.md +++ b/markdown/vector.md @@ -60,12 +60,16 @@ vector(); (1) vector(const Allocator& alloc); (2) vector(index_type shape); (3) vector(index_type shape, const Allocator& alloc); (4) +vector(const vector& other); (5) +vector(vector&& other); (6) ``` Constructs new `grb::vector` data structure. -1) Constructs an empty vector of dimension 0. -2) Constructs an empty vector of dimension `shape`. +1) and 2) Constructs an empty vector of dimension 0. +3) and 4) Constructs an empty vector of dimension `shape`. +5) Copy constructor +6) Move constructor ### Parameters `shape` - shape of the vector to be constructed From ff51ec3fff93ed6c337b6ff72449fdeea9e8c147 Mon Sep 17 00:00:00 2001 From: Benjamin Brock Date: Tue, 1 Aug 2023 11:00:34 -0700 Subject: [PATCH 2/3] Add `views.md` to HTML build --- markdown/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/markdown/Makefile b/markdown/Makefile index 19a9760..bc0817c 100644 --- a/markdown/Makefile +++ b/markdown/Makefile @@ -18,6 +18,7 @@ graphblas.html: $(TEX_SOURCES) $(MD_SOURCES) Makefile vector.md \ index.md \ hints.md \ + views.md \ functional.md \ plus.md \ multiplies.md \ From 4f9f0c091f72613309ead82986386edf485e7c9a Mon Sep 17 00:00:00 2001 From: Benjamin Brock Date: Thu, 7 Sep 2023 13:40:23 -0700 Subject: [PATCH 3/3] Update transform and transpose views --- markdown/views.md | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/markdown/views.md b/markdown/views.md index cee1e0a..d6de2bc 100644 --- a/markdown/views.md +++ b/markdown/views.md @@ -1,10 +1,18 @@ # Views -## grb::transpose +## grb::views::transpose + +```cpp +namespace views { + inline constexpr /* unspecified */ transpose = /* unspecified */; +} +``` + +##### Call signature ```cpp template -grb::transpose_view transpose(M&& matrix); +MatrixRange auto transpose(M&& matrix); ``` ### Parameters @@ -16,21 +24,25 @@ grb::transpose_view transpose(M&& matrix); - `M` must meet the requirements of `MatrixRange` ### Return Value -_TODO: Discuss issues with allowing transpose view in output_ Returns a matrix view that is equal to the transpose of `matrix`, satisfying `MatrixRange`. -If `M` meets the requirements of `MutableMatrixRange`, then the return value will also meet the -requirements of `MutableMatrixRange`. If the value returned by `transpose` outlives the lifetime of `matrix`, then the behavior is undefined. -## grb::transform +## grb::views::transform ```cpp -template -grb::transform_view transform(M&& matrix, Fn&& fn); (1) +namespace views { + inline constexpr /* unspecified */ transform = /* unspecified */; +} +``` -template -grb::transform_view transform(V&& vector, Fn&& fn); (2) +##### Call signature +```cpp +template +MatrixRange auto transform (M&& matrix, Fn&& fn); (1) + +template +VectorRange auto transform(V&& vector, Fn&& fn); (2) ``` (1) `fn` must accept an argument of type `std::ranges::range_value_t` and return a value of some type. The return type of `fn` will be the scalar type of the transform view. @@ -53,9 +65,9 @@ grb::transform_view transform(V&& vector, Fn&& fn); (2) ### Return Value -(1) Returns a view of the matrix `matrix` in which every stored scalar value has been transformed using the function `fn`. +(1) Returns a view of `matrix` satisfying `MatrixRange`. The stored scalar values will correspond to every stored scalar value in `matrix` transformed using the function `fn`. -(2) Returns a view of the vector `vector` in which every stored scalar value has been transformed using the function `fn`. +(2) Returns a view of `vector` satisfying `VectorRange`. The stored scalar values will correspond to every stored scalar value in `vector` transformed using the function `fn`. ### Example @@ -73,11 +85,11 @@ int main(int argc, char** argv) { // Transform each scalar value based on its // row and column index. - auto idx_view = grb::transform(a, [](auto&& entry) { - auto&& [idx, v] = entry; - auto&& [i, j] = idx; - return i + j; - }); + auto idx_view = grb::views::transform(a, [](auto&& entry) { + auto&& [idx, v] = entry; + auto&& [i, j] = idx; + return i + j; + }); grb::print(idx_view, "index transformed view");