Sha256: 8b6d2a5a7be783b308f03434468918764d91e0f5e3ec717c7fc3e34f993999c5

Contents?: true

Size: 1.47 KB

Versions: 19

Compression:

Stored size: 1.47 KB

Contents

/*
  Convert a data value of obj (with a single element) to dtype.
*/
/*
static dtype
<%=c_func(:nodef)%>(VALUE obj)
{
    cumo_narray_t *na;
    dtype  x;
    char  *ptr;
    size_t pos;
    VALUE  r, klass;

    CUMO_SHOW_SYNCHRONIZE_WARNING_ONCE("<%=name%>", "<%=type_name%>");
    cumo_cuda_runtime_check_status(cudaDeviceSynchronize());

    if (CumoIsNArray(obj)) {
        CumoGetNArray(obj,na);
        if (na->size != 1) {
            rb_raise(cumo_na_eShapeError,"narray size should be 1");
       }
        klass = rb_obj_class(obj);
        ptr = cumo_na_get_pointer_for_read(obj);
        pos = cumo_na_get_offset(obj);
        <% find_tmpl("store").definitions.select{|x| x.class==Store}.each do |x| %>
        if (<%=x.condition("klass")%>) {
            <%=x.extract_data("ptr","pos","x")%>;
            return x;
        }
        <% end %>

        // coerce
        r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
        if (rb_obj_class(r)==cT) {
            return <%=c_func%>(r);
        }
        <% if is_object %>
        return obj;
        <% else %>
        rb_raise(cumo_na_eCastError, "unknown conversion from %s to %s",
                 rb_class2name(rb_obj_class(obj)),
                 rb_class2name(cT));
        <% end %>
    }
    if (TYPE(obj)==T_ARRAY) {
        if (RARRAY_LEN(obj) != 1) {
            rb_raise(cumo_na_eShapeError,"array size should be 1");
        }
        return m_num_to_data(RARRAY_AREF(obj,0));
    }
    return m_num_to_data(obj);
}
*/

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
cumo-0.4.3 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.4.2 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.4.1 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.4.0 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.3.5 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.3.4 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.3.3 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.3.2 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.3.1 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.3.0 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.3.0.pre1 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.2.5 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.2.4 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.2.3 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.2.2 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.2.1 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.2.0 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.1.2 ext/cumo/narray/gen/tmpl/extract_data.c
cumo-0.1.1 ext/cumo/narray/gen/tmpl/extract_data.c