tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / interface / layouter / LayoutOptimizer.h
blob5919b87867d5e04beca6035bd4275f515dc9f571
1 /*
2 * Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #ifndef LAYOUT_OPTIMIZER_H
6 #define LAYOUT_OPTIMIZER_H
8 #include <List.h>
9 #include <math.h>
11 static const double kEqualsEpsilon = 0.000001;
14 namespace BPrivate {
15 namespace Layout {
17 class LayoutOptimizer {
18 public:
19 LayoutOptimizer(int32 variableCount);
20 ~LayoutOptimizer();
22 status_t InitCheck() const;
24 LayoutOptimizer* Clone() const;
26 bool AddConstraint(int32 left, int32 right,
27 double value, bool equality);
28 bool AddConstraintsFrom(
29 const LayoutOptimizer* solver);
30 void RemoveAllConstraints();
32 bool Solve(const double* desired, double size,
33 double* values);
35 private:
36 bool _Solve(const double* desired, double* values);
37 bool _SolveSubProblem(const double* d, int am,
38 double* p);
39 void _SetResult(const double* x, double* values);
42 struct Constraint;
44 int32 fVariableCount;
45 BList fConstraints;
46 double* fVariables;
47 double** fTemp1;
48 double** fTemp2;
49 double** fZtrans;
50 double** fQ;
51 double** fActiveMatrix;
52 double** fActiveMatrixTemp;
55 } // namespace Layout
56 } // namespace BPrivate
58 using BPrivate::Layout::LayoutOptimizer;
61 inline bool
62 fuzzy_equals(double a, double b)
64 return fabs(a - b) < kEqualsEpsilon;
68 #endif // LAYOUT_OPTIMIZER_H