Class: CABlock
Direct Known Subclasses
Instance Method Summary collapse
-
#addr2addr0 ⇒ Object
yard: class CABlock def addr2addr0 (addr) end end.
- #count ⇒ Object
-
#idx2addr0 ⇒ Object
yard: class CABlock def idx2addr0 (idx) end end.
-
#index2addr0 ⇒ Object
yard: class CABlock def idx2addr0 (idx) end end.
- #initialize_copy ⇒ Object
-
#move ⇒ Object
yard: class CABlock def move (*index) end end.
- #offset ⇒ Object
- #size0 ⇒ Object
- #start ⇒ Object
- #step ⇒ Object
Methods inherited from CArray
#==, #__attach__, #__detach__, #__sync__, #all_masked?, #ancestors, #any_masked?, #as_boolean, #as_cmplx128, #as_cmplx256, #as_cmplx64, #as_fixlen, #as_float128, #as_float32, #as_float64, #as_int16, #as_int32, #as_int64, #as_int8, #as_object, #as_type, #as_uint16, #as_uint32, #as_uint64, #as_uint8, #attach, attach, attach!, #attach!, #attached?, big_endian?, #bitarray, #bitfield, #boolean, boolean, #boolean?, #bsearch, #bsearch_index, byte, #bytes, cast, cast_self_or_other, #cast_with, #clip, cmplx128, #cmplx128, cmplx256, #cmplx256, #cmplx64, cmplx64, #coerce, #collect!, #collect_addr!, #collect_index!, #collect_with_addr!, #collect_with_index!, complex, #complex?, #convert, #data_class, #data_class=, data_class?, #data_type, data_type?, #data_type_name, data_type_name, dcomplex, #dim, #dim0, #dim1, #dim2, #dim3, double, #dump_binary, #each, #each_addr, each_index, #each_index, #each_with_addr, #each_with_index, #elem_copy, #elem_decr, #elem_fetch, #elem_incr, #elem_masked?, #elem_store, #elem_swap, #elements, #empty?, endian, #entity?, #fetch_linear_addr, #fields, #fields_at, #fixlen, fixlen, #fixlen?, float, float128, #float128, float32, #float32, float64, #float64, #float?, #freeze, #has_data_class?, #has_mask?, #hash, #incr_addr, #inherit_mask, #inherit_mask_replace, #initialize, int, #int16, int16, #int32, int32, #int64, int64, #int8, int8, #integer?, #invert_mask, #is_masked, #is_not_masked, #length, little_endian?, #load_binary, #map!, #map_addr!, #map_index!, #map_with_addr!, #map_with_index!, #mask, #mask=, #mask_array?, #members, #mul_add, #ndim, #numeric?, #obj_type, #object, object, #object?, #parent, #paste, #project, #rank, #read_only?, #reverse, #reverse!, #root_array, #same_shape?, #scalar?, #search, #search_index, #search_nearest, #search_nearest_index, #section, #section_linear, #seq, #seq!, #set, #shape, short, #size, sizeof, #sort, #sort!, #sort_addr, #str_format, #str_strptime, #swap_bytes, #swap_bytes!, #template, #time_strftime, #to_a, #to_ca, #to_s, #to_type, #trim, #trim!, #uint16, uint16, #uint32, uint32, #uint64, uint64, #uint8, uint8, #unmask, #unmask_copy, #unset, #unsigned?, #valid_addr?, #valid_index?, #value, #value_array?, #vectorized_fetch_linear_addr, #vectorized_find_linear_addr, #vectorized_section, #vectorized_section_linear, #virtual?, #where, wrap, wrap_readonly, wrap_writable
Constructor Details
This class inherits a constructor from CArray
Instance Method Details
#addr2addr0 ⇒ Object
yard: class CABlock def addr2addr0 (addr) end end
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'ext/ca_obj_block.c', line 822
static VALUE
rb_cb_addr2addr0 (VALUE self, VALUE raddr)
{
CABlock *cb;
ca_size_t addr = NUM2SIZE(raddr);
ca_size_t idx[CA_RANK_MAX];
int8_t i;
TypedData_Get_Struct(self, CABlock, &cablock_data_type, cb);
ca_addr2index((CArray*)cb, addr, idx);
addr = 0;
for (i=0; i<cb->ndim; i++) {
addr *= cb->size0[i];
addr += cb->start[i] + idx[i] * cb->step[i];
}
return SIZE2NUM(addr + cb->offset);
}
|
#count ⇒ Object
#idx2addr0 ⇒ Object
yard: class CABlock def idx2addr0 (idx) end end
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
# File 'ext/ca_obj_block.c', line 790
static VALUE
rb_cb_idx2addr0 (int argc, VALUE *argv, VALUE self)
{
CABlock *cb;
ca_size_t addr;
int8_t i;
ca_size_t idxi;
TypedData_Get_Struct(self, CABlock, &cablock_data_type, cb);
if ( argc != cb->ndim ) {
rb_raise(rb_eArgError,
"invalid # of arguments (should be <%i>)", cb->ndim);
}
addr = 0;
for (i=0; i<cb->ndim; i++) {
idxi = NUM2SIZE(argv[i]);
CA_CHECK_INDEX(idxi, cb->dim[i]);
addr = cb->size0[i] * addr + cb->start[i] + idxi * cb->step[i];
}
return SIZE2NUM(addr + cb->offset);
}
|
#index2addr0 ⇒ Object
yard: class CABlock def idx2addr0 (idx) end end
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
# File 'ext/ca_obj_block.c', line 790
static VALUE
rb_cb_idx2addr0 (int argc, VALUE *argv, VALUE self)
{
CABlock *cb;
ca_size_t addr;
int8_t i;
ca_size_t idxi;
TypedData_Get_Struct(self, CABlock, &cablock_data_type, cb);
if ( argc != cb->ndim ) {
rb_raise(rb_eArgError,
"invalid # of arguments (should be <%i>)", cb->ndim);
}
addr = 0;
for (i=0; i<cb->ndim; i++) {
idxi = NUM2SIZE(argv[i]);
CA_CHECK_INDEX(idxi, cb->dim[i]);
addr = cb->size0[i] * addr + cb->start[i] + idxi * cb->step[i];
}
return SIZE2NUM(addr + cb->offset);
}
|
#initialize_copy ⇒ Object
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
# File 'ext/ca_obj_block.c', line 717
static VALUE
rb_cb_initialize_copy (VALUE self, VALUE other)
{
CABlock *ca, *cs;
ca_size_t shrink[CA_RANK_MAX];
int8_t i;
TypedData_Get_Struct(self, CABlock, &cablock_data_type, ca);
TypedData_Get_Struct(other, CABlock, &cablock_data_type, cs);
for (i=0; i<cs->ndim; i++) {
shrink[i] = 0;
}
ca_block_setup(ca, cs->parent,
cs->ndim, cs->size0, cs->start, cs->step, cs->count, cs->offset);
/* CHECK ME : other.parent instead of other ? */
rb_ca_set_parent(self, rb_ca_parent(other));
rb_ca_data_type_inherit(self, rb_ca_parent(other));
return self;
}
|
#move ⇒ Object
yard: class CABlock def move (*index) end end
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
# File 'ext/ca_obj_block.c', line 851
static VALUE
rb_cb_move (int argc, VALUE *argv, VALUE self)
{
CABlock *cb;
ca_size_t start;
int8_t i;
TypedData_Get_Struct(self, CABlock, &cablock_data_type, cb);
if ( argc != cb->ndim ) {
rb_raise(rb_eArgError, "invalid # of arguments");
}
ca_update_mask(cb);
for (i=0; i<cb->ndim; i++) {
start = NUM2SIZE(argv[i]);
if ( start < 0 ) {
start += cb->size0[i];
}
if ( start < 0 || start + (cb->dim[i]-1) * cb->step[i] >= cb->size0[i] ) {
rb_raise(rb_eArgError, "%i-th index out of range", i);
}
cb->start[i] = start;
if ( cb->mask ) {
((CABlock*)(cb->mask))->start[i] = start;
}
}
return self;
}
|
#offset ⇒ Object
775 776 777 778 779 780 781 |
# File 'ext/ca_obj_block.c', line 775
static VALUE
rb_cb_offset (VALUE self)
{
CABlock *cb;
TypedData_Get_Struct(self, CABlock, &cablock_data_type, cb);
return SIZE2NUM(cb->offset);
}
|