예제 #1
0
파일: expression.hpp 프로젝트: kfrlib/kfr
void test_expression(const E& expr, size_t size, Fn&& fn, const char* expression = nullptr)
{
    using T                  = value_type_of<E>;
    ::testo::test_case* test = ::testo::active_test();
    auto&& c                 = ::testo::make_comparison();
    test->check(c <= expr.size() == size, expression);
    if (expr.size() != size)
        return;
    size                     = size_min(size, 200);
    constexpr size_t maxsize = 2 + ilog2(vector_width<T> * 2);
    for (size_t i = 0; i < size;)
    {
        const size_t next_size =
            std::min(prev_poweroftwo(size - i), static_cast<size_t>(1) << (std::rand() % maxsize));

        cswitch(csize<1> << csizeseq<maxsize>, next_size, [&](auto x) {
            constexpr size_t nsize = val_of(decltype(x)());
            ::testo::scope s(as_string("i = ", i));
            test->check(c <= get_elements(expr, cinput, i, vec_shape<T, nsize>()) ==
                            internal::get_fn_value<T, nsize>(i, fn),
                        expression);
        });
        i += next_size;
    }
}
예제 #2
0
/**
 * \brief Removes a resource element from the list.
 * \param resource_type A type of resource.
 * \param id Id of the element to remove.
 * \return \c true if the element was removed, \c false if such an element
 * did not exist.
 */
bool QuestResources::remove(
    ResourceType resource_type,
    const std::string& id
) {
  ResourceMap& resource = get_elements(resource_type);
  return resource.erase(id) > 0;
}
예제 #3
0
static vector_t get_sorted_elements(const hash_t *hash){
  vector_t elements = get_elements(hash);
  
  if(elements.num_elements>1) // fsanitize=undefined aborts the program if sending null pointer to qsort.
    qsort(elements.elements, elements.num_elements, sizeof(void*), compare_hash_elements);
  
  return elements;
}
예제 #4
0
void NoGhostGameofLife::finish_construction()
{
    m_numProcs = m_bulkData->parallel_size();
    m_time = 0;
    get_elements();
    create_element_connectivity_maps();
    write_output_mesh();
}
예제 #5
0
/**
 * \brief Adds a resource element to the list.
 * \param resource_type A type of resource.
 * \param id Id of the element to add.
 * \param description Description the element to add.
 * \return \c true if the element was added, \c false if an element with
 * this id already exists.
 */
bool QuestResources::add(
    ResourceType resource_type,
    const std::string& id,
    const std::string& description
) {
  ResourceMap& resource = get_elements(resource_type);
  auto result = resource.insert(std::make_pair(id, description));
  return result.second;
}
예제 #6
0
//public
GameofLife::GameofLife(GameofLifeMesh& Mesh, std::string meshName)
:m_metaData(Mesh.meta_data()), m_bulkData(Mesh.bulk_data()),
  m_lifeField(Mesh.life_field()), m_stkIo(Mesh.comm()), m_meshName(meshName), m_time(0),
 m_elemType(Mesh.element_type()),m_activeNeighborField(Mesh.neighbor_field())
{
    get_elements();
    write_output_mesh();
    fill_neighbor_sets_of_elements();
}
예제 #7
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_flattop& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     const vec<T, N> n = get_elements(self.linspace, cinput, index, y) * c_pi<T, 2>;
     constexpr T a0    = 1;
     constexpr T a1    = 1.93;
     constexpr T a2    = 1.29;
     constexpr T a3    = 0.388;
     constexpr T a4    = 0.028;
     return a0 - a1 * cos(n) + a2 * cos(2 * n) - a3 * cos(3 * n) + a4 * cos(4 * n);
 }
예제 #8
0
/**
 * \brief Sets the description of a resource element.
 * \param resource_type A type of resource.
 * \param id Id of the element to modify.
 * \param description The new description.
 * \return \c true in case of success, \c false if such an element does not
 * exist.
 */
bool QuestResources::set_description(
    ResourceType resource_type,
    const std::string& id,
    const std::string& description
) {
  if (!exists(resource_type, id)) {
    return false;
  }

  ResourceMap& resource = get_elements(resource_type);
  resource[id] = description;
  return true;
}
예제 #9
0
/**
 * \brief Returns the description of a resource element.
 * \param resource_type A type of resource.
 * \param id Id of the element to get.
 * \return description The element description.
 * Returns an empty string if the element does not exist.
 */
std::string QuestResources::get_description(
    ResourceType resource_type,
    const std::string& id
) const {

  const ResourceMap& resource = get_elements(resource_type);

  const auto& it = resource.find(id);
  if (it == resource.end()) {
    return "";
  }
  return it->second;
}
예제 #10
0
/**
 * \copydoc LuaData::export_to_lua
 */
bool QuestResources::export_to_lua(std::ostream& out) const {

  // Save each resource.
  for (const auto& kvp: resource_type_names) {

    const ResourceMap& resource = get_elements(kvp.first);
    for (const auto& element: resource) {

      const std::string& id = element.first;
      const std::string& description = element.second;

      out << kvp.second
          << "{ id = \""
          << id
          << "\", description = \""
          << description
          << "\" }\n";
    }
    out << "\n";
  }

  return true;
}
예제 #11
0
/**
 * \copydoc LuaData::export_to_lua
 */
bool QuestResources::export_to_lua(std::ostream& out) const {

  // Save each resource.
  for (const auto& kvp: EnumInfoTraits<ResourceType>::names) {

    const ResourceMap& resource = get_elements(kvp.first);
    for (const auto& element: resource) {

      const std::string& id = element.first;
      const std::string& description = element.second;

      out << kvp.second
          << "{ id = \""
          << escape_string(id)
          << "\", description = \""
          << escape_string(description)
          << "\" }\n";
    }
    out << "\n";
  }

  return true;
}
예제 #12
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_bartlett& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     return 1 - abs(get_elements(self.linspace, cinput, index, y));
 }
예제 #13
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_cosine& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     return sin(c_pi<T> * get_elements(self.linspace, cinput, index, y));
 }
예제 #14
0
/**
 * \brief Returns whether there exists an element with the specified id.
 * \param resource_type A type of resource.
 * \param id The id to look for.
 * \return \c true if there exists an element with the specified id in this
 * resource type.
 */
bool QuestResources::exists(ResourceType resource_type, const std::string& id) const {

  const ResourceMap& resource = get_elements(resource_type);
  return resource.find(id) != resource.end();
}
예제 #15
0
파일: planet.cpp 프로젝트: swilli/pykep
double planet::compute_period() const {
	return 2* boost::math::constants::pi<double>() * std::sqrt(std::pow(get_elements()[0],3) / get_mu_central_body());

}
예제 #16
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_bohman& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     const vec<T, N> n = abs(get_elements(self.linspace, cinput, index, y));
     return (T(1) - n) * cos(c_pi<T> * n) + (T(1) / c_pi<T>)*sin(c_pi<T> * n);
 }
예제 #17
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_hann& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     return T(0.5) * (T(1) - cos(c_pi<T, 2> * get_elements(self.linspace, cinput, index, y)));
 }
예제 #18
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_lanczos& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     return sinc(get_elements(self.linspace, cinput, index, y));
 }
예제 #19
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_gaussian& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     return exp(T(-0.5) * sqr(self.alpha * get_elements(self.linspace, cinput, index, y)));
 }
예제 #20
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_bartlett_hann& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     const vec<T, N> xx = get_elements(self.linspace, cinput, index, y);
     return T(0.62) - T(0.48) * abs(xx - T(0.5)) + T(0.38) * cos(c_pi<T, 2> * (xx - T(0.5)));
 }
예제 #21
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_kaiser& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     return modzerobessel(self.beta * sqrt(1 - sqr(get_elements(self.linspace, cinput, index, y)))) *
            self.m;
 }
예제 #22
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_blackman_harris& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     const vec<T, N> n = get_elements(self.linspace, cinput, index, y) * c_pi<T, 2>;
     return T(0.35875) - T(0.48829) * cos(n) + T(0.14128) * cos(2 * n) - T(0.01168) * cos(3 * n);
 }
예제 #23
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_blackman& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     const vec<T, N> n = get_elements(self.linspace, cinput, index, y);
     return self.a0 - self.a1 * cos(c_pi<T, 2> * n) + self.a2 * cos(c_pi<T, 4> * n);
 }
예제 #24
0
파일: pointer.hpp 프로젝트: kfrlib/kfr
 static void static_get(void* instance, size_t index, vec<T, N>& result)
 {
     result = get_elements(*static_cast<Expression*>(instance), cinput, index, vec_shape<T, N>());
 }
예제 #25
0
파일: window.hpp 프로젝트: kfrlib/kfr
 KFR_INTRINSIC friend vec<T, N> get_elements(const expression_hamming& self, cinput_t cinput,
                                                 size_t index, vec_shape<T, N> y)
 {
     return self.alpha -
            (T(1.0) - self.alpha) * (cos(c_pi<T, 2> * get_elements(self.linspace, cinput, index, y)));
 }