Пример #1
0
    static callable make()
    {
        callable self = functional::call<F>(ndt::type("(Any, Any) -> Any"));

        for (const std::pair<std::array<type_id_t, 2>, callable> &pair :
                callable::make_all<K, numeric_type_ids, numeric_type_ids>(0)) {
            children[pair.first[0]][pair.first[1]] = pair.second;
        }

        for (type_id_t i0 : numeric_type_ids()) {
            for (type_id_t i1 : dim_type_ids()) {
                const ndt::type child_tp =
                    ndt::callable_type::make(self.get_type()->get_return_type(),
                {ndt::type(i0), ndt::type(i1)});
                children[i0][i1] = functional::elwise(child_tp, self);
            }
        }

        for (type_id_t i0 : dim_type_ids()) {
            typedef join<numeric_type_ids, dim_type_ids>::type type_ids;
            for (type_id_t i1 : type_ids()) {
                const ndt::type child_tp =
                    ndt::callable_type::make(self.get_type()->get_return_type(),
                {ndt::type(i0), ndt::type(i1)});
                children[i0][i1] = functional::elwise(child_tp, self);
            }
        }

        return functional::multidispatch(self.get_array_type(), children,
                                         default_child);
    }
Пример #2
0
    static std::map<std::array<type_id_t, 2>, callable> make_children()
    {
      typedef type_id_sequence<bool_type_id, int8_type_id, int16_type_id, int32_type_id, int64_type_id, uint8_type_id,
                               uint16_type_id, uint32_type_id, uint64_type_id, float32_type_id,
                               float64_type_id> numeric_type_ids;

      std::map<std::array<type_id_t, 2>, callable> children =
          callable::make_all<K, numeric_type_ids, numeric_type_ids>(0);

      callable self = functional::call<F>(ndt::type("(Any, Any) -> Any"));

      for (type_id_t i0 : numeric_type_ids()) {
        for (type_id_t i1 : dim_type_ids()) {
          const ndt::type child_tp = ndt::callable_type::make(ndt::type("Any"), {ndt::type(i0), ndt::type(i1)});
          children[{{i0, i1}}] = functional::elwise(child_tp, self);
        }
      }

      for (type_id_t i : numeric_type_ids()) {
        children[{{option_type_id, i}}] = callable::make<option_comparison_kernel<F, true, false>>();
        children[{{i, option_type_id}}] = callable::make<option_comparison_kernel<F, false, true>>();
      }
      children[{{option_type_id, option_type_id}}] = callable::make<option_comparison_kernel<F, true, true>>();

      for (type_id_t dim_tp_id : dim_type_ids()) {
        children[{{dim_tp_id, option_type_id}}] = functional::elwise(self);
        children[{{option_type_id, dim_tp_id}}] = functional::elwise(self);
      }

      for (type_id_t i0 : dim_type_ids()) {
        typedef join<numeric_type_ids, dim_type_ids>::type type_ids;
        for (type_id_t i1 : type_ids()) {
          const ndt::type child_tp = ndt::callable_type::make(ndt::type("Any"), {ndt::type(i0), ndt::type(i1)});
          children[{{i0, i1}}] = functional::elwise(child_tp, self);
        }
      }

      children[{{string_type_id, string_type_id}}] = callable::make<K<string_type_id, string_type_id>>(0);

      return children;
    }
Пример #3
0
    static callable make()
    {
        const callable self = functional::call<F>(ndt::type("(Any) -> Any"));

        for (const std::pair<const type_id_t, callable> &pair :
                callable::make_all<K, numeric_type_ids>(0)) {
            children[pair.first] = pair.second;
        }

        for (type_id_t i0 : dim_type_ids()) {
            const ndt::type child_tp = ndt::callable_type::make(
                                           self.get_type()->get_return_type(), ndt::type(i0));
            children[i0] = functional::elwise(child_tp, self);
        }

        return functional::multidispatch(self.get_array_type(), children,
                                         default_child);
    }