0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 /*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 * Header for Vector.c
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 *
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 * $Id: Vector.h,v 1.1 2011/06/14 10:40:52 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 #ifndef VECTOR_H
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 #define VECTOR_H
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 #ifndef ALLOCATE_ARRAY
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 #define ALLOCATE_ARRAY(type, n) ((type *)calloc(n, sizeof(type)))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 #endif
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 #ifndef ALLOCATE
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 #define ALLOCATE(type) ((type *)calloc(1, sizeof(type)))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 #endif
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 #define NONE -1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 #define WARNING 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 #define INFO 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 #define DEBUG 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 #define VERBOSE_LEVEL INFO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 #include <stdarg.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 #include <stdio.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 #include <stdlib.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 #include <string.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 typedef struct Vector
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 /* size of vector */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 long int size;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 /* data array containing vector elements */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 double *data;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 } Vector;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 /* from Vector.c */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 void printMsg(int level, char *format, ...);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 char *toString(Vector *t);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 Vector *initVector(double *data, long int size);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 Vector *copyVector(Vector *in);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 void freeVector(Vector *v);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 /* vector operations */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 Vector *vec_plus_s(Vector *v, double s);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 Vector *s_plus_vec(double s, Vector *v);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 Vector *vec_plus_vec(int num, Vector *v, ...);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 Vector *plus_internal(Vector *v, double s);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 Vector *plus_internal_v(Vector *v1, Vector *v2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 Vector *vec_minus_s(Vector *v, double s);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 Vector *s_minus_vec(double s, Vector *v);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 Vector *vec_times_s(Vector *v, double s);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 Vector *s_times_vec(double s, Vector *v);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 Vector *vec_times_vec(int num, Vector *v, ...);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 Vector *times_internal(Vector *v, double s);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 Vector *times_internal_v(Vector *v1, Vector *v2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 Vector *vec_div_s(Vector *v, double s);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 Vector *sin_of_vec(Vector *v);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 Vector *cos_of_vec(Vector *v);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 #endif /* VECTOR_H */
|