v0.5.86
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 110 of file speed_test.cpp.

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

◆ unfused()

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

Definition at line 75 of file speed_test.cpp.

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

Variable Documentation

◆ N

const int N =60000

Definition at line 3 of file speed_test.cpp.