Skip to content
Browse files

bugfix: length was multiplied by byte length

  • Loading branch information...
1 parent 2556957 commit 28006e0fb9c9293d210b2201f7c8ef50f4ebee1f @seiya committed Mar 26, 2012
Showing with 1 addition and 7 deletions.
  1. +1 −7 ext/mpi/mpi.c
View
8 ext/mpi/mpi.c
@@ -16,6 +16,7 @@
struct NARRAY *a;\
GetNArray(rb_obj, a);\
buffer = (void*)(a->ptr);\
+ if (len==0) len = a->total;\
switch (a->type) {\
case NA_BYTE:\
typ = MPI_BYTE;\
@@ -24,37 +25,30 @@
case NA_SINT:\
typ = MPI_SHORT;\
buffer = (void*)((char*)buffer + off*4);\
- len *= 4;\
break;\
case NA_LINT:\
typ = MPI_LONG;\
buffer = (void*)((char*)buffer + off*8);\
- len *= 8;\
break;\
case NA_SFLOAT:\
typ = MPI_FLOAT;\
buffer = (void*)((char*)buffer + off*4);\
- len *= 4;\
break;\
case NA_DFLOAT:\
typ = MPI_DOUBLE;\
buffer = (void*)((char*)buffer + off*8);\
- len *= 8;\
break;\
case NA_SCOMPLEX:\
typ = MPI_2COMPLEX;\
buffer = (void*)((char*)buffer + off*8);\
- len *= 8;\
break;\
case NA_DCOMPLEX:\
typ = MPI_2DOUBLE_COMPLEX;\
buffer = (void*)((char*)buffer + off*16);\
- len *= 16;\
break;\
default:\
rb_raise(rb_eArgError, "narray type is invalid");\
}\
- if (len==0) len = a->total;\
} else {\
rb_raise(rb_eArgError, "Only String and NArray are supported");\
}\

0 comments on commit 28006e0

Please sign in to comment.
Something went wrong with that request. Please try again.