Method: Numo::NArray#==
- Defined in:
- ext/numo/narray/narray.c
#==(other) ⇒ Boolean
Equality of self and other in view of numerical array. i.e., both arrays have same shape and corresponding elements are equal.
1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 |
# File 'ext/numo/narray/narray.c', line 1957
static VALUE
na_equal(VALUE self, volatile VALUE other)
{
volatile VALUE vbool;
narray_t *na1, *na2;
int i;
GetNArray(self,na1);
if (!rb_obj_is_kind_of(other,cNArray)) {
other = rb_funcall(rb_obj_class(self), id_cast, 1, other);
}
GetNArray(other,na2);
if (na1->ndim != na2->ndim) {
return Qfalse;
}
for (i=0; i<na1->ndim; i++) {
if (na1->shape[i] != na2->shape[i]) {
return Qfalse;
}
}
if (na1->size == 0) {
return Qtrue;
}
vbool = rb_funcall(self, id_eq, 1, other);
return (rb_funcall(vbool, id_count_false, 0)==INT2FIX(0)) ? Qtrue : Qfalse;
}
|