Пример #1
0
static void
mps_context_expand (mps_context * s, int n)
{
  int i;
  long int previous_prec = mpc_get_prec (s->mfpc1[0]);

  s->root = mps_realloc (s->root, sizeof(mps_approximation*) * n);
  for (i = s->n - s->zero_roots; i < n; i++)
    {
      s->root[i] = mps_approximation_new (s);
    }

  s->order = mps_realloc (s->order, sizeof(int) * n);

  s->fppc1 = mps_realloc (s->fppc1, sizeof(cplx_t) * (n + 1));
  s->mfpc1 = mps_realloc (s->mfpc1, sizeof(mpc_t) * (n + 1));

  for (i = s->n + 1 - s->zero_roots; i < n + 1; i++)
    mpc_init2 (s->mfpc1[i], previous_prec);

  s->mfppc1 = mps_realloc (s->mfppc1, sizeof(mpc_t) * (n + 1));
  for (i = s->n + 1- s->zero_roots; i <= n; i++)
    mpc_init2 (s->mfppc1[i], previous_prec);

  /* temporary vectors */
  s->spar1 = mps_realloc (s->spar1, sizeof(mps_boolean) * (n + 2));
  s->again_old = mps_realloc (s->again_old, sizeof(mps_boolean) * (n));

  s->fap1 = mps_realloc (s->fap1, sizeof(double) * (n + 1));
  s->fap2 = mps_realloc (s->fap2, sizeof(double) * (n + 1));

  s->dap1 = mps_realloc (s->dap1, sizeof(rdpe_t) * (n + 1));
  s->dpc1 = mps_realloc (s->dpc1, sizeof(cdpe_t) * (n + 1));
  s->dpc2 = mps_realloc (s->dpc2, sizeof(cdpe_t) * (n + 1));

  /* Setting some default here, that were not settable because we didn't know
   * the degree of the polynomial */
  for (i = 0; i < n; i++)
    s->root[i]->wp = DBL_DIG * LOG2_10;
}
Пример #2
0
/**
 * @brief Allocate all the data needed by MPSolve. Must be called after setting
 * the degree of the polynomial (or, more generally, the number of root of the
 * equation) in <code>s->deg</code>.
 *
 * @param s The <code>mps_context</code> of the computation.
 */
void
mps_allocate_data (mps_context * s)
{
  MPS_DEBUG_THIS_CALL;
  int i;

  s->root = mps_newv (mps_approximation*, s->n);
  for (i = 0; i < s->n; i++)
    s->root[i] = mps_approximation_new (s);

  /* Reset the cluster structure, so we can start without assumption
   * on the location of the roots. */
  mps_cluster_reset (s);

  s->order = int_valloc (s->deg);

  s->fppc1 = cplx_valloc (s->deg + 1);

  s->mfpc1 = mpc_valloc (s->deg + 1);
  for (i = 0; i <= s->deg; i++)
    mpc_init2 (s->mfpc1[i], 0);

  s->mfppc1 = mpc_valloc (s->deg + 1);
  for (i = 0; i <= s->deg; i++)
    mpc_init2 (s->mfppc1[i], 0);

  /* temporary vectors */
  s->spar1 = mps_boolean_valloc (s->deg + 2);
  s->h = mps_boolean_valloc (s->deg + 2);
  s->again_old = mps_boolean_valloc (s->deg);

  s->oldpunt = int_valloc (s->deg + 1);
  s->clust_aux = int_valloc (s->deg + 1);
  s->punt_aux = int_valloc (s->deg + 1);
  s->punt_out = int_valloc (s->deg + 1);
  s->clust_out = int_valloc (s->deg + 1);

  s->fap1 = double_valloc (s->deg + 1);
  s->fap2 = double_valloc (s->deg + 1);

  s->dap1 = rdpe_valloc (s->deg + 1);
  s->dpc1 = cdpe_valloc (s->deg + 1);
  s->dpc2 = cdpe_valloc (s->deg + 1);

  s->fradii = double_valloc (s->deg + 1);
  s->partitioning = int_valloc (s->deg + 2);
  s->dradii = rdpe_valloc (s->deg + 1);

  /* Setting some default here, that were not settable because we didn't know
   * the degree of the polynomial */
  for (i = 0; i < s->n; i++) 
    s->root[i]->wp = DBL_DIG * LOG2_10;

  /* Init the mutex that need it */
  pthread_mutex_init (&s->precision_mutex, NULL);

  /* Other mt variables in status */
  MPS_INIT_LOCK (s->data_prec_max);

  s->initialized = true;
}