• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 10124913218

27 Jul 2024 04:27PM UTC coverage: 12.208%. First build
10124913218

Pull #3794

github

gzotti
Reduced to max.4 additional threads
Pull Request #3794: Parallelize ephemeris computation with C++ parallelism.

208 of 369 new or added lines in 24 files covered. (56.37%)

14439 of 118271 relevant lines covered (12.21%)

19314.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.45
/src/core/planetsephems/calc_interpolated_elements.c
1
/************************************************************************
2

3
Copyright (c) 2007 Johannes Gajdosik
4

5
Permission is hereby granted, free of charge, to any person obtaining a
6
copy of this software and associated documentation files (the "Software"),
7
to deal in the Software without restriction, including without limitation
8
the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
and/or sell copies of the Software, and to permit persons to whom the
10
Software is furnished to do so, subject to the following conditions:
11

12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
14

15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
SOFTWARE.
22

23
For documentation see the header file.
24

25
****************************************************************/
26

27
#include <string.h>
28
#include "calc_interpolated_elements.h"
29

30
void CalcInterpolatedElements(const double t,double elem[],
924✔
31
                              const int dim,
32
                              void (*calc_func)(const double t,double elem[],
33
                                                void *user),
34
                              const double delta_t,
35
                              double *t0,double e0[],
36
                              double *t1,double e1[],
37
                              double *t2,double e2[],
38
                              void *user) {
39
/*
40
printf("CalcInterpolatedElements: %12.9f %12.9f %12.9f %12.9f\n",t,*t0,*t1,*t2);
41
*/
42
  int i;
43
  if (*t1 < -1e99) { /* *t1 uninitialized */
924✔
44
    *t0 = -1e100;
8✔
45
    *t2 = -1e100;
8✔
46
    *t1 = t;
8✔
47
    (*calc_func)(*t1,e1,user);
8✔
48
    memcpy(&elem[0], &e1[0], dim*sizeof(double));
8✔
49
    return;
8✔
50
  }
51
  if (t <= *t1) {
916✔
52
    if (*t1 - delta_t <= t) { /* interpolate */
1✔
53
      if (*t0 < -1e99) {
×
54
        *t0 = *t1 - delta_t;
×
55
        (*calc_func)(*t0,e0,user);
×
56
      }
57
    } else if (*t1 - 2.0*delta_t <= t) { /* interpolate */
1✔
58
      if (*t0 < -1e99) {
×
59
        *t0 = *t1 - delta_t;
×
60
        (*calc_func)(*t0,e0,user);
×
61
      }
62
      *t2 = *t1;*t1 = *t0;
×
NEW
63
      memcpy(&e2[0], &e1[0], dim*sizeof(double));
×
NEW
64
      memcpy(&e1[0], &e0[0], dim*sizeof(double));
×
65
      *t0 = *t1 - delta_t;
×
66
      (*calc_func)(*t0,e0,user);
×
67
    } else {
68
      *t0 = -1e100;
1✔
69
      *t2 = -1e100;
1✔
70
      *t1 = t;
1✔
71
      (*calc_func)(*t1,e1,user);
1✔
72
      memcpy(&elem[0], &e1[0], dim*sizeof(double));
1✔
73
      return;
1✔
74
    }
75
    {
76
      const double f0 = (*t1 - t);
×
77
      const double f1 = (t - *t0);
×
78
      const double fact = 1.0 / delta_t;
×
79
      for (i=0;i<dim;i++) elem[i] = fact * (e0[i]*f0 + e1[i]*f1);
×
80
    }
81
  } else {
82
    if (*t1 + delta_t >= t) { /* interpolate */
915✔
83
      if (*t2 < -1e99) {
×
84
        *t2 = *t1 + delta_t;
×
85
        (*calc_func)(*t2,e2,user);
×
86
      }
87
    } else if (*t1 + 2.0*delta_t >= t) { /* interpolate */
915✔
88
      if (*t2 < -1e99) {
×
89
        *t2 = *t1 + delta_t;
×
90
        (*calc_func)(*t2,e2,user);
×
91
      }
92
      *t0 = *t1;*t1 = *t2;
×
NEW
93
      memcpy(&e0[0], &e1[0], dim*sizeof(double));
×
NEW
94
      memcpy(&e1[0], &e2[0], dim*sizeof(double));
×
95
      *t2 = *t1 + delta_t;
×
96
      (*calc_func)(*t2,e2,user);
×
97
    } else {
98
      *t0 = -1e100;
915✔
99
      *t2 = -1e100;
915✔
100
      *t1 = t;
915✔
101
      (*calc_func)(*t1,e1,user);
915✔
102
      memcpy(&elem[0], &e1[0], dim*sizeof(double));
915✔
103
      return;
915✔
104
    }
105
    {
106
      const double f1 = (*t2 - t);
×
107
      const double f2 = (t - *t1);
×
108
      const double fact = 1.0 / delta_t;
×
109
      for (i=0;i<dim;i++) elem[i] = fact * (e1[i]*f1 + e2[i]*f2);
×
110
    }
111
  }
112
}
113

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc