Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add nmatrix buffer support to slicing
  • Loading branch information
Uditgulati committed Mar 30, 2021
commit c6f6b0cf5c8fe6e2600f597d6905623b9c7ff121
6 changes: 3 additions & 3 deletions ext/accessors.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ VALUE nm_accessor_get(int argc, VALUE* argv, VALUE self){
{
if(is_slice(nmat, argv)){

nmatrix* slice = ALLOC(nmatrix);
nmatrix_buffer* slice = ALLOC(nmatrix_buffer);
slice->dtype = nmat->dtype;
slice->stype = nmat->stype;
slice->mat = nmat;

get_slice(nmat, lower_indices, upper_indices, slice);

return TypedData_Wrap_Struct(NMatrix, &nm_data_type, slice);
return TypedData_Wrap_Struct(NMatrix, &nm_buffer_data_type, slice);

//return a slice
}
Expand Down
3 changes: 2 additions & 1 deletion ext/ruby_nmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static const rb_data_type_t nm_data_type = {

typedef struct NMATRIX_BUFFER_STRUCT
{
nm_dtype dtype;
size_t count;
size_t ndims;
size_t* shape;
Expand Down Expand Up @@ -537,7 +538,7 @@ void get_dense_from_dia(const void* data_t, const size_t rows,
void* elements_t, nm_dtype);

//forwards for internally used functions
void get_slice(nmatrix* nmat, size_t* lower, size_t* upper, nmatrix* slice);
void get_slice(nmatrix* nmat, size_t* lower, size_t* upper, nmatrix_buffer* slice);
size_t get_index(nmatrix* nmat, VALUE* indices);


Expand Down
Loading