Beispiel #1
0
static float make_number() {
  float v = 0;
  int sel;

  if (return_large == true && R(3) == 1) {
      sel = R(6);
  } else {
      sel = R(4);
  }

  if (return_undef == false && sel == 0) {
      sel = 1;
  }

  if (R(2) == 1) {
      v = (float)R(100);
  } else {

      switch (sel) {
        case 0: break;
        case 1: v = 0; break;
        case 2: v = 0.000001f; break;
        case 3: v = 10000; break;
        case 4: v = 2000000000; break;
        case 5: v = huge(); break;
      }

  }

  if (R(4) == 1) {
      v = -v;
  }

  return v;
}
 auto update_vertex(LpState& s)
 {
     if (s.cell != start)
     {
         auto minimum = huge();
         for (auto neighbour : valid_neighbours_of(s.cell))
             minimum = min(minimum, (at(neighbour).g + cost()));
         s.r = minimum;
     }
     q.remove(s.cell);
     if (s.g != s.r) q.push(s.cell);
 }
 auto replan(Cells const& cells_to_toggle = {})
 {
     reset_statistics();
     for (auto c : cells_to_toggle)
     {
         at(c).bad = !at(c).bad;
         if (!at(c).bad)
             update_vertex(at(c));
         else
             at(c).g = at(c).r = huge();
         update_neighbours_of(c);
     }
     compute_shortest_path();
 }
Beispiel #4
0
int
main (int argc, char *argv[])
{
  tests_start_mpfr ();

  special ();
  bug20070831 ();
  huge ();

  test_generic (2, 100, 25);
  test_generic_huge (2, 100, 5);

  data_check ("data/acosh", mpfr_acosh, "mpfr_acosh");
  bad_cases (mpfr_acosh, mpfr_cosh, "mpfr_acosh", 0, -128, 29,
             4, 128, 800, 40);

  tests_end_mpfr ();
  return 0;
}
Beispiel #5
0
int main()
{
    double z = 1.0;

    cout << "Some inquiries into the nature of double:" << endl
         << "digits(z) = " << digits(z) << endl
         << "epsilon(z) = " << epsilon(z) << endl
         << "huge(z) = " << huge(z) << endl
         << "tiny(z) = " << tiny(z) << endl
         << "max_exponent(z) = " << max_exponent(z) << endl
         << "min_exponent(z) = " << min_exponent(z) << endl
         << "max_exponent10(z) = " << max_exponent10(z) << endl
         << "min_exponent10(z) = " << min_exponent10(z) << endl
         << "precision(z) = " << precision(z) << endl
         << "radix(z) = " << radix(z) << endl;

    Range r = range(z);
    cout << "range(z) = [ " << r.first() << ", " << r.last() << " ]"
         << endl;

    cout << endl << "More obscure properties:" << endl
         << "is_signed(z) = " << is_signed(z) << endl
         << "is_integer(z) = " << is_integer(z) << endl
         << "is_exact(z) = " << is_exact(z) << endl
         << "round_error(z) = " << round_error(z) << endl
         << "has_infinity(z) = " << has_infinity(z) << endl
         << "has_quiet_NaN(z) = " << has_quiet_NaN(z) << endl
         << "has_signaling_NaN(z) = " << has_signaling_NaN(z) << endl
         << "has_denorm(z) = " << has_denorm(z) << endl
         << "has_denorm_loss(z) = " << has_denorm_loss(z) << endl
         << "infinity(z) = " << infinity(z) << endl
         << "quiet_NaN(z) = " << quiet_NaN(z) << endl
         << "signaling_NaN(z) = " << signaling_NaN(z) << endl
         << "denorm_min(z) = " << denorm_min(z) << endl
         << "is_iec559(z) = " << is_iec559(z) << endl
         << "is_bounded(z) = " << is_bounded(z) << endl
         << "is_modulo(z) = " << is_modulo(z) << endl
         << "traps(z) = " << traps(z) << endl
         << "tinyness_before(z) = " << tinyness_before(z) << endl;

    return 0;
}
            auto compute_shortest_path()
            {
                Timing t{ run_time };
                while (!q.empty() && (Key{ at(q.top()) } < Key{ at(goal) } || at(goal).r != at(goal).g))
                {
                    auto c = q.pop();
                    if (at(c).g > at(c).r)
                        at(c).g = at(c).r;
                    else
                        at(c).g = huge(), 
                        update_vertex(at(c));
                    update_neighbours_of(c);

                    {
                        max_q_size = max(max_q_size, q.size());
                        expansions.insert(c);
                    }
                }
                path = build_path();
            }
static float make_number(bool positiveOnly) {
    float f = positiveOnly ? 1.0f : 0.0f;
    float v = f;
    int sel;

    if (return_large) sel = R(6); else sel = R(4);
    if (!return_undef && sel == 0) sel = 1;

    if (R(2) == 1) v = (float)(R(100)+f); else

    switch (sel) {
        case 0: break;
        case 1: v = f; break;
        case 2: v = 0.000001f; break;
        case 3: v = 10000.0f; break;
        case 4: v = 2000000000.0f; break;
        case 5: v = huge(); break;
    }

    if (!positiveOnly && (R(4) == 1)) v = -v;
    return v;
}
Beispiel #8
0
int GmshRemote()
{
  GmshClient *client = Msg::GetGmshClient();

  int rank = Msg::GetCommRank();
  int nbDaemon = Msg::GetCommSize();

  if(!client && rank == 0) return 0;

  if(client && nbDaemon < 2)
    computeAndSendVertexArrays(client);
  else if(client && nbDaemon >= 2 && rank == 0)
    gatherAndSendVertexArrays(client, false);

  while(1){

    // on the node with MPI rank 0, communicate through a socket
    if (rank == 0) {
      // stop if we have no communications for 5 minutes
      int ret = client->Select(300, 0);
      if(!ret){
        client->Info("Timout: stopping remote Gmsh...");
        break;
      }
      else if(ret < 0){
        client->Error("Error on select: stopping remote Gmsh...");
        break;
      }

      int type, length, swap;
      if(!client->ReceiveHeader(&type, &length, &swap)){
        client->Error("Did not receive message header: stopping remote Gmsh...");
        break;
      }

      char *msg = new char[length + 1];
      if(!client->ReceiveString(length, msg)){
        client->Error("Did not receive message body: stopping remote Gmsh...");
        delete [] msg;
        break;
      }

      if(type == GmshSocket::GMSH_STOP){
        client->Info("Stopping remote Gmsh...");
        delete [] msg;
        break;
      }
      else if(type == GmshSocket::GMSH_VERTEX_ARRAY){
        ParseString(msg);
#if !defined(HAVE_MPI)
        computeAndSendVertexArrays(client);
#else
        int mpi_msg = MPI_GMSH_PARSE_STRING;
        MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        gatherAndSendVertexArrays(client, swap);
#endif
      }
      else if(type == GmshSocket::GMSH_MERGE_FILE){
        MergeFile(msg);
#if !defined(HAVE_MPI)
        computeAndSendVertexArrays(client);
#else
        int mpi_msg = MPI_GMSH_MERGE_FILE;
        MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        gatherAndSendVertexArrays(client, swap);
#endif
      }
      else if(type == GmshSocket::GMSH_PARSE_STRING){
        ParseString(msg);
#if defined(HAVE_MPI)
        int mpi_msg = MPI_GMSH_PARSE_STRING;
        MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
#endif
      }
      else if(type == GmshSocket::GMSH_SPEED_TEST){
        client->Info("Sending huge array");
        std::string huge(500000000, 'a');
        client->SpeedTest(huge.c_str());
      }
      else{
        client->Error("Ignoring unknown message");
      }

      delete [] msg;
    }
    else { // if we're not on the master node (rank != 0) wait for him...
#if defined(HAVE_MPI)
      int mpi_msg;
      MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
      if (mpi_msg == MPI_GMSH_COMPUTE_VIEW)
        computeAndSendVertexArrays();
      else if(mpi_msg == MPI_GMSH_SHUTDOWN)
        Msg::Exit(0);
      else if(mpi_msg == MPI_GMSH_PARSE_STRING){
        int length;
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        char msg[length];
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        ParseString(msg);
      }
      else if (mpi_msg == MPI_GMSH_MERGE_FILE){
        int length;
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        char msg[length];
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        MergeFile(msg);
      }
#endif
    }
  }

#if defined(HAVE_MPI)
  int mpi_msg = MPI_GMSH_SHUTDOWN;
  MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
#endif

  return 0;
}