ext/numo/narray/array.c in numo-narray-0.9.1.4 vs ext/numo/narray/array.c in numo-narray-0.9.1.5

- old
+ new

@@ -1,9 +1,9 @@ /* array.c - Numerical Array Extension for Ruby - (C) Copyright 1999-2017 by Masahiro TANAKA + Ruby/Numo::NArray - Numerical Array class for Ruby + Copyright (C) 1999-2019 Masahiro TANAKA */ #include <ruby.h> #include "numo/narray.h" // mdai: Multi-Dimensional Array Investigation @@ -120,14 +120,16 @@ static int na_mdai_object_type(int type, VALUE v) { if (rb_obj_is_kind_of(v, rb_cRange)) { MDAI_ATTR_TYPE(type,v,begin); MDAI_ATTR_TYPE(type,v,end); - } else if (rb_obj_is_kind_of(v, na_cStep)) { +#ifdef HAVE_RB_ARITHMETIC_SEQUENCE_EXTRACT + } else if (rb_obj_is_kind_of(v, rb_cArithSeq)) { MDAI_ATTR_TYPE(type,v,begin); MDAI_ATTR_TYPE(type,v,end); MDAI_ATTR_TYPE(type,v,step); +#endif } else { type = na_object_type(type,v); } return type; } @@ -208,11 +210,17 @@ if ( na_mdai_investigate(mdai,ndim+1) ) { len--; /* Array is empty */ } } else - if (rb_obj_is_kind_of(v, rb_cRange) || rb_obj_is_kind_of(v, na_cStep)) { + if (rb_obj_is_kind_of(v, rb_cRange) +#ifdef HAVE_RB_ARITHMETIC_SEQUENCE_EXTRACT + || rb_obj_is_kind_of(v, rb_cArithSeq) +#else + || rb_obj_is_kind_of(v, rb_cEnumerator) +#endif + ) { nary_step_sequence(v,&length,&dbeg,&dstep); len += length-1; mdai->type = na_mdai_object_type(mdai->type, v); } else if (IsNArray(v)) { @@ -463,14 +471,16 @@ @overload new_like(obj) @param [Numeric,Array,Numo::NArray] obj @return [Numo::NArray] @example Numo::NArray.new_like([[1,2,3],[4,5,6]]) - => Numo::Int32#shape=[2,3](empty) + # => Numo::Int32#shape=[2,3](empty) + Numo::DFloat.new_like([[1,2],[3,4]]) - => Numo::DFloat#shape=[2,2](empty) + # => Numo::DFloat#shape=[2,2](empty) + Numo::NArray.new_like([1,2i,3]) - => Numo::DComplex#shape=[3](empty) + # => Numo::DComplex#shape=[3](empty) */ VALUE na_s_new_like(VALUE type, VALUE obj) { VALUE newary;