1 /* integration/workspace.c
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
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.
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.
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.
22 #include <gsl/gsl_integration.h>
23 #include <gsl/gsl_errno.h>
25 gsl_integration_workspace *
26 gsl_integration_workspace_alloc (const size_t n)
28 gsl_integration_workspace * w ;
32 GSL_ERROR_VAL ("workspace length n must be positive integer",
36 w = (gsl_integration_workspace *)
37 malloc (sizeof (gsl_integration_workspace));
41 GSL_ERROR_VAL ("failed to allocate space for workspace struct",
45 w->alist = (double *) malloc (n * sizeof (double));
49 free (w); /* exception in constructor, avoid memory leak */
51 GSL_ERROR_VAL ("failed to allocate space for alist ranges",
55 w->blist = (double *) malloc (n * sizeof (double));
60 free (w); /* exception in constructor, avoid memory leak */
62 GSL_ERROR_VAL ("failed to allocate space for blist ranges",
66 w->rlist = (double *) malloc (n * sizeof (double));
72 free (w); /* exception in constructor, avoid memory leak */
74 GSL_ERROR_VAL ("failed to allocate space for rlist ranges",
79 w->elist = (double *) malloc (n * sizeof (double));
86 free (w); /* exception in constructor, avoid memory leak */
88 GSL_ERROR_VAL ("failed to allocate space for elist ranges",
92 w->order = (size_t *) malloc (n * sizeof (size_t));
100 free (w); /* exception in constructor, avoid memory leak */
102 GSL_ERROR_VAL ("failed to allocate space for order ranges",
106 w->level = (size_t *) malloc (n * sizeof (size_t));
115 free (w); /* exception in constructor, avoid memory leak */
117 GSL_ERROR_VAL ("failed to allocate space for order ranges",
123 w->maximum_level = 0 ;
129 gsl_integration_workspace_free (gsl_integration_workspace * w)
142 gsl_integration_workspace_limit (gsl_integration_workspace * w)
149 gsl_integration_workspace_size (gsl_integration_workspace * w)