Ejemplo n.º 1
0
void Scrollbar::setLength(float length) {
	GfxMan.lockFrame();

	// Need at least the space for the 2 caps
	_length = MAX(length, 4.0f);

	if      (_type == kTypeVertical)
		createV();
	else if (_type == kTypeHorizontal)
		createH();

	GfxMan.unlockFrame();
}
Ejemplo n.º 2
0
int main(){
	HashTable * t = createH(10);
	Node * n = createNode(2);
	putHash(t,n);
	getHash(t,2);
}
Ejemplo n.º 3
0
bool PSLQ::solve(UINT maxDigits) {
  const BigReal       maxNorm = rSqrt(sqr(e(1,maxDigits+1)-1)*m_x.getDimension(),10);
  const BigRealMatrix H       = createH();
  m_A                         = createHermiteReducingMatrix(H);
  BigRealMatrix       AHQ     = m_A * H; // N x (N-1)-matrix

  tcout << _T("Digits in calculation           :") << iparam(3) << m_digits  << endl
        << _T("Max number of digits in solution:") << iparam(3) << maxDigits << endl
        << _T("Max bound                       :") << dparam(5) << maxNorm   << endl;

  for(;;) {
    m_minBound = rQuot(BIGREAL_1, getMaxDiagElement(AHQ), 10);
    if(m_minBound > maxNorm) {
      return false; // we are out of digits
    }

    const int r = findPivotRow(AHQ); // Step 1: Exchange. r = [0..N-2]

    if(m_verbose&VERBOSE_PIVOT) {
      tcout << _T("Pivotrow:") << r << endl;
    }

    m_A.swapRows(r, r+1);
    AHQ.swapRows(r, r+1);

    if(r != m_n - 2) {   // Step 2: Corner
#ifdef TEST_ROTATION
      BigRealMatrix AHQTest = AHQ;
      AHQTest *= RotationMatrix1(AHQTest, r);
#endif // TEST_ROTATION
      AHQ *= RotationMatrix(AHQ, r);
    }

    // Step 3: Reduction
#ifdef TEST_REDUCEEXACT
    if(m_verbose&VERBOSE_MATRIX) {
      const BigRealMatrix D0    = createHermiteReducingMatrix0(AHQ);
      const BigRealMatrix D0AHQ = D0 * AHQ;
      tcout << _T("Hermite reducing Matrix D0:") << endl << dparam(8) << D0;
      tcout << _T("D0*AHQ:")                     << endl << dparam(8) << D0AHQ;
    }
#endif

    const BigRealMatrix D = createHermiteReducingMatrix(AHQ);
    if(m_verbose&VERBOSE_MATRIX) {
      tcout << _T("Hermite reducing Matrix D:") << endl << iparam(6) << D;
    }

    m_A = D * m_A;
    AHQ = D * AHQ;

    if(m_verbose&VERBOSE_MATRIX) {
      tcout << _T("AHQ:") << endl << dparam(8)  << AHQ;
      tcout << _T("A:"  ) << endl << iparam(16) << m_A;
    }

    // Step 4: check Termination
    try {
      const BigRealMatrix Ainv = round(inverse(m_A));
      const BigRealVector y    = m_x * Ainv;
      const int           z    = getZeroComponent(y);
      if(z >= 0) {
        if(m_verbose&VERBOSE_INVA) {
          tcout << _T("inv(A):") << endl << iparam(12) << Ainv;
        }
        if(m_verbose&VERBOSE_DATA) {
          tcout << _T("column:") << z << endl;
        }
        m_solution = Ainv.getColumn(z);
        return true;
      }
    } catch(Exception e) {
      return false; // Occurs when m_A is singular (Exception comes from inverse(m_A))
    }
  }
}
Ejemplo n.º 4
0
// Free hist and reinitialize
void hClear (void) {
    destroyH(hist);
    hist = createH();
    histsize = 0;
}