-
Notifications
You must be signed in to change notification settings - Fork 4
/
vectors.c
84 lines (67 loc) · 1.38 KB
/
vectors.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "vectors.h"
float *gen_fvect(long length)
{
float *v;
v = (float *) malloc((size_t) (sizeof(float) * length));
if (!v) {
perror("\nError in gen_fvect()");
printf("\n");
exit(-1);
}
return v;
}
double *gen_dvect(long length)
{
double *v;
v = (double *) malloc((size_t) (sizeof(double) * length));
if (!v) {
perror("\nError in gen_dvect()");
printf("\n");
exit(-1);
}
return v;
}
short *gen_svect(long length)
{
short *v;
v = (short *) malloc((size_t) (sizeof(short) * length));
if (!v) {
perror("\nError in gen_svect()");
printf("\n");
exit(-1);
}
return v;
}
int *gen_ivect(long length)
{
int *v;
v = (int *) malloc((size_t) (sizeof(int) * length));
if (!v) {
perror("\nError in gen_ivect()");
printf("\n");
exit(-1);
}
return v;
}
long *gen_lvect(long length)
{
long *v;
v = (long *) malloc((size_t) (sizeof(long) * length));
if (!v) {
perror("\nError in gen_lvect()");
printf("\n");
exit(-1);
}
return v;
}
unsigned char *gen_bvect(long length)
{
unsigned char *v;
v = (unsigned char *) malloc((size_t) (sizeof(unsigned char) * length));
if (!v) {
perror("\nError in gen_bvect()");
printf("\n");
exit(-1);
}
return v;
}