TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpctac
tacy.c
Go to the documentation of this file.
1
4
/*****************************************************************************/
5
#include "tpcclibConfig.h"
6
/*****************************************************************************/
7
#include "
tpcift.h
"
8
/*****************************************************************************/
9
#include <stdio.h>
10
#include <stdlib.h>
11
#include <math.h>
12
#include <time.h>
13
#include <string.h>
14
/*****************************************************************************/
15
#include "
tpctac.h
"
16
/*****************************************************************************/
17
18
/*****************************************************************************/
26
int
tacYRange
(
28
TAC
*d,
30
int
i,
32
double
*ymin,
34
double
*ymax,
36
int
*smin,
38
int
*smax,
40
int
*imin,
42
int
*imax
43
) {
44
if
(ymin!=NULL) *ymin=nan(
""
);
45
if
(ymax!=NULL) *ymax=nan(
""
);
46
if
(smin!=NULL) *smin=-1;
47
if
(smax!=NULL) *smax=-1;
48
if
(imin!=NULL) *imin=-1;
49
if
(imax!=NULL) *imax=-1;
50
/* Check the data */
51
if
(d==NULL || d->
sampleNr
<1)
return
(1);
52
/* Check the index */
53
if
(i>=d->
tacNr
)
return
(2);
54
55
/* Find the min and max time */
56
double
*xi, *xa;
57
if
(d->
isframe
) {xi=d->
x1
; xa=d->
x2
;}
else
xi=xa=d->
x
;
58
double
mi, ma;
59
mi=ma=nan(
""
);
60
for
(
int
j=0; j<d->
sampleNr
; j++) {
61
if
(isnan(xi[j]) || isnan(xa[j]))
continue
;
62
for
(
int
k=0; k<d->
tacNr
; k++) {
63
if
(i>=0 && i!=k)
continue
;
64
if
(isnan(mi) || isnan(ma)) {
65
mi=d->
c
[k].
y
[j]; ma=d->
c
[k].
y
[j];
66
if
(smin!=NULL) *smin=j;
67
if
(smax!=NULL) *smax=j;
68
if
(imin!=NULL) *imin=k;
69
if
(imax!=NULL) *imax=k;
70
continue
;
71
}
72
if
(d->
c
[k].
y
[j]<mi) {
73
mi=d->
c
[k].
y
[j];
74
if
(smin!=NULL) *smin=j;
75
if
(imin!=NULL) *imin=k;
76
}
else
if
(d->
c
[k].
y
[j]>ma) {
77
ma=d->
c
[k].
y
[j];
78
if
(smax!=NULL) *smax=j;
79
if
(imax!=NULL) *imax=k;
80
}
81
}
82
}
83
if
(ymin!=NULL) *ymin=mi;
84
if
(ymax!=NULL) *ymax=ma;
85
if
(isnan(mi) || isnan(ma))
return
(2);
86
return
(0);
87
}
88
/*****************************************************************************/
89
90
/*****************************************************************************/
99
int
tacYRangeInXRange
(
101
TAC
*d,
103
int
i,
105
const
double
xmin,
107
const
double
xmax,
109
double
*ymin,
111
double
*ymax,
113
int
*smin,
115
int
*smax,
117
int
*imin,
119
int
*imax
120
) {
121
if
(ymin!=NULL) *ymin=nan(
""
);
122
if
(ymax!=NULL) *ymax=nan(
""
);
123
if
(smin!=NULL) *smin=-1;
124
if
(smax!=NULL) *smax=-1;
125
if
(imin!=NULL) *imin=-1;
126
if
(imax!=NULL) *imax=-1;
127
/* Check the data */
128
if
(d==NULL || d->
sampleNr
<1)
return
(1);
129
/* Check the index */
130
if
(i>=d->
tacNr
)
return
(2);
131
/* Check x range */
132
if
(xmin>xmax)
return
(3);
133
134
/* Find the min and max time */
135
double
*xi, *xa, x;
136
if
(d->
isframe
) {xi=d->
x1
; xa=d->
x2
;}
else
xi=xa=d->
x
;
137
double
mi, ma;
138
mi=ma=nan(
""
);
139
for
(
int
j=0; j<d->
sampleNr
; j++) {
140
if
(isnan(xi[j]) || isnan(xa[j]))
continue
;
141
x=0.5*(xi[j]+xa[j]);
if
(x<xmin || x>xmax)
continue
;
142
for
(
int
k=0; k<d->
tacNr
; k++) {
143
if
(i>=0 && i!=k)
continue
;
144
if
(isnan(mi) || isnan(ma)) {
145
mi=d->
c
[k].
y
[j]; ma=d->
c
[k].
y
[j];
146
if
(smin!=NULL) *smin=j;
147
if
(smax!=NULL) *smax=j;
148
if
(imin!=NULL) *imin=k;
149
if
(imax!=NULL) *imax=k;
150
continue
;
151
}
152
if
(d->
c
[k].
y
[j]<mi) {
153
mi=d->
c
[k].
y
[j];
154
if
(smin!=NULL) *smin=j;
155
if
(imin!=NULL) *imin=k;
156
}
else
if
(d->
c
[k].
y
[j]>ma) {
157
ma=d->
c
[k].
y
[j];
158
if
(smax!=NULL) *smax=j;
159
if
(imax!=NULL) *imax=k;
160
}
161
}
162
}
163
if
(ymin!=NULL) *ymin=mi;
164
if
(ymax!=NULL) *ymax=ma;
165
if
(isnan(mi) || isnan(ma))
return
(2);
166
return
(0);
167
}
168
/*****************************************************************************/
169
170
/*****************************************************************************/
TACC::y
double * y
Definition
tpctac.h:75
TAC
Definition
tpctac.h:87
TAC::x
double * x
Definition
tpctac.h:97
TAC::sampleNr
int sampleNr
Definition
tpctac.h:89
TAC::isframe
int isframe
Definition
tpctac.h:95
TAC::c
TACC * c
Definition
tpctac.h:117
TAC::x2
double * x2
Definition
tpctac.h:101
TAC::x1
double * x1
Definition
tpctac.h:99
TAC::tacNr
int tacNr
Definition
tpctac.h:91
tacYRangeInXRange
int tacYRangeInXRange(TAC *d, int i, const double xmin, const double xmax, double *ymin, double *ymax, int *smin, int *smax, int *imin, int *imax)
Get the range of y values (concentrations) in TAC struct, including only samples with x (times) insid...
Definition
tacy.c:99
tacYRange
int tacYRange(TAC *d, int i, double *ymin, double *ymax, int *smin, int *smax, int *imin, int *imax)
Get the range of y values (concentrations) in TAC struct.
Definition
tacy.c:26
tpcift.h
Header file for library libtpcift.
tpctac.h
Header file for library libtpctac.
Generated on
for TPCCLIB by
1.17.0