Method: Numo::NArray.new_like

Defined in:
ext/numo/narray/array.c

.new_like(obj) ⇒ Numo::NArray

Generate new unallocated NArray instance with shape and type defined from obj. Numo::NArray.new_like(obj) returns instance whose type is defined from obj. Numo::DFloat.new_like(obj) returns DFloat instance.

Examples:

Numo::NArray.new_like([[1,2,3],[4,5,6]])
# => Numo::Int32#shape=[2,3](empty)

Numo::DFloat.new_like([[1,2],[3,4]])
# => Numo::DFloat#shape=[2,2](empty)

Numo::NArray.new_like([1,2i,3])
# => Numo::DComplex#shape=[3](empty)

Parameters:

Returns:



469
470
471
472
473
474
475
476
# File 'ext/numo/narray/array.c', line 469

VALUE
na_s_new_like(VALUE type, VALUE obj)
{
    VALUE newary;

    na_composition3(obj, &type, 0, &newary);
    return newary;
}