ext/cumo/include/cumo/narray.h in cumo-0.1.2 vs ext/cumo/include/cumo/narray.h in cumo-0.2.0
- old
+ new
@@ -425,13 +425,29 @@
#define CumoIsNArray(obj) (rb_obj_is_kind_of(obj,cNArray)==Qtrue)
#define CUMO_DEBUG_PRINT(v) puts(StringValueCStr(rb_funcall(v,rb_intern("inspect"),0)))
-#define CUMO_NA_CumoIsNArray(obj) \
- (rb_obj_is_kind_of(obj,cNArray)==Qtrue)
-#define CUMO_NA_IsArray(obj) \
- (TYPE(obj)==T_ARRAY || rb_obj_is_kind_of(obj,cNArray)==Qtrue)
+#define CUMO_NA_CumoIsNArray(obj) (rb_obj_is_kind_of(obj,cNArray)==Qtrue)
+#define CUMO_NA_IsArray(obj) (TYPE(obj)==T_ARRAY || rb_obj_is_kind_of(obj,cNArray)==Qtrue)
+
+static inline bool
+cumo_na_has_idx_p(VALUE obj)
+{
+ cumo_narray_t *na;
+ cumo_narray_view_t *nv;
+ int i = 0;
+ CumoGetNArray(obj, na);
+ if (CUMO_NA_TYPE(na) == CUMO_NARRAY_VIEW_T) {
+ CumoGetNArrayView(obj, nv);
+ for (; i < nv->base.ndim; ++i) {
+ if (nv->stridx[i].index) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
#define CUMO_NUM2REAL(v) NUM2DBL( rb_funcall((v),cumo_na_id_real,0) )
#define CUMO_NUM2IMAG(v) NUM2DBL( rb_funcall((v),cumo_na_id_imag,0) )
//#define CUMO_NA_MAX_DIMENSION (int)(sizeof(VALUE)*8-2)