Bug fix of sparse vector conversion

Fixed a small bug caused by the inconsistency of index/data array size and vector length.