Skip to content
Snippets Groups Projects
Commit 44d08f19 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Writing documentation on StaticFor.

parent 6eb47984
No related branches found
No related tags found
1 merge request!44Tutorials
This commit is part of merge request !44. Comments created here will be created in the context of that merge request.
#include <iostream>
#include <cstdlib>
#include <TNL/Containers/StaticVector.h>
#include <TNL/Algorithms/StaticFor.h>
using namespace TNL;
using namespace TNL::Containers;
int main( int argc, char* argv[] )
{
/****
* Create two static vectors
*/
const int Size( 3 );
StaticVector< Size, double > a, b;
a = 1.0;
b = 2.0;
double sum( 0.0 );
/****
* Compute an addition of a vector and a constant number.
*/
auto addition = [&]( int i, const double& c ) { a[ i ] = b[ i ] + c; sum += a[ i ]; };
Algorithms::StaticFor< 0, Size >::exec( addition, 3.14 );
std::cout << "a = " << a << std::endl;
std::cout << "sum = " << sum << std::endl;
}
for( int i = 0; i < Size; i++ )
{
a[ i ] = b[ i ] + c; sum += a[ i ];
};
Algorithms::StaticFor< 0, Size, true >::exec( addition, 3.14 );
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment