1 /*****************************************************************************
2    Major portions of this software are copyrighted by the Medical College
3    of Wisconsin, 1994-2000, and are released under the Gnu General Public
4    License, Version 2.  See the file README.Copyright for details.
5 ******************************************************************************/
6 
7 /*
8   This file contains routines to initialize and implement the
9   differential exponential drug response signal model.
10 
11   File:     model_exp.c
12   Author:   Z. Saad, based on model_diffexp.c by B. Douglas Ward
13 */
14 
15 
16 /*---------------------------------------------------------------------------*/
17 
18 #include <math.h>
19 #include "NLfit_model.h"
20 
21 void signal_model
22 (
23   float * gs,                /* parameters for signal model */
24   int ts_length,             /* length of time series data */
25   float ** x_array,          /* independent variable matrix */
26   float * ts_array           /* estimated signal model time series */
27 );
28 
29 
30 /*---------------------------------------------------------------------------*/
31 /*
32   Routine to initialize the signal model by defining the number of parameters
33   in the signal model, the name of the signal model, and the default values
34   for the minimum and maximum parameter constraints.
35 */
36 
37 DEFINE_MODEL_PROTOTYPE
38 
initialize_model()39 MODEL_interface * initialize_model ()
40 {
41   MODEL_interface * mi = NULL;
42 
43 
44   /*----- allocate memory space for model interface -----*/
45   mi = (MODEL_interface *) RwcMalloc (sizeof(MODEL_interface));
46 
47 
48   /*----- define interface for the differential - exponential model -----*/
49 
50   /*----- name of this model -----*/
51   strcpy (mi->label, "Exp");
52 
53   /*----- this is a signal model -----*/
54   mi->model_type = MODEL_SIGNAL_TYPE;
55 
56   /*----- number of parameters in the model -----*/
57   mi->params = 2;
58 
59   /*----- parameter labels -----*/
60   strcpy (mi->plabel[0], "a");
61   strcpy (mi->plabel[1], "b");
62 
63   /*----- minimum and maximum parameter constraints -----*/
64   mi->min_constr[0] =  -500.0;    mi->max_constr[0] =   500.0;
65   mi->min_constr[1] =   1.00;   mi->max_constr[1] =     1.00;
66 
67   /*----- function which implements the model -----*/
68   mi->call_func = &signal_model;
69 
70 
71   /*----- return pointer to the model interface -----*/
72   return (mi);
73 }
74 
75 
76 /*---------------------------------------------------------------------------*/
77 /*
78   Routine to calculate the time series which results from using the
79   an exponential signal model with the specified
80   model parameters.
81 
82   Definition of model parameters:
83 
84      gs[0] = multiplicative constant (k)
85      gs[1] = elimination rate constant (alpha1)
86 */
87 
signal_model(float * gs,int ts_length,float ** x_array,float * ts_array)88 void signal_model
89 (
90   float * gs,                /* parameters for signal model */
91   int ts_length,             /* length of time series data */
92   float ** x_array,          /* independent variable matrix */
93   float * ts_array           /* estimated signal model time series */
94 )
95 
96 {
97   int it;                           /* time index */
98   float t;                          /* time */
99   float fval;                       /* time series value at time t */
100 
101 
102   for (it = 0;  it < ts_length;  it++)
103     {
104       t = x_array[it][1];
105 	fval = gs[0] * (exp(gs[1]*(t)));
106       ts_array[it] = fval;
107     }
108 
109 }
110 
111 
112 
113 
114