## Revision 766

1
//\$Id: simple_thread.cpp 3054 2013-01-10 22:54:36Z jsibert \$
2
#include "pt_trace.h"
3
4
5
#include "msimple.htp"
6
7
extern void * mp_ptr;
8
9
static int nentries = 0;
10

11
12
{
13
nentries ++;
14
15
16
17
model_parameters * mp = (model_parameters*)mp_ptr;
18
TTTRACE(nentries,sno, ((void*)mp))
19

20
21
22
23
24

25
//PROCEDURE_SECTION
26
//pred_Y=a*x+b;
27
//f=(norm2(pred_Y-Y));
28
//f=nobs/2.*log(f);    // make it a likelihood function so that
29
// covariance matrix is correct
30
TTTRACE(sno,mp->a, mp->b)
31
TTTRACE(sno,mp->x(sno).indexmin(),mp->x(sno).indexmax());
32
TTRACE(sno,mp->x(sno))
33

34
dvar_vector pred_Y(mp->x(sno).indexmin(),mp->x(sno).indexmax());
35
TTTRACE(sno,pred_Y.indexmin(),pred_Y.indexmax())
36
pred_Y = mp->a * mp->x(sno) + mp-> b;
37
TTTRACE(sno,pred_Y.indexmin(),pred_Y.indexmax());
38
TTRACE(sno,pred_Y);
39

40
dvariable f=norm2(pred_Y-mp->Y(sno));
41
f=mp->nobs/2.*log(f);    // make it a likelihood function so that
42
// covariance matrix is correct
43
TTRACE(sno,f)
44

45
46
47
return;
48
}
49

1
//\$Id: msimple.tpl 3054M 2013-01-11 20:23:43Z (local) \$
2

3
GLOBALS_SECTION
4
5
6
#include "pt_trace.h"
7
8
ofstream clogf;
9
int NSLAVES=0;
10

11

12
void * mp_ptr = NULL;
13
14
15
16

17

18

19
DATA_SECTION
20
init_int nobs
21
init_int nslaves
22

23
matrix Y(1,nslaves,1,nobs)
24
matrix x(1,nslaves,1,nobs)
25

26
LOCAL_CALCS
27
double A = 2.0;
28
double B = 4.0;
29
random_number_generator rng(101);
30
dvector err(1,nobs);
31
for (int i = 1; i <= nslaves; i++)
32
{
33
x(i).fill_randu(rng);
34
x(i) *= 100.0;
35
Y(i) = A*x(i) + B;
36
err.fill_randn(rng);
37
Y(i) += 5.0*err;
38
}
39
NSLAVES = nslaves;
40
/*
41
if (1)
42
{
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff