Re-implement next_k_array
; add k_array_rank
#379
Merged
next_k_array
; add k_array_rank
#379