TaPAS  0.2
vec.h
Go to the documentation of this file.
1 /*
2  * vec.h -- Vectors of rational numbers
3  *
4  * This file is a part of the Talence Linear Algebra Library.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Université Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 
29 #ifndef __VEC_H__
30 # define __VEC_H__
31 
32 # include <ccl/ccl-assert.h>
33 # include <talalib/common.h>
34 
35 BEGIN_C_DECLS
36 
37 typedef struct tla_vec_st {
38  int size;
39  mpz_t *num;
40  mpz_t den;
41 } tla_vec_t[1];
42 
43 /*
44  * Accessor to the _i th component of the vector. _i must belong to the
45  * range [1, n] where n is the size of the vector.
46  */
47 # define TLA_V_NUM(_V, _i) \
48  (ccl_assert (1 <= (_i) && (_i) <= (_V)->size), (_V)->num[(_i) - 1])
49 
50 # define TLA_V_DEN(_V) ((_V)->den)
51 
52 extern void
53 tla_vec_init (tla_vec_t v, int size);
54 extern void
55 tla_vec_resize (tla_vec_t v, int size);
56 extern void
57 tla_vec_init_set (tla_vec_t v, const tla_vec_t other);
58 extern void
59 tla_vec_init_neg (tla_vec_t v, const tla_vec_t other);
60 extern void
61 tla_vec_clear (tla_vec_t v);
62 extern void
63 tla_vec_set_q (tla_vec_t v, mpq_t *vec);
64 extern void
65 tla_vec_set (tla_vec_t v, const tla_vec_t x);
66 extern void
67 tla_vec_get (mpq_t *vec, const tla_vec_t v);
68 extern void
69 tla_vec_get_num (tla_vec_t res, const tla_vec_t v);
70 extern void
71 tla_vec_swap_at (tla_vec_t v, int i, int j);
72 extern void
73 tla_vec_set_unity (tla_vec_t v, int i);
74 extern void
75 tla_vec_set_zero (tla_vec_t v);
76 extern void
77 tla_vec_canonicalize (tla_vec_t v);
78 extern int
79 tla_vec_get_size (const tla_vec_t v);
80 extern int
81 tla_vec_is_zero (const tla_vec_t v);
82 extern int
83 tla_vec_are_equal (const tla_vec_t v1, const tla_vec_t v2);
84 extern void
85 tla_vec_scalar_product (mpq_t res, const tla_vec_t v1, const tla_vec_t v2);
86 extern void
87 tla_vec_mul_2exp (tla_vec_t res, const int exp2, const tla_vec_t v);
88 extern void
89 tla_vec_q_mul (tla_vec_t res, mpq_t scale, const tla_vec_t v);
90 extern void
91 tla_vec_z_mul (tla_vec_t res, const mpz_t scale, const tla_vec_t v);
92 extern void
93 tla_vec_z_mul_si (tla_vec_t res, int scale, const tla_vec_t v);
94 extern void
95 tla_vec_qz_mul (tla_vec_t res, const tla_vec_t v, const mpz_t num,
96  const mpz_t den);
97 extern void
98 tla_vec_q_div (tla_vec_t res, const tla_vec_t v, mpq_t d);
99 extern void
100 tla_vec_z_div (tla_vec_t res, const tla_vec_t v, const mpz_t d);
101 extern void
102 tla_vec_z_div_si (tla_vec_t res, const tla_vec_t v, int d);
103 extern void
104 tla_vec_qz_div (tla_vec_t res, const tla_vec_t v, const mpz_t num,
105  const mpz_t den);
106 extern void
107 tla_vec_add (tla_vec_t res, const tla_vec_t v1, const tla_vec_t v2);
108 extern void
109 tla_vec_add_z_mul (tla_vec_t res, const tla_vec_t x, const mpz_t a,
110  const tla_vec_t y);
111 extern void
112 tla_vec_sub_z_mul (tla_vec_t res, const tla_vec_t x, const mpz_t a,
113  const tla_vec_t y);
114 extern void
115 tla_vec_add_si_mul (tla_vec_t res, const tla_vec_t x, int a, const tla_vec_t y);
116 extern void
117 tla_vec_sub (tla_vec_t res, const tla_vec_t v1, const tla_vec_t v2);
118 extern void
119 tla_vec_gamma (tla_vec_t res, const tla_vec_t v, int b);
120 extern void
121 tla_vec_inv_gamma (tla_vec_t res, const tla_vec_t v, int b);
122 extern void
123 tla_vec_sub_ith_den (tla_vec_t res, const tla_vec_t v, int i);
124 extern void
125 tla_vec_div_2 (tla_vec_t res, const tla_vec_t v);
126 extern void
127 tla_vec_sub_last_den_div_2 (tla_vec_t res, const tla_vec_t v);
128 extern void
129 tla_vec_ith_div (tla_vec_t res, int i);
130 extern void
131 tla_vec_sub_ith_mul (tla_vec_t res, tla_vec_t x, int i, tla_vec_t y);
132 extern void
133 tla_vec_assign_sub_ith_mul (tla_vec_t res, int i0, tla_vec_t y);
134 extern unsigned int
135 tla_vec_hash (const tla_vec_t v);
136 
137 END_C_DECLS
138 
139 #endif /* ! __VEC_H__ */
Macros allowing to set assertions into the code.