sofars 0.6.2

Pure Rust implementation of the IAU SOFA library
Documentation
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
#![allow(clippy::approx_constant)]
use criterion::{Criterion, criterion_group, criterion_main};
use sofars::astro::*;
use std::hint::black_box;

fn bench_astro(c: &mut Criterion) {
    let mut group = c.benchmark_group("astro");

    // Common test parameters
    let utc1 = 2456384.5;
    let utc2 = 0.969254051;
    let tt1 = 2456165.5;
    let tt2 = 0.401182685;
    let dut1 = 0.1550675;
    let elong = -0.527800806;
    let phi = -1.2345856;
    let hm = 2738.0;
    let xp = 2.47230737e-7;
    let yp = 1.82640464e-6;
    let phpa = 731.0;
    let tc = 12.8;
    let rh = 0.59;
    let wl = 0.55;

    let rc = 2.71;
    let dc = 0.174;
    let pr = 1e-5;
    let pd = 5e-6;
    let px = 0.1;
    let rv = 55.0;

    // pmsafe
    group.bench_function("pmsafe", |b| {
        b.iter(|| {
            pmsafe(
                black_box(1.234),
                black_box(0.789),
                black_box(1e-5),
                black_box(-2e-5),
                black_box(1e-2),
                black_box(10.0),
                black_box(2400000.5),
                black_box(48348.5625),
                black_box(2400000.5),
                black_box(51544.5),
            )
        })
    });

    // atoi13
    group.bench_function("atoi13", |b| {
        b.iter(|| {
            atoi13(
                black_box("R"),
                black_box(2.710085107986886201),
                black_box(0.1717653435758265198),
                black_box(utc1),
                black_box(utc2),
                black_box(dut1),
                black_box(elong),
                black_box(phi),
                black_box(hm),
                black_box(xp),
                black_box(yp),
                black_box(phpa),
                black_box(tc),
                black_box(rh),
                black_box(wl),
            )
        })
    });

    // atoc13
    group.bench_function("atoc13", |b| {
        b.iter(|| {
            atoc13(
                black_box("R"),
                black_box(2.710085107986886201),
                black_box(0.1717653435758265198),
                black_box(utc1),
                black_box(utc2),
                black_box(dut1),
                black_box(elong),
                black_box(phi),
                black_box(hm),
                black_box(xp),
                black_box(yp),
                black_box(phpa),
                black_box(tc),
                black_box(rh),
                black_box(wl),
            )
        })
    });

    // ab
    let pnat = [-0.76, -0.60, -0.21];
    let v_ab = [2.1e-5, -8.9e-5, -3.8e-5];
    group.bench_function("ab", |b| {
        b.iter(|| {
            ab(
                black_box(&pnat),
                black_box(&v_ab),
                black_box(0.999),
                black_box(0.999),
            )
        })
    });

    // pvstar
    let pv_data = [[126668.5, 2136.7, -245251.2], [-0.004, -0.006, 0.011]];
    group.bench_function("pvstar", |b| b.iter(|| pvstar(black_box(&pv_data))));

    // pvtob
    group.bench_function("pvtob", |b| {
        let mut pv = [[0.0; 3]; 2];
        b.iter(|| {
            pvtob(
                black_box(elong),
                black_box(phi),
                black_box(hm),
                black_box(xp),
                black_box(yp),
                black_box(1e-8),
                black_box(5.0),
                &mut pv,
            )
        })
    });

    // apcg
    let ebpv = [[0.9, -0.4, -0.1], [0.007, 0.014, 0.006]];
    let ehp = [0.9, -0.4, -0.1];
    group.bench_function("apcg", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| {
            apcg(
                black_box(tt1),
                black_box(tt2),
                black_box(&ebpv),
                black_box(&ehp),
                &mut astrom,
            )
        })
    });

    // apcg13
    group.bench_function("apcg13", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| apcg13(black_box(tt1), black_box(tt2), &mut astrom))
    });

    // apci
    group.bench_function("apci", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| {
            apci(
                black_box(tt1),
                black_box(tt2),
                black_box(&ebpv),
                black_box(&ehp),
                black_box(0.001),
                black_box(-2e-5),
                black_box(3e-8),
                &mut astrom,
            )
        })
    });

    // apci13
    group.bench_function("apci13", |b| {
        let mut astrom = IauAstrom::default();
        let mut eo = 0.0;
        b.iter(|| apci13(black_box(tt1), black_box(tt2), &mut astrom, &mut eo))
    });

    // apcs
    let pv_apcs = [[-1836024.0, 1056607.0, -5998795.0], [-77.0, -133.0, 0.09]];
    group.bench_function("apcs", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| {
            apcs(
                black_box(tt1),
                black_box(tt2),
                black_box(&pv_apcs),
                black_box(&ebpv),
                black_box(&ehp),
                &mut astrom,
            )
        })
    });

    // apcs13
    group.bench_function("apcs13", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| {
            apcs13(
                black_box(tt1),
                black_box(tt2),
                black_box(&pv_apcs),
                &mut astrom,
            )
        })
    });

    // aper
    group.bench_function("aper", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| aper(black_box(5.678), &mut astrom))
    });

    // aper13
    group.bench_function("aper13", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| aper13(black_box(tt1), black_box(tt2), &mut astrom))
    });

    // atcc13
    group.bench_function("atcc13", |b| {
        b.iter(|| {
            atcc13(
                black_box(rc),
                black_box(dc),
                black_box(pr),
                black_box(pd),
                black_box(px),
                black_box(rv),
                black_box(tt1),
                black_box(tt2),
            )
        })
    });

    // apco
    group.bench_function("apco", |b| {
        let mut astrom = IauAstrom::default();
        b.iter(|| {
            apco(
                black_box(tt1),
                black_box(tt2),
                black_box(&ebpv),
                black_box(&ehp),
                black_box(0.001),
                black_box(-2e-5),
                black_box(3e-8),
                black_box(3.14),
                black_box(elong),
                black_box(phi),
                black_box(hm),
                black_box(xp),
                black_box(yp),
                black_box(0.0),
                black_box(0.0002),
                black_box(-2e-7),
                &mut astrom,
            )
        })
    });

    // apco13
    group.bench_function("apco13", |b| {
        let mut astrom = IauAstrom::default();
        let mut eo = 0.0;
        b.iter(|| {
            apco13(
                black_box(utc1),
                black_box(utc2),
                black_box(dut1),
                black_box(elong),
                black_box(phi),
                black_box(hm),
                black_box(xp),
                black_box(yp),
                black_box(phpa),
                black_box(tc),
                black_box(rh),
                black_box(wl),
                &mut astrom,
                &mut eo,
            )
        })
    });

    // atci13
    group.bench_function("atci13", |b| {
        b.iter(|| {
            atci13(
                black_box(rc),
                black_box(dc),
                black_box(pr),
                black_box(pd),
                black_box(px),
                black_box(rv),
                black_box(tt1),
                black_box(tt2),
            )
        })
    });

    // atciq
    group.bench_function("atciq", |b| {
        let mut astrom = IauAstrom::default();
        let mut eo = 0.0;
        apci13(tt1, tt2, &mut astrom, &mut eo);
        b.iter(|| {
            atciq(
                black_box(rc),
                black_box(dc),
                black_box(pr),
                black_box(pd),
                black_box(px),
                black_box(rv),
                &mut astrom,
            )
        })
    });

    // atciqn
    let bodies = [
        IauLdBody::new(
            0.00028574,
            3e-10,
            [[-7.81, -5.61, -1.98], [0.003, -0.004, -0.001]],
        ),
        IauLdBody::new(
            0.00095435,
            3e-9,
            [[0.738, 4.636, 1.969], [-0.007, 0.001, 0.0007]],
        ),
        IauLdBody::new(
            1.0,
            6e-6,
            [
                [-0.0007, -0.0023, -0.001],
                [0.000006, -0.0000003, -0.0000002],
            ],
        ),
    ];
    group.bench_function("atciqn", |b| {
        let mut astrom = IauAstrom::default();
        let mut eo = 0.0;
        apci13(tt1, tt2, &mut astrom, &mut eo);
        b.iter(|| {
            atciqn(
                black_box(rc),
                black_box(dc),
                black_box(pr),
                black_box(pd),
                black_box(px),
                black_box(rv),
                &mut astrom,
                black_box(3),
                black_box(&bodies),
            )
        })
    });

    // atciqz
    group.bench_function("atciqz", |b| {
        let mut astrom = IauAstrom::default();
        let mut eo = 0.0;
        apci13(tt1, tt2, &mut astrom, &mut eo);
        b.iter(|| atciqz(black_box(rc), black_box(dc), &mut astrom))
    });

    // atco13
    group.bench_function("atco13", |b| {
        b.iter(|| {
            atco13(
                black_box(rc),
                black_box(dc),
                black_box(pr),
                black_box(pd),
                black_box(px),
                black_box(rv),
                black_box(utc1),
                black_box(utc2),
                black_box(dut1),
                black_box(elong),
                black_box(phi),
                black_box(hm),
                black_box(xp),
                black_box(yp),
                black_box(phpa),
                black_box(tc),
                black_box(rh),
                black_box(wl),
            )
        })
    });

    // atic13
    group.bench_function("atic13", |b| {
        b.iter(|| atic13(black_box(rc), black_box(dc), black_box(tt1), black_box(tt2)))
    });

    // aticq
    group.bench_function("aticq", |b| {
        let mut astrom = IauAstrom::default();
        let mut eo = 0.0;
        apci13(tt1, tt2, &mut astrom, &mut eo);
        b.iter(|| aticq(black_box(rc), black_box(dc), &mut astrom))
    });

    // aticqn
    group.bench_function("aticqn", |b| {
        let mut astrom = IauAstrom::default();
        let mut eo = 0.0;
        apci13(tt1, tt2, &mut astrom, &mut eo);
        b.iter(|| {
            aticqn(
                black_box(rc),
                black_box(dc),
                &mut astrom,
                black_box(3),
                black_box(&bodies),
            )
        })
    });

    // atio13
    group.bench_function("atio13", |b| {
        b.iter(|| {
            atio13(
                black_box(rc),
                black_box(dc),
                black_box(utc1),
                black_box(utc2),
                black_box(dut1),
                black_box(elong),
                black_box(phi),
                black_box(hm),
                black_box(xp),
                black_box(yp),
                black_box(phpa),
                black_box(tc),
                black_box(rh),
                black_box(wl),
            )
        })
    });

    // ld
    let p_ld = [-0.76, -0.60, -0.21];
    let q_ld = [-0.76, -0.60, -0.21];
    let e_ld = [0.76, 0.60, 0.21];
    group.bench_function("ld", |b| {
        b.iter(|| {
            ld(
                black_box(0.00028),
                black_box(p_ld),
                black_box(q_ld),
                black_box(e_ld),
                black_box(8.9),
                black_box(3e-10),
            )
        })
    });

    // ldn
    group.bench_function("ldn", |b| {
        b.iter(|| {
            ldn(
                black_box(3),
                black_box(&bodies),
                black_box(&ehp),
                black_box(&p_ld),
            )
        })
    });

    // ldsun
    group.bench_function("ldsun", |b| {
        b.iter(|| ldsun(black_box(p_ld), black_box(ehp), black_box(0.999)))
    });

    // starpv
    group.bench_function("starpv", |b| {
        b.iter(|| {
            starpv(
                black_box(rc),
                black_box(dc),
                black_box(pr),
                black_box(pd),
                black_box(px),
                black_box(rv),
            )
        })
    });

    group.finish();
}

criterion_group!(benches, bench_astro);
criterion_main!(benches);