/**
  * Estimates the approximate index for a given number
  * It uses the approximate formula:
  * F(n) ~ (PHI^n)/sqrt(5), where '~' means the 'closest integer to'
  * This equation is based on the relation: phi = -1/PHI
  * Which turns Lucas' formula into:
  * F(n) = (PHI^2n + 1)/(PHI^n * sqrt(5))
  * From which we get the formula above, after making the approximation:
  * (PHI^2n + 1) -> (PHI^2n)
  *
  * @param integer $num
  * @return integer the approximate index
  * @access private
  */
 function &_estimateN(&$num)
 {
     /*{{{*/
     if (Math_IntegerOp::isMath_Integer($num)) {
         $f = $num->toString();
     } else {
         $f = $num;
     }
     return Math_Fibonacci::_closestInt((log($f) + MATH_LNSQRT5) / MATH_LNPHI);
 }
 /**
  * Checks that the passed object is a valid Math_Integer number.
  * The object must be an instance of Math_Integer and have been properly
  * initialized.
  *
  * @param object Math_Integer $int1
  * @return mixed TRUE if is a Math_Integer object, PEAR_Error otherwise
  * @access private
  */
 function _validInt(&$int1)
 {
     /*{{{*/
     $error = '';
     if (!Math_IntegerOp::isMath_Integer($int1)) {
         $error = 'Is not a Math_Integer object.';
     } elseif (!$int1->initialized()) {
         $error = 'Math_Integer object is uninitalized.';
     }
     if (!empty($error)) {
         return PEAR::raiseError($error);
     } else {
         return true;
     }
 }