TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcimgio
sif.c
Go to the documentation of this file.
1
5
/*****************************************************************************/
6
int
SIF_TEST
;
7
char
siferrmsg
[128];
8
/*****************************************************************************/
9
#include "
libtpcimgio.h
"
10
/*****************************************************************************/
11
12
/*****************************************************************************/
17
void
sifInit
(
19
SIF
*data
20
) {
21
if
(
SIF_TEST
) printf(
"sifInit()\n"
);
22
if
(data==NULL)
return
;
23
memset(data, 0,
sizeof
(
SIF
));
24
data->
frameNr
=data->
colNr
=0;
25
}
26
/*****************************************************************************/
27
28
/*****************************************************************************/
33
void
sifEmpty
(
35
SIF
*data
36
) {
37
if
(
SIF_TEST
) printf(
"sifEmpty()\n"
);
38
if
(data==NULL)
return
;
39
if
(data->
frameNr
>0) {
40
free((
char
*)(data->
x1
)); free((
char
*)(data->
x2
));
41
free((
char
*)(data->
prompts
)); free((
char
*)(data->
randoms
));
42
free((
char
*)(data->
trues
)); free((
char
*)(data->
weights
));
43
data->
frameNr
=data->
colNr
=0;
44
}
45
data->
scantime
=(time_t)0; data->
version
=0;
46
strcpy(data->
studynr
,
""
); strcpy(data->
isotope_name
,
""
);
47
}
48
/*****************************************************************************/
49
50
/*****************************************************************************/
56
int
sifSetmem
(
58
SIF
*data,
60
int
frameNr
61
) {
62
if
(
SIF_TEST
) printf(
"sifSetmem()\n"
);
63
if
(data==NULL)
return
(1);
64
/* Clear previous data, if necessary */
65
if
(data->
frameNr
>0)
sifEmpty
(data);
66
if
(frameNr<1)
return
(0);
67
68
/* Allocate memory */
69
data->
x1
=(
double
*)calloc(frameNr,
sizeof
(
double
));
70
data->
x2
=(
double
*)calloc(frameNr,
sizeof
(
double
));
71
data->
prompts
=(
double
*)calloc(frameNr,
sizeof
(
double
));
72
data->
randoms
=(
double
*)calloc(frameNr,
sizeof
(
double
));
73
data->
trues
=(
double
*)calloc(frameNr,
sizeof
(
double
));
74
data->
weights
=(
double
*)calloc(frameNr,
sizeof
(
double
));
75
if
(data->
x1
==NULL || data->
x2
==NULL || data->
prompts
==NULL ||
76
data->
randoms
==NULL || data->
trues
==NULL || data->
weights
==NULL) {
77
strcpy(
siferrmsg
,
"out of memory"
);
return
(1);}
78
data->
frameNr
=frameNr;
79
80
return
(0);
81
}
82
/*****************************************************************************/
83
84
/*****************************************************************************/
libtpcimgio.h
Header file for libtpcimgio.
SIF_TEST
int SIF_TEST
Definition
sif.c:6
siferrmsg
char siferrmsg[128]
Definition
sif.c:7
sifInit
void sifInit(SIF *data)
Definition
sif.c:17
sifSetmem
int sifSetmem(SIF *data, int frameNr)
Definition
sif.c:56
sifEmpty
void sifEmpty(SIF *data)
Definition
sif.c:33
SIF
Definition
libtpcimgio.h:1443
SIF::x1
double * x1
Definition
libtpcimgio.h:1457
SIF::prompts
double * prompts
Definition
libtpcimgio.h:1461
SIF::frameNr
int frameNr
Definition
libtpcimgio.h:1447
SIF::x2
double * x2
Definition
libtpcimgio.h:1459
SIF::version
int version
Definition
libtpcimgio.h:1451
SIF::studynr
char studynr[MAX_STUDYNR_LEN+1]
Definition
libtpcimgio.h:1453
SIF::scantime
time_t scantime
Definition
libtpcimgio.h:1445
SIF::isotope_name
char isotope_name[8]
Definition
libtpcimgio.h:1455
SIF::weights
double * weights
Definition
libtpcimgio.h:1467
SIF::colNr
int colNr
Definition
libtpcimgio.h:1449
SIF::randoms
double * randoms
Definition
libtpcimgio.h:1463
SIF::trues
double * trues
Definition
libtpcimgio.h:1465
Generated on
for TPCCLIB by
1.17.0