예제 #1
0
파일: copy.hpp 프로젝트: jb--/cuda-wrapper
typename boost::enable_if<boost::is_same<T, typename U::value_type>, void>::type
copy(symbol<T[]> const& src, U& dst)
{
    function_requires<RandomAccessContainerConcept<U> >();
    assert(typename U::difference_type(src.size()) == (dst.end() - dst.begin()));
    CUDA_CALL(cudaMemcpyFromSymbol(&*dst.begin(), reinterpret_cast<char const*>(src.data()), src.size() * sizeof(T), 0, cudaMemcpyDeviceToHost));
}
예제 #2
0
// copy all symbol data from another symbol into a symbol from list
void reel::copySymbol(symbol temp, int offset)
{
 // set the name of the symbol offset from the base of the list to the name of temp
 list[offset].setName(temp.getName());
 // set the value of the symbol offset from the base of the list to the value of temp
 list[offset].setValue(temp.getValue());
};
예제 #3
0
파일: copy.hpp 프로젝트: jb--/cuda-wrapper
typename boost::enable_if<boost::is_same<T, typename U::value_type>, void>::type
copy(U const& src, symbol<T[]> const& dst)
{
    function_requires<RandomAccessContainerConcept<U> >();
    assert((src.end() - src.begin()) == typename U::difference_type(dst.size()));
    CUDA_CALL(cudaMemcpyToSymbol(reinterpret_cast<char const*>(dst.data()), &*src.begin(), (src.end() - src.begin()) * sizeof(T), 0, cudaMemcpyHostToDevice));
}
예제 #4
0
파일: params.cpp 프로젝트: greatmazinger/z3
 bool split_name(symbol const& name, symbol & prefix, symbol & suffix) const {
     if (name.is_numerical()) return false;
     char const* str = name.bare_str();
     char const* period = strchr(str,'.');
     if (!period) return false;
     svector<char> prefix_((unsigned)(period-str), str);
     prefix_.push_back(0);
     prefix = symbol(prefix_.c_ptr());
     suffix = symbol(period + 1);
     return true;
 }
예제 #5
0
파일: path.C 프로젝트: pamoakoy/daisy-model
symbol 
Path::nodir (symbol name_s)
{
  const std::string name = name_s.name ();
  size_t start = name.size ();

  for (;start > 0; start--)
    {
      const char prev = name[start-1];

      if (prev == '/')
	break;
      
#if !defined (__unix) 
      if (prev == '\\' || prev == ':')
	break;
#endif // !unix
    }
  
  std::string result;

  for (;start < name.size (); start++)
    result += name[start];

  return result;
}
예제 #6
0
static unsigned pp_symbol(std::ostream & out, symbol const & s) {
    if (is_smt2_quoted_symbol(s)) {
        std::string str = mk_smt2_quoted_symbol(s);
        out << str;
        return static_cast<unsigned>(str.length());
    }
    else if (s.is_numerical()) {
        std::string str = s.str();
        out << str;
        return static_cast<unsigned>(str.length());
    }
    else {
        out << s.bare_str();
        return static_cast<unsigned>(strlen(s.bare_str()));
    }
}
symbol_distribution::symbol_distribution(const symbol &s)
: total_frequencies(1) {
	for (int i = 0; i < ARITHMETIC_SYMBOL_COUNT; i++) {
		frequencies[i] = 0u;
	}
	frequencies[s.get_sequential_code()] = 1u;
}
예제 #8
0
파일: path.C 프로젝트: pamoakoy/daisy-model
bool 
Path::set_directory (symbol directory_s)
{ 
  const std::string& directory = directory_s.name ();
  const char *const dir = directory.c_str ();
  const bool result 
    = chdir (dir) == 0 || (mkdir (dir, 0777) == 0 && chdir (dir) == 0); 
  
  if (!result)
    /* Do nothing */;
  else if (directory[0] == '/'
#ifndef __unix__
           || directory[0] == '\\' || directory[1] == ':'
#endif
           )
    // Already absolute.
    current_directory = directory;
  else
    // Make it absolute.
    current_directory = get_cwd ();

  std::ostringstream tmp;
  tmp << "Changing directory to '" << directory << "' " 
      << (result ? "success" : "failure");
  Assertion::debug (tmp.str ());

  return result;
}
예제 #9
0
파일: path.C 프로젝트: pamoakoy/daisy-model
std::auto_ptr<std::istream> 
Path::open_file (symbol name_s) const
{
  const std::string& name = name_s.name ();

  struct Message : std::ostringstream 
  {
    ~Message ()
    { Assertion::debug (this->str ()); }
  } tmp;
  tmp << "In directory '" << get_directory () << "':";

  std::auto_ptr<std::istream> in;

  // Absolute filename.
  if (name[0] == '.' || name[0] == '/'
#ifndef __unix__
      || name[0] == '\\' || name[1] == ':'
#endif
      )
    {
      tmp << "\nOpening absolute file name '" << name << "'";
      in.reset (new std::ifstream (name.c_str ()));
      return in;
    }

  tmp << "\nLooking for file '" << name << "'";

  // Look in path.
  for (unsigned int i = 0; i < path.size (); i++)
    {
      const symbol dir = (path[i] == "." ? current_directory : path[i]);
      const symbol file = dir + DIRECTORY_SEPARATOR + name;
      tmp << "\nTrying '" << file << "'";
      if (path[i] == ".")
	tmp << " (cwd)";
      in.reset (new std::ifstream (file.name ().c_str ()));
      if (in->good ())
	{
	  tmp << " success!";
	  return in;
	}
    }
  tmp << "\nGiving up";
  daisy_assert (in.get ());		
  return in;			// Return last bad stream.
}
예제 #10
0
파일: ast_smt2_pp.cpp 프로젝트: EinNarr/z3
 std::string ensure_quote(symbol const& s) {
     std::string str;
     if (is_smt2_quoted_symbol(s))
         str = mk_smt2_quoted_symbol(s);
     else
         str = s.str();
     return str;
 }
예제 #11
0
void 
PrinterFile::Implementation::print_object (const FrameModel& value,
                                           const Library& library, 
                                           const FrameModel *const original, 
                                           int indent)
{
  const symbol element = value.type_name ();
  if (!library.check (element))
    {
      out << "<unknown " << element << ">";
      return;
    }

  // Check original.
  if (original && original->type_name () == element)
    {
      out << "original";
      // Check if we added something over the original.
      if (value.subset (metalib, *original))
        return;
      out << " ";
      print_alist (value, original, indent + 9, false);
      return;

    }
  
  const FrameModel& element_frame = library.model (element);
  
  // Check if we added something over the library.
  if (value.subset (metalib, element_frame))
    {
      // We didn't.
      print_symbol (element);
      return;
    }

  // Library element with additional attributes.
  print_symbol (element);
  out << " ";
  print_alist (value, &element_frame,
               indent + 1 + element.name ().length ()
               // Buglet: Wrong indentation for elements with strange chars.
               + (is_identifier (element.name ()) ? 0 : 2),
               false);
}
double symbol_distribution::get_accumulated_probability(const symbol &s) const {
	double result = 0.0;
	for (unsigned int i = 0; i < s.get_sequential_code(); i++) {
		result +=
				static_cast<double>(frequencies[i]) /
				static_cast<double>(total_frequencies);
	}
	return result;
}
예제 #13
0
void 
ChemistryMulti::check_ignore (const symbol chem, Treelog& msg)
{
  if (ignored (chem))
    return;
  
  msg.message ("Fate of '" + chem.name () + "' will not be traced");
  ignore.push_back (chem);
}
예제 #14
0
 void set_next_arg(cmd_context & ctx, symbol const & s) override {
     cmd * c = ctx.find_cmd(s);
     if (c == nullptr) {
         std::string err_msg("unknown command '");
         err_msg = err_msg + s.bare_str() + "'";
         throw cmd_exception(std::move(err_msg));
     }
     m_cmds.push_back(s);
 }
예제 #15
0
 virtual void set_next_arg(cmd_context & ctx, symbol const & s) {
     cmd * c = ctx.find_cmd(s);
     if (c == 0) {
         std::string err_msg("unknown command '");
         err_msg = err_msg + s.bare_str() + "'";
         throw cmd_exception(err_msg);
     }
     m_cmds.push_back(s);
 }
예제 #16
0
void
DestinationTable::initialize (const symbol log_dir, const symbol objid,
                              const symbol description, const Volume& volume,
                              const std::vector<std::pair<symbol, symbol>/**/>&
                              /**/ parameters)
{
  const std::string fn = log_dir.name () + file.name ();
  out.open (fn.c_str ());

  print_header.start (out, objid, file, parsed_from_file);

  for (size_t i = 0; i < parameters.size (); i++)
    print_header.parameter (out, parameters[i].first, parameters[i].second);

  print_header.interval (out, volume);
  print_header.log_description (out, description);

  out.flush ();
}
예제 #17
0
void symbol:: copy( symbol s ){
	int l = strlen(s.name);
	name = new char[l+1];
	char* tmp = new char[20];
	s.getname(tmp);
	strcopy(name, tmp);
	value = s.value;
	bonus = s.bonus;
	delete[] tmp;
}
예제 #18
0
파일: inifcns.cpp 프로젝트: feelpp/feelpp
// If x is real then U.diff(x)-I*V.diff(x) represents both conjugate(U+I*V).diff(x) 
// and conjugate((U+I*V).diff(x))
static ex conjugate_expl_derivative(const ex & arg, const symbol & s)
{
	if (s.info(info_flags::real))
		return conjugate(arg.diff(s));
	else {
		exvector vec_arg;
		vec_arg.push_back(arg);
		return fderivative(ex_to<function>(conjugate(arg)).get_serial(),0,vec_arg).hold()*arg.diff(s);
	}
}
예제 #19
0
 void insert(symbol const & name, param_kind k, char const * descr) {
     SASSERT(!name.is_numerical());
     info i;
     if (m_info.find(name, i)) {
         SASSERT(i.first == k);
         return;
     }
     m_info.insert(name, info(k, descr));
     m_names.push_back(name);
 }
예제 #20
0
void 
PrinterFile::print_entry (const Frame& frame,
			  const symbol key)
{ 
  if (frame.check (key))
    {
      impl->out << "(" << key << " ";
      const int indent = 2 + key.name ().length ();
      impl->print_entry (frame, NULL, key, indent, false);
      impl->out << ")\n";
    }
}
예제 #21
0
symbol                          // Return DIM without time.
Oldunits::Content::crop_time (const symbol dim_s)
{
  const std::string& dim = dim_s.name ();
  daisy_assert (dim.size () > 0);
  size_t end;
  for (end = dim.size () - 1; dim[end] != '/'; end--)
    daisy_assert (end > 0);
  std::string result;
  for (int i = 0; i < end; i++)
    result += dim[i];
  return result;
}
예제 #22
0
std::string mk_smt2_quoted_symbol(symbol const & s) {
    SASSERT(is_smt2_quoted_symbol(s));
    string_buffer<> buffer;
    buffer.append('|');
    char const * str = s.bare_str();
    while (*str) {
        if (*str == '|' || *str == '\\')
            buffer.append('\\');
        buffer.append(*str);
        str++;
    }
    buffer.append('|');
    return std::string(buffer.c_str());
}
예제 #23
0
bool				// True iff FROM and TO have same time unit.
Oldunits::Content::time_match (const symbol from_s, const symbol to_s)
{
  const std::string& from = from_s.name ();
  const std::string& to = to_s.name ();
  const size_t from_size = from.size ();
  const size_t to_size = to.size ();

  for (int i = 1; true; i++)
    {
      if (i > from_size || i > to_size)
	return false;

      const char from_c = from[from_size - i];
      const char to_c = to[to_size - i];
      
      if (from_c != to_c)
	return false;
      
      if (from_c == '/')
	return true;
    }
}
예제 #24
0
void
SummaryBalance::print_balance (std::ostream& out,
                               const symbol title, const double total, 
                               const symbol dim,
                               const int /* dim_size */, const int max_size,
                               const int width) const
{
  out << std::string (max_size + 3, ' ') << std::string (width, '-') << "\n"
      << std::string (max_size - title.name ().size (), ' ') << title << " = ";
  out.width (width);
  out << total;
  if (dim != Attribute::Unknown ())
    out << " [" << dim << "]";
  out << "\n";
}
예제 #25
0
void
PrinterFile::print_comment (const symbol comment_s)
{
  const std::string& comment = comment_s.name ();

  std::vector<std::string> text;

  int last = 0;
  for (;;)
    {
      const int next = comment.find ('\n', last);
      if (next < 0)
	break;
      text.push_back (comment.substr (last, next - last));
      last = next + 1;
    }
  text.push_back (comment.substr (last));

  for (unsigned int i = 0; i < text.size (); i++)
    impl->out << ";; " << text[i] << "\n";
}
예제 #26
0
 bool operator()(symbol const & lhs,
                 def const & rhs) const
 {
     return operator()(lhs.c_str(), rhs.name());
 }
예제 #27
0
 const char * name(void) const
 {
     return name_.c_str();
 }
unsigned int symbol_distribution::get_emissions(const symbol &s) const {
	return frequencies[s.get_sequential_code()];
}
bool symbol_distribution::has_only_the_symbol(const symbol &s) const {
	return frequencies[s.get_sequential_code()] == 1 && total_frequencies == 1;
}
double symbol_distribution::get_probability_of(const symbol &s) const {
	int index = s.get_sequential_code();
	return
		static_cast<double>(frequencies[index]) /
		static_cast<double>(total_frequencies);
}