1 /* This software was developed by Bruce Hendrickson and Robert Leland *
2 * at Sandia National Laboratories under US Department of Energy *
3 * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
4
5 #include <stdio.h>
6
7 /* Allocates a double vector with range [nl..nh]. Dies. */
mkvec(nl,nh)8 double *mkvec(nl, nh)
9 int nl, nh;
10 {
11 double *v;
12 double *smalloc();
13
14 v = (double *) smalloc((unsigned) (nh - nl + 1) * sizeof(double));
15 return (v - nl);
16 }
17
18 /* Allocates a double vector with range [nl..nh]. Returns error code. */
mkvec_ret(nl,nh)19 double *mkvec_ret(nl, nh)
20 int nl, nh;
21 {
22 double *v;
23 double *smalloc_ret();
24
25 v = (double *) smalloc_ret((unsigned) (nh - nl + 1) * sizeof(double));
26 if (v == NULL)
27 return(NULL);
28 else
29 return (v - nl);
30 }
31
32 /* Free a double vector with range [nl..nh]. */
frvec(v,nl)33 void frvec(v, nl)
34 double *v;
35 int nl;
36 {
37 int sfree();
38
39 sfree((char *) (v + nl));
40 v = NULL;
41 }
42
43 /* Allocates a float vector with range [nl..nh]. Dies. */
mkvec_float(nl,nh)44 float *mkvec_float(nl, nh)
45 int nl, nh;
46 {
47 float *v;
48 double *smalloc();
49
50 v = (float *) smalloc((unsigned) (nh - nl + 1) * sizeof(float));
51 return (v - nl);
52 }
53
54 /* Allocates a float vector with range [nl..nh]. Returns error code. */
mkvec_ret_float(nl,nh)55 float *mkvec_ret_float(nl, nh)
56 int nl, nh;
57 {
58 float *v;
59 double *smalloc_ret();
60
61 v = (float *) smalloc_ret((unsigned) (nh - nl + 1) * sizeof(float));
62 if (v == NULL)
63 return(NULL);
64 else
65 return (v - nl);
66 }
67
68 /* Free a float vector with range [nl..nh]. */
frvec_float(v,nl)69 void frvec_float(v, nl)
70 float *v;
71 int nl;
72 {
73 int sfree();
74
75 sfree((char *) (v + nl));
76 v = NULL;
77 }
78