This repository has been archived by the owner on Dec 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprivate.c
129 lines (93 loc) · 2.61 KB
/
private.c
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
/*
* Copyright 2017 Battelle Energy Alliance
*/
/*
* private.c - contains miscellaneous private utilities for the Gauss
* Algorithms library.
*/
#include "GaussLib.h"
#include "GLprivate.h"
/*
* GP_info_to_vector global private routine that uses the GPFitVary
* flags to copy information from the GLFitInfo
* structure to 'vector'.
*/
void GP_info_to_vector(GPFitVary *fitvary, GLFitInfo *info, double *vector)
{
int i, j;
/* currently assuming enough storage in vector */
i = 0;
if (fitvary->intercept == GL_TRUE)
vector[i++] = info->intercept;
if (fitvary->slope == GL_TRUE)
vector[i++] = info->slope;
if (fitvary->step_height == GL_TRUE)
vector[i++] = info->step_height;
if (fitvary->avg_width == GL_TRUE)
vector[i++] = info->avg_width;
for (j = 0; j < info->npeaks; j++)
{
if (fitvary->peakvary[j].height == GL_TRUE)
vector[i++] = info->peakinfo[j].height;
if (fitvary->peakvary[j].centroid == GL_TRUE)
vector[i++] = info->peakinfo[j].centroid;
if (fitvary->peakvary[j].addwidth_511 == GL_TRUE)
vector[i++] = info->peakinfo[j].addwidth_511;
}
}
/*
* GP_vector_to_info global private routine that uses the GPFitVary
* flags to copy information from 'vector' to the
* GLFitInfo structure.
*/
void GP_vector_to_info(GPFitVary *fitvary, double *vector, GLFitInfo *info)
{
int i, j;
/* currently assuming enough storage in info */
i = 0;
if (fitvary->intercept == GL_TRUE)
info->intercept = vector[i++];
if (fitvary->slope == GL_TRUE)
info->slope = vector[i++];
if (fitvary->step_height == GL_TRUE)
info->step_height = vector[i++];
if (fitvary->avg_width == GL_TRUE)
info->avg_width = vector[i++];
info->npeaks = fitvary->npeaks;
for (j = 0; j < info->npeaks; j++)
{
if (fitvary->peakvary[j].height == GL_TRUE)
info->peakinfo[j].height = vector[i++];
if (fitvary->peakvary[j].centroid == GL_TRUE)
info->peakinfo[j].centroid = vector[i++];
if (fitvary->peakvary[j].addwidth_511 == GL_TRUE)
info->peakinfo[j].addwidth_511 = vector[i++];
}
}
/*
* GP_info_count global private routine that returns the count
* of true flags in the GPFitVary structure.
*/
int GP_info_count(GPFitVary *fitvary)
{
int i, j;
i = 0;
if (fitvary->intercept == GL_TRUE)
i++;
if (fitvary->slope == GL_TRUE)
i++;
if (fitvary->step_height == GL_TRUE)
i++;
if (fitvary->avg_width == GL_TRUE)
i++;
for (j = 0; j < fitvary->npeaks; j++)
{
if (fitvary->peakvary[j].height == GL_TRUE)
i++;
if (fitvary->peakvary[j].centroid == GL_TRUE)
i++;
if (fitvary->peakvary[j].addwidth_511 == GL_TRUE)
i++;
}
return(i);
}