v0.7.24
Functions | Variables
speed_test.cpp File Reference
#include <ctime>
#include <iostream>

Go to the source code of this file.

Functions

void fused (const double metric[6][N], double inverse[6][N])
 
void fused_big (const double metric[6][N], double inverse[6][N])
 
void unfused (const double metric[6][N], double inverse[6][N])
 
int main ()
 

Variables

const int N = 60000
 

Function Documentation

◆ fused()

void fused ( const double  metric[6][N],
double  inverse[6][N] 
)

Definition at line 5 of file speed_test.cpp.

6 {
7  for(int i = 0; i < N; ++i)
8  {
9  double det = metric[0][i] * metric[3][i] * metric[5][i]
10  + metric[1][i] * metric[4][i] * metric[2][i]
11  + metric[2][i] * metric[1][i] * metric[4][i]
12  - metric[0][i] * metric[4][i] * metric[4][i]
13  - metric[1][i] * metric[1][i] * metric[5][i]
14  - metric[2][i] * metric[3][i] * metric[2][i];
15  inverse[0][i]
16  = (metric[3][i] * metric[5][i] - metric[4][i] * metric[4][i]) / det;
17  inverse[1][i]
18  = (metric[2][i] * metric[4][i] - metric[1][i] * metric[5][i]) / det;
19  inverse[2][i]
20  = (metric[1][i] * metric[4][i] - metric[2][i] * metric[3][i]) / det;
21  inverse[3][i]
22  = (metric[0][i] * metric[5][i] - metric[2][i] * metric[2][i]) / det;
23  inverse[4][i]
24  = (metric[2][i] * metric[1][i] - metric[0][i] * metric[4][i]) / det;
25  inverse[5][i]
26  = (metric[3][i] * metric[0][i] - metric[1][i] * metric[1][i]) / det;
27  }
28 }
const int N
Definition: speed_test.cpp:3

◆ fused_big()

void fused_big ( const double  metric[6][N],
double  inverse[6][N] 
)

Definition at line 30 of file speed_test.cpp.

31 {
32  double det[N];
33  for(int i = 0; i < N; ++i)
34  {
35  det[i] = metric[0][i] * metric[3][i] * metric[5][i]
36  + metric[1][i] * metric[4][i] * metric[2][i]
37  + metric[2][i] * metric[1][i] * metric[4][i]
38  - metric[0][i] * metric[4][i] * metric[4][i]
39  - metric[1][i] * metric[1][i] * metric[5][i]
40  - metric[2][i] * metric[3][i] * metric[2][i];
41  }
42  for(int i = 0; i < N; ++i)
43  {
44  inverse[0][i]
45  = (metric[3][i] * metric[5][i] - metric[4][i] * metric[4][i]) / det[i];
46  }
47  for(int i = 0; i < N; ++i)
48  {
49  inverse[1][i]
50  = (metric[2][i] * metric[4][i] - metric[1][i] * metric[5][i]) / det[i];
51  }
52  for(int i = 0; i < N; ++i)
53  {
54  inverse[2][i]
55  = (metric[1][i] * metric[4][i] - metric[2][i] * metric[3][i]) / det[i];
56  }
57  for(int i = 0; i < N; ++i)
58  {
59  inverse[3][i]
60  = (metric[0][i] * metric[5][i] - metric[2][i] * metric[2][i]) / det[i];
61  }
62  for(int i = 0; i < N; ++i)
63  {
64  inverse[4][i]
65  = (metric[2][i] * metric[1][i] - metric[0][i] * metric[4][i]) / det[i];
66  }
67  for(int i = 0; i < N; ++i)
68  {
69  inverse[5][i]
70  = (metric[3][i] * metric[0][i] - metric[1][i] * metric[1][i]) / det[i];
71  }
72 }
const int N
Definition: speed_test.cpp:3

◆ main()

int main ( )

Definition at line 109 of file speed_test.cpp.

110 {
111  double metric[6][N], inverse[6][N];
112 
113  for(int j = 0; j < 6; ++j)
114  for(int i = 0; i < N; ++i)
115  metric[j][i] = 1 + i + j;
116 
117  const int iterations = 30;
118 
119  for(int i = 0; i < iterations; ++i)
120  {
121  // fused_big(metric,inverse);
122  // fused(metric,inverse);
123  // unfused(metric,inverse);
124  }
125 }
const int N
Definition: speed_test.cpp:3

◆ unfused()

void unfused ( const double  metric[6][N],
double  inverse[6][N] 
)

Definition at line 74 of file speed_test.cpp.

75 {
76  double det[N];
77 
78  for(int i = 0; i < N; ++i)
79  det[i] = metric[0][i] * metric[3][i] * metric[5][i]
80  + metric[1][i] * metric[4][i] * metric[2][i]
81  + metric[2][i] * metric[1][i] * metric[4][i]
82  - metric[0][i] * metric[4][i] * metric[4][i]
83  - metric[1][i] * metric[1][i] * metric[5][i]
84  - metric[2][i] * metric[3][i] * metric[2][i];
85  for(int i = 0; i < N; ++i)
86  inverse[0][i]
87  = (metric[3][i] * metric[5][i] - metric[4][i] * metric[4][i]) / det[i];
88  for(int i = 0; i < N; ++i)
89  inverse[1][i]
90  = (metric[2][i] * metric[4][i] - metric[1][i] * metric[5][i]) / det[i];
91  for(int i = 0; i < N; ++i)
92  inverse[2][i]
93  = (metric[1][i] * metric[4][i] - metric[2][i] * metric[3][i]) / det[i];
94  for(int i = 0; i < N; ++i)
95  inverse[3][i]
96  = (metric[0][i] * metric[5][i] - metric[2][i] * metric[2][i]) / det[i];
97  for(int i = 0; i < N; ++i)
98  inverse[4][i]
99  = (metric[2][i] * metric[1][i] - metric[0][i] * metric[4][i]) / det[i];
100  for(int i = 0; i < N; ++i)
101  inverse[5][i]
102  = (metric[3][i] * metric[0][i] - metric[1][i] * metric[1][i]) / det[i];
103 }
const int N
Definition: speed_test.cpp:3

Variable Documentation

◆ N

const int N = 60000

Definition at line 3 of file speed_test.cpp.