1 /*
2 * Name: init.h
3 * Author: Pietro Belotti
4 *
5 * This code is published under the Eclipse Public License (EPL).
6 * See http://www.eclipse.org/legal/epl-v10.html
7 *
8 */
9
10 #ifndef INIT_H
11 #define INIT_H
12
13 #include "sparse.h"
14
15 void init_x (sparseLP *lp, double *x);
16
17 int init_sat (sparseLP *lp, char *sat, double *b_Ax, double *x, double *temp);
18
19
20 /*
21 * Initialize b-Ax [j], sat [j], scalars sum_of_violation return
22 * number of constraints fulfilled
23 *
24 * It is run for each constraint, sat and b_Ax are the current
25 * positions in the respective arrays
26 *
27 * Parallel version: run by all slaves on own chunk; send returned
28 * value to master
29 */
30
31 #ifdef RTR_USE_PRAGMAS
32
33 /*
34 * single block operation
35 */
36
calc_lhs_block(double * z,double * coe,double * x,int * pos,register int n)37 static __inline void calc_lhs_block (double *z, double *coe, double *x, int *pos, register int n) {
38
39 #pragma disjoint (*z, *coe, *x, *pos)
40
41 for (; n >= 0; --n)
42 *z += coe [n] * x [pos [n]];
43 }
44
45 /*
46 * divide in blocks of CONCURRENT_FLOPS size and use pragmas in calc_lhs_block
47 */
48
calc_lhs(double * z,int n,double * coe,double * x,int * pos)49 static __inline void calc_lhs (double *z, int n, double *coe, double *x, int *pos) {
50
51 register int j = n / CONCURRENT_FLOPS;
52
53 for (; j > 0; --j, pos += CONCURRENT_FLOPS,
54 coe += CONCURRENT_FLOPS)
55 calc_lhs_block (z, coe, x, pos, CONCURRENT_FLOPS);
56
57 calc_lhs_block (z, coe, x, pos, n % CONCURRENT_FLOPS);
58 }
59 #endif
60
61 #endif
62