Project

General

Profile

Statistics
| Branch: | Revision:

cool / src / lib / GMLMIP-0.1 / rules / sizefunctions.c @ 7c4d2eb4

History | View | Annotate | Download (618 Bytes)

1 e034e268 Thorsten WiƟmann
#include "sizefunctions.h"
2
3
/* Functions for calculating size of a linear program */
4
int sizeofcoef(int a){
5
        int result = 1;
6
        while (a >>= 1) 
7
                ++result;
8
        return result;
9
}
10
11
int sizeofcoef(Rational a){
12
        return 1 + sizeofcoef(a.get_top()) + sizeofcoef(a.get_bot());
13
}
14
15
template <class T>
16
int sizeoflp(const int n, const int m, T* a, T* b){
17
        int sum = 1 + n + m;
18
        for(int i=0; i < n; i++)
19
                sum+=sizeofcoef(a[i]);
20
        for(int j=0; j < m; j++)
21
                sum+=sizeofcoef(b[j]);
22
        return sum;
23
}
24
25
template int sizeoflp<int>(const int, const int, int*, int*);
26
template int sizeoflp<Rational>(const int, const int, Rational*, Rational*);