File: benchmarkXcwise.cpp

package info (click to toggle)
eigen3 3.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,492 kB
  • sloc: cpp: 151,572; ansic: 75,396; fortran: 24,137; sh: 971; python: 244; javascript: 205; makefile: 42
file content (35 lines) | stat: -rw-r--r-- 605 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// g++ -O3 -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX

#include <iostream>
#include <Eigen/Core>

using namespace std;
using namespace Eigen;

#ifndef VECTYPE
#define VECTYPE VectorXLd
#endif

#ifndef VECSIZE
#define VECSIZE 1000000
#endif

#ifndef REPEAT
#define REPEAT 1000
#endif

int main(int argc, char *argv[])
{
	VECTYPE I = VECTYPE::Ones(VECSIZE);
	VECTYPE m(VECSIZE,1);
	for(int i = 0; i < VECSIZE; i++)
	{
		m[i] = 0.1 * i/VECSIZE;
	}
	for(int a = 0; a < REPEAT; a++)
	{
		m = VECTYPE::Ones(VECSIZE) + 0.00005 * (m.cwise().square() + m/4);
	}
	cout << m[0] << endl;
	return 0;
}