CDT++
Causal Dynamical Triangulations in C++
Loading...
Searching...
No Matches
S3Action.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 Causal Dynamical Triangulations in C++ using CGAL
3
4 Copyright © 2014 Adam Getchell
5 ******************************************************************************/
6
16
17#ifndef INCLUDE_S3ACTION_HPP_
18#define INCLUDE_S3ACTION_HPP_
19
20#include <mpfr.h>
21
22#include <Settings.hpp>
23
24#pragma GCC diagnostic push
25#pragma GCC diagnostic ignored "-Wcomment"
26
47[[nodiscard]] inline auto S3_bulk_action_alpha_minus_one(
48 Int_precision const N1_TL, Int_precision const N3_31_13,
49 Int_precision const N3_22, long double const K,
50 long double const Lambda) noexcept -> Gmpzf
51{
52 // Set precision for initialization and assignment functions
53 mpfr_set_default_prec(PRECISION);
54
55 // Initialize for MPFR
56 mpfr_t n1_tl;
57 mpfr_t n3_31;
58 mpfr_t n3_22;
59 mpfr_t k;
60 mpfr_t lambda;
61 mpfr_t two;
62 mpfr_t pi;
63 mpfr_t r1;
64 mpfr_t r2;
65 mpfr_t r3;
66 mpfr_t const2673;
67 mpfr_t const118;
68 mpfr_t r4;
69 mpfr_t r5;
70 mpfr_t r6;
71 mpfr_t r7;
72 mpfr_t const7386;
73 mpfr_t r8;
74 mpfr_t r9;
75 mpfr_t r10;
76 mpfr_t r11;
77 mpfr_t r12;
78 mpfr_t total;
79 mpfr_inits2(PRECISION, pi, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12,
80 total, nullptr);
81
82 // Set input parameters and constants to mpfr_t equivalents
83 mpfr_init_set_si(n1_tl, N1_TL, MPFR_RNDD);
84 mpfr_init_set_si(n3_31, N3_31_13, MPFR_RNDD);
85 mpfr_init_set_si(n3_22, N3_22, MPFR_RNDD);
86 mpfr_init_set_ld(k, K, MPFR_RNDD);
87 mpfr_init_set_ld(lambda, Lambda, MPFR_RNDD);
88 mpfr_init_set_str(two, "2.0", 10, MPFR_RNDD);
89 mpfr_const_pi(pi, MPFR_RNDD);
90 mpfr_init_set_str(const2673, "2.673", 10, MPFR_RNDD);
91 mpfr_init_set_str(const118, "0.118", 10, MPFR_RNDD);
92 mpfr_init_set_str(const7386, "7.386", 10, MPFR_RNDD);
93
94 // First term accumulates in r3
95 mpfr_mul(r1, two, pi, MPFR_RNDD); // r1 = 2*pi
96 mpfr_mul(r2, r1, k, MPFR_RNDD); // r2 = 2*pi*k
97 mpfr_mul(r3, r2, n1_tl, MPFR_RNDD); // r3 = 2*pi*k*n1_tl
98
99 // Second term accumulates in r7
100 mpfr_mul(r4, const2673, k, MPFR_RNDD); // r4 = 2.673*k
101 mpfr_mul(r5, const118, lambda, MPFR_RNDD); // r5 = 0.118*lambda
102 mpfr_add(r6, r4, r5, MPFR_RNDD); // r6 = r4 + r5
103 mpfr_mul(r7, n3_31, r6, MPFR_RNDD); // r7 = n3_31*r6
104
105 // Third term accumulates in r11
106 mpfr_mul(r8, const7386, k, MPFR_RNDD); // r8 = 7.386*k
107 mpfr_mul(r9, const118, lambda, MPFR_RNDD); // r9 = 0.118*lambda
108 mpfr_add(r10, r8, r9, MPFR_RNDD); // r10 = r8+r9
109 mpfr_mul(r11, n3_22, r10, MPFR_RNDD); // r11 = n3_22*r10
110
111 // Result is r3+r7+r11
112 mpfr_sub(r12, r7, r3, MPFR_RNDD); // r12 = r7-r3
113 mpfr_add(total, r11, r12, MPFR_RNDD); // total = r11+r12
114
115 // Convert mpfr_t total to Gmpzf result by using Gmpzf(double d)
116 // Perhaps fixable later by switching to MP_Float
117 auto const result = mpfr_get_d(total, MPFR_RNDD);
118
119 // Free memory
120 mpfr_clears(n1_tl, n3_31, n3_22, k, lambda, two, pi, r1, r2, r3, const2673,
121 const118, r4, r5, r6, r7, const7386, r8, r9, r10, r11, r12, total,
122 nullptr);
123
124 return result;
125} // S3_bulk_action_alpha_minus_one()
126
144[[nodiscard]] inline auto S3_bulk_action_alpha_one(
145 Int_precision const N1_TL, Int_precision const N3_31_13,
146 Int_precision const N3_22, long double const K,
147 long double const Lambda) noexcept -> Gmpzf
148{
149 // Set precision for initialization and assignment functions
150 mpfr_set_default_prec(PRECISION);
151
152 // Initialize for MPFR
153 mpfr_t n1_tl;
154 mpfr_t n3_31;
155 mpfr_t n3_22;
156 mpfr_t k;
157 mpfr_t lambda;
158 mpfr_t two;
159 mpfr_t pi;
160 mpfr_t r1;
161 mpfr_t r2;
162 mpfr_t r3;
163 mpfr_t const3548;
164 mpfr_t const167;
165 mpfr_t r4;
166 mpfr_t r5;
167 mpfr_t r6;
168 mpfr_t r7;
169 mpfr_t const5355;
170 mpfr_t const204;
171 mpfr_t r8;
172 mpfr_t r9;
173 mpfr_t r10;
174 mpfr_t r11;
175 mpfr_t r12;
176 mpfr_t total;
177 mpfr_inits2(PRECISION, pi, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12,
178 total, nullptr);
179
180 // Set input parameters and constants to mpfr_t equivalents
181 mpfr_init_set_si(n1_tl, N1_TL, MPFR_RNDD);
182 mpfr_init_set_si(n3_31, N3_31_13, MPFR_RNDD);
183 mpfr_init_set_si(n3_22, N3_22, MPFR_RNDD);
184 mpfr_init_set_ld(k, K, MPFR_RNDD);
185 mpfr_init_set_ld(lambda, Lambda, MPFR_RNDD);
186 mpfr_init_set_str(two, "2.0", 10, MPFR_RNDD);
187 mpfr_const_pi(pi, MPFR_RNDD);
188 mpfr_init_set_str(const3548, "-3.548", 10, MPFR_RNDD);
189 mpfr_init_set_str(const167, "-0.167", 10, MPFR_RNDD);
190 mpfr_init_set_str(const5355, "-5.355", 10, MPFR_RNDD);
191 mpfr_init_set_str(const204, "-0.204", 10, MPFR_RNDD);
192
193 // First term accumulates in r3
194 mpfr_mul(r1, two, pi, MPFR_RNDD); // r1 = 2*pi
195 mpfr_mul(r2, r1, k, MPFR_RNDD); // r2 = 2*pi*k
196 mpfr_mul(r3, r2, n1_tl, MPFR_RNDD); // r3 = 2*pi*k*n1_tl
197
198 // Second term accumulates in r7
199 mpfr_mul(r4, const3548, k, MPFR_RNDD); // r4 = -3.548*k
200 mpfr_mul(r5, const167, lambda, MPFR_RNDD); // r5 = -0.167*lambda
201 mpfr_add(r6, r4, r5, MPFR_RNDD); // r6 = r4 + r5
202 mpfr_mul(r7, n3_31, r6, MPFR_RNDD); // r7 = n3_31*r6
203
204 // Third term accumulates in r11
205 mpfr_mul(r8, const5355, k, MPFR_RNDD); // r8 = -5.355*k
206 mpfr_mul(r9, const204, lambda, MPFR_RNDD); // r9 = -0.204*lambda
207 mpfr_add(r10, r8, r9, MPFR_RNDD); // r10 = r8+r9
208 mpfr_mul(r11, n3_22, r10, MPFR_RNDD); // r11 = n3_22*r10
209
210 // Result is r3+r7+r11
211 mpfr_add(r12, r3, r7, MPFR_RNDD); // r12 = r3+r7
212 mpfr_add(total, r11, r12, MPFR_RNDD); // total = r11+r12
213
214 // Convert mpfr_t total to Gmpzf result by using Gmpzf(double d)
215 // Perhaps fixable later by switching to MP_Float
216 auto const result = mpfr_get_d(total, MPFR_RNDD);
217
218 // Free memory
219 mpfr_clears(n1_tl, n3_31, n3_22, k, lambda, two, pi, r1, r2, r3, const3548,
220 const167, r4, r5, r6, r7, const5355, const204, r8, r9, r10, r11,
221 r12, total, nullptr);
222
223 return result;
224} // Gmpzf S3_bulk_action_alpha_one()
225
252[[nodiscard]] inline auto S3_bulk_action(
253 Int_precision const N1_TL, Int_precision const N3_31_13,
254 Int_precision const N3_22, long double const Alpha, long double const K,
255 long double const Lambda) noexcept -> Gmpzf
256{
257 // Set precision for initialization and assignment functions
258 mpfr_set_default_prec(PRECISION);
259
260 // Initialize for MPFR
261 mpfr_t n1_tl;
262 mpfr_t n3_31;
263 mpfr_t n3_22;
264 mpfr_t alpha;
265 mpfr_t k;
266 mpfr_t lambda;
267 mpfr_t two;
268 mpfr_t pi;
269 mpfr_t r1;
270 mpfr_t r2;
271 mpfr_t r3;
272 mpfr_t r4;
273 mpfr_t r5;
274 mpfr_t r6;
275 mpfr_t three;
276 mpfr_t r7;
277 mpfr_t four;
278 mpfr_t r8;
279 mpfr_t one;
280 mpfr_t r9;
281 mpfr_t r10;
282 mpfr_t r11;
283 mpfr_t r12;
284 mpfr_t r13;
285 mpfr_t r14;
286 mpfr_t r15;
287 mpfr_t r16;
288 mpfr_t r17;
289 mpfr_t r18;
290 mpfr_t r19;
291 mpfr_t r20;
292 mpfr_t r21;
293 mpfr_t twelve;
294 mpfr_t r22;
295 mpfr_t r23;
296 mpfr_t r24;
297 mpfr_t r25;
298 mpfr_t r26;
299 mpfr_t r27;
300 mpfr_t r28;
301 mpfr_t r29;
302 mpfr_t r30;
303 mpfr_t r31;
304 mpfr_t r32;
305 mpfr_t r33;
306 mpfr_t r34;
307 mpfr_t r35;
308 mpfr_t r36;
309 mpfr_t r37;
310 mpfr_t r38;
311 mpfr_t r39;
312 mpfr_t r40;
313 mpfr_t r41;
314 mpfr_t r42;
315 mpfr_t r43;
316 mpfr_t r44;
317 mpfr_t r45;
318 mpfr_t r46;
319 mpfr_t r47;
320 mpfr_t r48;
321 mpfr_t r49;
322 mpfr_t r50;
323 mpfr_t r51;
324 mpfr_t r52;
325 mpfr_t total;
326 mpfr_inits2(PRECISION, pi, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12,
327 r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25,
328 r26, r27, r28, r29, r30, r31, r32, r33, r34, r35, r36, r37, r38,
329 r39, r40, r41, r42, r43, r44, r45, r46, r47, r48, r49, r50, r51,
330 r52, total, nullptr);
331
332 // Set input parameters and constants to mpfr_t equivalents
333 mpfr_init_set_si(n1_tl, N1_TL, MPFR_RNDD);
334 mpfr_init_set_si(n3_31, N3_31_13, MPFR_RNDD);
335 mpfr_init_set_si(n3_22, N3_22, MPFR_RNDD);
336 mpfr_init_set_ld(alpha, Alpha, MPFR_RNDD);
337 mpfr_init_set_ld(k, K, MPFR_RNDD);
338 mpfr_init_set_ld(lambda, Lambda, MPFR_RNDD);
339 mpfr_init_set_str(two, "2.0", 10, MPFR_RNDD);
340 mpfr_const_pi(pi, MPFR_RNDD);
341 mpfr_init_set_str(three, "3.0", 10, MPFR_RNDD);
342 mpfr_init_set_str(four, "4.0", 10, MPFR_RNDD);
343 mpfr_init_set_str(one, "1.0", 10, MPFR_RNDD);
344 mpfr_init_set_str(twelve, "12.0", 10, MPFR_RNDD);
345
346 // First term accumulates in r5
347 mpfr_mul(r1, two, pi, MPFR_RNDD); // r1 = 2*pi
348 mpfr_mul(r2, r1, k, MPFR_RNDD); // r2 = 2*pi*k
349 mpfr_sqrt(r3, alpha, MPFR_RNDD); // r3 = sqrt(alpha)
350 mpfr_mul(r4, r3, r2, MPFR_RNDD); // r4 = r3*r2 = 2*pi*k*sqrt(alpha)
351 mpfr_mul(r5, r4, n1_tl, MPFR_RNDD); // r5 = r4*n1_tl
352
353 // Second term accumulates in r30
354 mpfr_sqrt(r6, three, MPFR_RNDD); // r6 = sqrt(3)
355 mpfr_mul(r7, four, alpha, MPFR_RNDD); // r7 = 4*alpha
356 mpfr_add(r8, one, r7, MPFR_RNDD); // r8 = r7+1 = 4*alpha+1
357 mpfr_sqrt(r9, r8, MPFR_RNDD); // r9 = sqrt(r8) = sqrt(4*alpha+1)
358 mpfr_mul(r10, r6, r9, MPFR_RNDD); // r10 = r6*r9
359 mpfr_div(r11, one, r10, MPFR_RNDD); // r11 = 1/r10
360 mpfr_asinh(r12, r11, MPFR_RNDD); // r12 = arcsinh(r11)
361 mpfr_neg(r13, three, MPFR_RNDD); // r13 = -3
362 mpfr_mul(r14, r13, k, MPFR_RNDD); // r14 = r13*k = -3*k
363 mpfr_mul(r15, r14, r12, MPFR_RNDD); // r15 = r14*r12 = -3*k*arcsinh(r11)
364
365 mpfr_mul(r16, two, alpha, MPFR_RNDD); // r16 = 2*alpha
366 mpfr_add(r17, r16, one, MPFR_RNDD); // r17 = 2*alpha+1
367 mpfr_div(r18, r17, r8, MPFR_RNDD); // r18 = (2*alpha+1)/(4*alpha+1)
368 mpfr_acos(r19, r18, MPFR_RNDD); // r19 = arccos(r18)
369 mpfr_mul(r20, r14, r3, MPFR_RNDD); // r20 = -3*k*sqrt(alpha)
370 mpfr_mul(r21, r20, r19, MPFR_RNDD); // r21 = -3*k*sqrt(alpha)*arccos(r18)
371
372 mpfr_mul(r22, three, alpha, MPFR_RNDD); // r22 = 3*alpha
373 mpfr_add(r23, r22, one, MPFR_RNDD); // r23 = 3*alpha+1
374 mpfr_sqrt(r24, r23, MPFR_RNDD); // r24 = sqrt(3*alpha+1)
375 mpfr_neg(r25, lambda, MPFR_RNDD); // r25 = -lambda
376 mpfr_div(r26, r25, twelve, MPFR_RNDD); // r26 = -lambda/12
377 mpfr_mul(r27, r26, r24, MPFR_RNDD); // r27 = (-lambda/12)*sqrt(3*alpha+1)
378
379 // Accumulate partial sums of second term
380 mpfr_add(r28, r15, r21, MPFR_RNDD); // r28 = r15+r21
381 mpfr_add(r29, r28, r27, MPFR_RNDD); // r29 = r28+r27
382
383 // Multiply by overall factor of n3_31
384 mpfr_mul(r30, n3_31, r29, MPFR_RNDD); // r30 = n3_31*r29
385
386 // Third term accumulates in r51
387 mpfr_mul(r31, two, k, MPFR_RNDD); // r31 = 2*k
388 mpfr_sqrt(r32, two, MPFR_RNDD); // r32 = sqrt(2)
389 mpfr_mul(r33, two, r32, MPFR_RNDD); // r33 = 2*sqrt(2)
390 mpfr_sqrt(r34, r17, MPFR_RNDD); // r34 = sqrt(2*alpha+1)
391 mpfr_mul(r35, r33, r34, MPFR_RNDD); // r35 = r33*r34
392 mpfr_div(r36, r35, r8, MPFR_RNDD); // r36 = 2*sqrt(2)*sqrt(2*alpha+1)/
393 // 4*alpha+1
394 mpfr_asinh(r37, r36, MPFR_RNDD); // r37 = arcsinh(r36)
395 mpfr_mul(r38, r31, r37, MPFR_RNDD); // r38 = 2*k*arcsinh(r36)
396
397 mpfr_neg(r39, one, MPFR_RNDD); // r39 = -1
398 mpfr_div(r40, r39, r8, MPFR_RNDD); // r40 = -1/(4*alpha+1)
399 mpfr_acos(r41, r40, MPFR_RNDD); // r41 = arccos(r40)
400 mpfr_neg(r42, four, MPFR_RNDD); // r42 = -4
401 mpfr_mul(r43, r42, k, MPFR_RNDD); // r43 = -4*k
402 mpfr_mul(r44, r43, r3, MPFR_RNDD); // r44 = -4*k*sqrt(alpha)
403 mpfr_mul(r45, r44, r41, MPFR_RNDD); // r45 = -4*k*sqrt(alpha)*arccos(r40)
404
405 mpfr_add(r46, r7, two, MPFR_RNDD); // r46 = 4*alpha+2
406 mpfr_sqrt(r47, r46, MPFR_RNDD); // r47 = sqrt(4*alpha+2)
407 mpfr_mul(r48, r26, r47, MPFR_RNDD); // r48 = (-lambda/12)*sqrt(4*alpha+2)
408
409 // Accumulate partial sums of third term
410 mpfr_add(r49, r38, r45, MPFR_RNDD); // r49 = r38+r45
411 mpfr_add(r50, r49, r48, MPFR_RNDD); // r50 = r49+r48
412
413 // Multiply by overall factor of n3_22
414 mpfr_mul(r51, n3_22, r50, MPFR_RNDD); // r51 = n3_22*r50
415
416 mpfr_add(r52, r5, r30, MPFR_RNDD); // r52 = r5+r30
417 mpfr_add(total, r51, r52, MPFR_RNDD); // total = r51+r52
418
419 // Convert mpfr_t total to Gmpzf result by using Gmpzf(double d)
420 // Perhaps fixable later by switching to MP_Float
421 auto const result = mpfr_get_d(total, MPFR_RNDD);
422
423 // Free memory
424 mpfr_clears(n1_tl, n3_31, n3_22, alpha, k, lambda, two, pi, r1, r2, r3, r4,
425 r5, r6, three, r7, four, r8, one, r9, r10, r11, r12, r13, r14,
426 r15, r16, r17, r18, r19, r20, r21, twelve, r22, r23, r24, r25,
427 r26, r27, r28, r29, r30, r31, r32, r33, r34, r35, r36, r37, r38,
428 r39, r40, r41, r42, r43, r44, r45, r46, r47, r48, r49, r50, r51,
429 r52, total, nullptr);
430
431 return result;
432} // Gmpzf S3_bulk_action()
433
434#pragma GCC diagnostic pop
435
436#endif // INCLUDE_S3ACTION_HPP_
auto S3_bulk_action_alpha_one(Int_precision const N1_TL, Int_precision const N3_31_13, Int_precision const N3_22, long double const K, long double const Lambda) noexcept -> Gmpzf
Calculates S3 bulk action for =1.
Definition: S3Action.hpp:144
auto S3_bulk_action_alpha_minus_one(Int_precision const N1_TL, Int_precision const N3_31_13, Int_precision const N3_22, long double const K, long double const Lambda) noexcept -> Gmpzf
Calculates S3 bulk action for =-1.
Definition: S3Action.hpp:47
auto S3_bulk_action(Int_precision const N1_TL, Int_precision const N3_31_13, Int_precision const N3_22, long double const Alpha, long double const K, long double const Lambda) noexcept -> Gmpzf
Calculates the generalized S3 bulk action in terms of , , , , , and .
Definition: S3Action.hpp:252
Global integer and precision settings.
std::int_fast32_t Int_precision
Definition: Settings.hpp:31
static Int_precision constexpr PRECISION
Sets the precision for MPFR.
Definition: Settings.hpp:44