From d0080aa55ef47ce0b55475b33029d6734cd2b5b0 Mon Sep 17 00:00:00 2001 From: formaggia Date: Tue, 20 Aug 2024 14:36:42 +0200 Subject: [PATCH 1/4] updated modules --- Examples/src/LinearAlgebra/spectra | 2 +- Extras/json | 2 +- Extras/muparser | 2 +- Extras/pybind11 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/src/LinearAlgebra/spectra b/Examples/src/LinearAlgebra/spectra index c853f877..ca632777 160000 --- a/Examples/src/LinearAlgebra/spectra +++ b/Examples/src/LinearAlgebra/spectra @@ -1 +1 @@ -Subproject commit c853f87719d2fb95c4a67b4bf66be87aaba4fabd +Subproject commit ca6327776b72d062acd5b17b2593f8f6c0e73ce8 diff --git a/Extras/json b/Extras/json index 18c96030..72e09ca4 160000 --- a/Extras/json +++ b/Extras/json @@ -1 +1 @@ -Subproject commit 18c9603032a781b06dd3418ec13a7111c910bc76 +Subproject commit 72e09ca47424a8ee885ccec1819bfad5d53b03b7 diff --git a/Extras/muparser b/Extras/muparser index d034a7ad..9cd26f00 160000 --- a/Extras/muparser +++ b/Extras/muparser @@ -1 +1 @@ -Subproject commit d034a7ad98c1b52b54d7fe7a6b6d1acde26391fb +Subproject commit 9cd26f00e0ef410af7624f09b1b690be02676f55 diff --git a/Extras/pybind11 b/Extras/pybind11 index 204e35e7..c2503d69 160000 --- a/Extras/pybind11 +++ b/Extras/pybind11 @@ -1 +1 @@ -Subproject commit 204e35e7a12d4998939ce4b48f56c962a77ccaa7 +Subproject commit c2503d69f787285dd03edd02446759f709e5156e From 3a1aa3777295586f74352709497ae3d5a4848a24 Mon Sep 17 00:00:00 2001 From: Luca Formaggia Date: Wed, 21 Aug 2024 08:52:06 +0200 Subject: [PATCH 2/4] Create jekyll-gh-pages.yml --- .github/workflows/jekyll-gh-pages.yml | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/jekyll-gh-pages.yml diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml new file mode 100644 index 00000000..0ebd768b --- /dev/null +++ b/.github/workflows/jekyll-gh-pages.yml @@ -0,0 +1,51 @@ +# Sample workflow for building and deploying a Jekyll site to GitHub Pages +name: Deploy Jekyll with GitHub Pages dependencies preinstalled + +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From 5fd9e525944772e9c50c4876c165519bf54179e1 Mon Sep 17 00:00:00 2001 From: Luca Formaggia Date: Wed, 21 Aug 2024 08:55:31 +0200 Subject: [PATCH 3/4] Create blank.yml --- .github/workflows/blank.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 00000000..746e72c2 --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,36 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "master" branch + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + # Runs a single command using the runners shell + - name: Run a one-line script + run: echo Hello, world! + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + echo Add other actions to build, + echo test, and deploy your project. From 7d451309f7544ba3133c876f42d773a981a4e7a7 Mon Sep 17 00:00:00 2001 From: Luca Formaggia Date: Wed, 21 Aug 2024 09:29:28 +0200 Subject: [PATCH 4/4] Update README.md --- Examples/src/STL/RangesAndViews/README.md | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Examples/src/STL/RangesAndViews/README.md b/Examples/src/STL/RangesAndViews/README.md index ad0c4568..878e8e02 100644 --- a/Examples/src/STL/RangesAndViews/README.md +++ b/Examples/src/STL/RangesAndViews/README.md @@ -1,22 +1,22 @@ -# C++ Ranges, Views, and Range Adaptors +# C++ Ranges, Views, and Range Adaptors # -## Ranges +## Ranges ## A **Range** is a concept that refers to anything you can iterate over with a beginning and an end. In C++, ranges provide a more modern and powerful abstraction for dealing with sequences of values. The range library, introduced in C++20, offers several utilities to work with ranges conveniently. In modern c++ a range is any object that can be used in a range-based for loop. This includes containers, as well as views, and in general any class that implements the `begin()` and `end()` functions, returning valid iterators, or that returns valid iterators when called with `std::begin()` and `std::end()`. The `end()` function should return what is normally indicated as a `sentinel`, i.e. a value that identify the end of the range. For instance for a container `end()` returns an iterator that is one past the last element of the container. Having generalised the concept of `sentinel` allow to introduce ranges defined by the start and the number of elements, as that returned by `std::ranges::subrange` or `std::ranges::views::take`. -### Key Features: +### Key Features: ### - **Composable:** Ranges can be combined with other ranges or operations to create new ranges. - **Lazy Evaluation:** Operations on ranges are often lazy, meaning they are evaluated only when needed. - **Readable and Writeable:** Ranges can be designed for reading, writing, or both. -## Views -**Views** are a classes that represent special kind of ranges that do not own the data they operate on. Instead, they provide a view into a range given in the constructor by applying some transformation or filtering. +## Views ## +**Views** are classes that represent special kinds of ranges that do not own the data they operate on. Instead, they provide a view into a range given in the constructor by applying some transformation or filtering. -### Characteristics: -- **Non-Owning:** Views reference data that is owned elsewhere, meaning they are cheap to copy. +### Characteristics: ### +- **Non-Owning:** Views reference data owned elsewhere, meaning they are cheap to copy. - **Lazy Computation:** They compute their elements on-the-fly as you iterate through them. -- **Composable:** Multiple views can be composed together to form complex data processing pipelines. +- **Composable:** Multiple views can be composed to form complex data processing pipelines. An example of a view is `std::ranges::filter_view`, which takes a range and a predicate and returns a view that only includes elements for which the predicate returns `true`: @@ -30,8 +30,8 @@ An example of a view is `std::ranges::filter_view`, which takes a range and a pr for (int n : even_nums) std::cout << n << ' '; // prints 2 4 ``` -## Range Adaptors -Range **Adaptors** are functions that take one or more ranges as input and produce a new view. They adapt a range by transforming it in some way, such as filtering elements or transforming them. +## Range Adaptors ## +Range **Adaptors** are functions that take one or more ranges as input and produce a new view. They adapt a range by transforming it, such as filtering elements or transforming them. They can be piped, i.e. chained together, to create complex data processing pipelines. Practically for every view there is a corresponding range adaptor. For instance, the `std::ranges::filter_view` view has a corresponding `std::ranges::views::filter` range adaptor. The previous example may be rewritten as: ```c++ @@ -62,7 +62,7 @@ But you can do more complex stuff: ### Common Range Adaptors: - `views::filter`: Creates a view that includes only elements for which a predicate returns `true`. -- `views::transform`: Applies a function to each element of a range and returns a view of the results. +- `views::transform`: Applies a function to each range element and returns a view of the results. - `views::take`: Produces a view consisting of the first `n` elements of the input range. - `views::drop`: Creates a view that skips the first `n` elements of the input range. - `views::reverse`: Produces a view with the elements of the range in reverse order. @@ -101,12 +101,13 @@ Yet, they can still work with an iterator-sentinel pair if needed, offering flex // Constrained algorithm with a projection (comparison operator is still required, but here we use the default less-than) std::ranges::sort(range, {}, [](int a) { return std::abs(a); });// the projector is the third argument ``` -Projection can also be adopted to specify the element to be used in the algorithm. For instance, in the following example we sort a vector of pairs by the second element of the pair: +Projection can also be adopted to specify the element used in the algorithm. For instance, in the following example, we sort a vector of pairs by the second element of the pair: + ```cpp std::vector> v = {{1, 2}, {2, 1}, {3, 3}}; std::ranges::sort(v, {}, [](auto p) { return p.second; }); ``` -- **Pointer-to-Member Callables**: These algorithms support pointer-to-member callables, which can be used to specify operations on member variables of class objects within a range. +- **Pointer-to-Member Callables**: These algorithms support pointer-to-member callables, which can specify operations on member variables of class objects within a range. An example: ```cpp struct Person { @@ -185,7 +186,7 @@ auto even_nums_vec = range_to_vector(even_nums);// use the view to build a vecto ... ``` -# What do I learn here ? +# What do I learn here ? # - The use of a very recent addition to the C++ language - A new way of handling containers and algorithm. Cleaner and more effective. It will probably rapidly become the normal way of programming with the containers of the standard library in modern C++;