Method: NumRu::NArray#to_binary

Defined in:
ext/numru/narray/narray.c

#to_binaryObject

method: to_binary – convert the data contents to a BYTE type NArray



697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
# File 'ext/numru/narray/narray.c', line 697

static VALUE
 na_to_binary(VALUE self)
{
  struct NARRAY *a1, *a2;
  int i, rank;
  na_shape_t *shape;
  VALUE v;

  GetNArray(self,a1);

  rank = a1->rank+1;
  shape = ALLOCA_N(na_shape_t,rank);
  shape[0] = na_sizeof[a1->type];
  for (i=1; i<rank; ++i)
    shape[i] = a1->shape[i-1];

  v = na_make_object( NA_BYTE, rank, shape, cNArray );
  GetNArray(v,a2);
  MEMCPY(a2->ptr,a1->ptr,char,a2->total);

  return v;
}