Numeric
Example of using the standard library numeric functions.
- Boards: 🛈
- AVR, AVR USB, Nano Every, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Due, Teensy 3.x, ESP8266, ESP32
This sketch creates an incremental array using the iota function, then computes the inner product of the vector with itself, and uses that to calculate the norm of the vector.
Output
v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Array< T, N > copyAs(const Array< U, N > &src)
Copy an Array to an Array of a different type.
Written by PieterP, 2019-11-18
https://github.com/tttapa/Arduino-Helpers
#include <AH/STL/cmath>
#include <AH/STL/numeric>
;
double norm = std::sqrt(
sum_sq);
}
void loop() {}
Dummy header file for Arduino builder.
Print & endl(Print &printer)
Setprecision setprecision(int n)
An array wrapper for easy copying, comparing, and iterating.