namespace cpp {}

C++ lernen, kennen, anwenden

Benutzer-Werkzeuge

Webseiten-Werkzeuge


kennen:lib:exclusive_scan

exclusive_scan()

#include <numeric>

T exclusive_scan (In first, In last, Out result, T startwert) 
T exclusive_scan (In first, In last, Out result, T startwert, Binary op) 
 
T exclusive_scan (Exec pol, In first, In last, Out result, T startwert) 
T exclusive_scan (Exec pol, In first, In last, Out result, T startwert, Binary op) 

Bildet die "Partialsummenfolge" für alle Werte des Bereiches [first,last-1). zuzüglich startwert als ersten Ergebniswert. Die Reihenfolge der "Additionen" op ist nicht festgelegt.

Die Verarbeitung der Werte erfolgt nach dem Rechenschema

          x1   x2   x3   x4  ...  xn-1 xn
          |    |    |    |        |
          v    v    v    v        v
         .+   .+   .+   .+       .+    
        / |  / |  / |  / |      / |
       /  v /  v /  v /  v /      v
startwert s1   s2   s3   s4  ...  sn

Parameter

first Anfang des Bereiches
last Ende des Bereiches
result Anfang des Ergebnisbereiches
startwert Anfangswert der Berechnung
op zweistelliges Funktionsobjekt
pol parallele Ausführungsart

Ergebnis

Rückgabewert: Iterator auf Ende des Ergebnisbereiches

Siehe auch

Beispiel

exclusive_scan.cpp
#include <functional>
#include <numeric>
#include <iostream>
 
int main()
{
  double arr[] = { 1, 2, 3, 4, 5 };
  double sum[5]; 
 
  std::exclusive_scan(arr, arr+5, sum, 100, std::plus{});
 
  for (double d : sum)
  {
    std::cout << d << ' ';
  }
  std::cout << '\n';   
}
kennen/lib/exclusive_scan.txt · Zuletzt geändert: 2021-07-31 11:52 von 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki