summaryrefslogtreecommitdiff
path: root/omegalib/omega_lib/include/omega/pres_cmpr.h
blob: fb3e6f02948d83c2182ac81bd96feeb9d77d31fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#if ! defined _pres_cmpr_h
#define _pres_cmpr_h 1

#include <omega/omega_core/oc.h>

namespace omega {

//
// Compressed problem: rectangular non-0 cut from the big problem.
//
class Comp_Constraints {
public:
  Comp_Constraints(eqn *constrs, int no_constrs, int no_vars);
  void UncompressConstr(eqn *constrs, short &pn_constrs);
  ~Comp_Constraints();
  bool no_constraints() const
  { return n_constrs == 0; }
  int n_constraints() const
  { return n_constrs; }

protected:
  inline int coef_index(int e, int v)
  {return e*(n_vars+1) + v;}

private:
  int n_constrs;
  int n_vars;
  coef_t *coefs;
};

class Comp_Problem {
public:
  Comp_Problem(Problem *problem);
  Problem *UncompressProblem();
  bool no_constraints() const
  { return eqs.no_constraints() && geqs.no_constraints(); }

private:
/* === data === */
  int             _nVars, _safeVars;
  const char   *(*_get_var_name)(unsigned int var, void *args);
  void           *_getVarNameArgs;
  Comp_Constraints eqs;
  Comp_Constraints geqs;
};

} // namespace

#endif