home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / idlib / math / Lcp.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  2KB  |  51 lines

  1.  
  2. #ifndef __MATH_LCP_H__
  3. #define __MATH_LCP_H__
  4.  
  5. /*
  6. ===============================================================================
  7.  
  8.   Box Constrained Mixed Linear Complementarity Problem solver
  9.  
  10.   A is a matrix of dimension n*n and x, b, lo, hi are vectors of dimension n
  11.  
  12.   Solve: Ax = b + t, where t is a vector of dimension n, with
  13.   complementarity condition: (x[i] - lo[i]) * (x[i] - hi[i]) * t[i] = 0
  14.   such that for each 0 <= i < n one of the following holds:
  15.  
  16.     1. lo[i] < x[i] < hi[i], t[i] == 0
  17.     2. x[i] == lo[i], t[i] >= 0
  18.     3. x[i] == hi[i], t[i] <= 0
  19.  
  20.   Partly bounded or unbounded variables can have lo[i] and/or hi[i]
  21.   set to negative/positive idMath::INFITITY respectively.
  22.  
  23.   If boxIndex != NULL and boxIndex[i] != -1 then
  24.  
  25.     lo[i] = - fabs( lo[i] * x[boxIndex[i]] )
  26.     hi[i] = fabs( hi[i] * x[boxIndex[i]] )
  27.     boxIndex[boxIndex[i]] must be -1
  28.   
  29.   Before calculating any of the bounded x[i] with boxIndex[i] != -1 the
  30.   solver calculates all unbounded x[i] and all x[i] with boxIndex[i] == -1.
  31.  
  32. ===============================================================================
  33. */
  34.  
  35. class idLCP {
  36. public:
  37.     static idLCP *    AllocSquare( void );        // A must be a square matrix
  38.     static idLCP *    AllocSymmetric( void );        // A must be a symmetric matrix
  39.  
  40.     virtual            ~idLCP( void );
  41.  
  42.     virtual bool    Solve( const idMatX &A, idVecX &x, const idVecX &b, const idVecX &lo, const idVecX &hi, const int *boxIndex = NULL ) = 0;
  43.     virtual void    SetMaxIterations( int max );
  44.     virtual int        GetMaxIterations( void );
  45.  
  46. protected:
  47.     int                maxIterations;
  48. };
  49.  
  50. #endif /* !__MATH_LCP_H__ */
  51.