std::valarray<T>:: size
From cppreference.com
C++
Numerics library
Common mathematical functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Mathematical special functions (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Mathematical constants (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Basic linear algebra algorithms (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Data-parallel types (
simd
)
(C++26)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Floating-point environment (C++11) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Numeric array (
valarray
)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Saturation arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bit operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
std::
size_t
size
(
)
const
;
|
||
Returns the number of elements in the valarray.
Parameters
(none)
Return value
Number of elements in the valarray.
Example
Run this code
#include <iostream> #include <valarray> int main() { std::valarray<double> a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; std::cout << "Average: " << a.sum()/a.size() << '\n'; }
Output:
Average: 5.5
See also
changes the size of valarray
(public member function) |
Retrieved from "
https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/valarray/size&oldid=124258
"