Annotated Source Code

1/* multifit/work.c
2 * 
3 * Copyright (C) 2000, 2007, 2009 Brian Gough
4 * 
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 * 
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * General Public License for more details.
14 * 
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#include <config.h>
21#include <gsl/gsl_errno.h>
22#include <gsl/gsl_multifit.h>
23
24gsl_multifit_linear_workspace *
25gsl_multifit_linear_alloc (const size_t nmax, const size_t pmax)
6Enter function.    gsl_multifit_linear_alloc(n, p)
26{
27  gsl_multifit_linear_workspace *w;
28
29  w = calloc (1, sizeof (gsl_multifit_linear_workspace));
7Call a function.    calloc(1, sizeof(gsl_multifit_linear_workspace))
47Memory allocated in heap space is not freed.    calloc(1, sizeof(gsl_multifit_linear_workspace))
30
31  if (w == 0)
8Take the false branch.    w == 0
32    {
33      GSL_ERROR_VAL ("failed to allocate space for multifit_linear struct",
34                     GSL_ENOMEM, 0);
35    }
36
37  w->nmax = nmax;                     /* max number of observations */
38  w->pmax = pmax;                     /* max number of parameters */
39  w->n = 0;
40  w->p = 0;
41  w->rcond = 0.0;
42
43  w->A = gsl_matrix_alloc (nmax, pmax);
9Call a function.    gsl_matrix_alloc(nmax, pmax)
44
45  if (w->A == 0)
10Take the false branch.    w->A == 0
46    {
47      gsl_multifit_linear_free(w);
48      GSL_ERROR_VAL ("failed to allocate space for A", GSL_ENOMEM, 0);
49    }
50
51  w->Q = gsl_matrix_alloc (pmax, pmax);
11Call a function.    gsl_matrix_alloc(pmax, pmax)
52
53  if (w->Q == 0)
12Take the false branch.    w->Q == 0
54    {
55      gsl_multifit_linear_free(w);
56      GSL_ERROR_VAL ("failed to allocate space for Q", GSL_ENOMEM, 0);
57    }
58
59  w->QSI = gsl_matrix_alloc (pmax, pmax);
13Call a function.    gsl_matrix_alloc(pmax, pmax)
60
61  if (w->QSI == 0)
14Take the false branch.    w->QSI == 0
62    {
63      gsl_multifit_linear_free(w);
64      GSL_ERROR_VAL ("failed to allocate space for QSI", GSL_ENOMEM, 0);
65    }
66
67  w->S = gsl_vector_alloc (pmax);
15Call a function.    gsl_vector_alloc(pmax)
68
69  if (w->S == 0)
16Take the false branch.    w->S == 0
70    {
71      gsl_multifit_linear_free(w);
72      GSL_ERROR_VAL ("failed to allocate space for S", GSL_ENOMEM, 0);
73    }
74
75  w->t = gsl_vector_alloc (nmax);
17Call a function.    gsl_vector_alloc(nmax)
76
77  if (w->t == 0)
18Take the false branch.    w->t == 0
78    {
79      gsl_multifit_linear_free(w);
80      GSL_ERROR_VAL ("failed to allocate space for t", GSL_ENOMEM, 0);
81    }
82
83  w->xt = gsl_vector_calloc (pmax);
19Call a function.    gsl_vector_calloc(pmax)
84
85  if (w->xt == 0)
20Take the false branch.    w->xt == 0
86    {
87      gsl_multifit_linear_free(w);
88      GSL_ERROR_VAL ("failed to allocate space for xt", GSL_ENOMEM, 0);
89    }
90
91  w->D = gsl_vector_calloc (pmax);
21Call a function.    gsl_vector_calloc(pmax)
92
93  if (w->D == 0)
22Take the false branch.    w->D == 0
94    {
95      gsl_multifit_linear_free(w);
96      GSL_ERROR_VAL ("failed to allocate space for D", GSL_ENOMEM, 0);
97    }
98
99  return w;
100}
23Exit function.    gsl_multifit_linear_alloc(n, p)
101
102void
103gsl_multifit_linear_free (gsl_multifit_linear_workspace * w)
104{
105  RETURN_IF_NULL (w);
106
107  if (w->A)
108    gsl_matrix_free (w->A);
109
110  if (w->Q)
111    gsl_matrix_free (w->Q);
112
113  if (w->QSI)
114    gsl_matrix_free (w->QSI);
115
116  if (w->S)
117    gsl_vector_free (w->S);
118
119  if (w->t)
120    gsl_vector_free (w->t);
121
122  if (w->xt)
123    gsl_vector_free (w->xt);
124
125  if (w->D)
126    gsl_vector_free (w->D);
127
128  free (w);
129}
130
131
Events list
Event 6
Event 7
Event 47
Event 8
Event 9
Event 10
Event 11
Event 12
Event 13
Event 14
Event 15
Event 16
Event 17
Event 18
Event 19
Event 20
Event 21
Event 22
Event 23