comparison src/c_sources/Vector.h @ 0:f0afece42f48

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