Looks like the answer to the question (and double checking my sources) helped me solve the answer.
replacements:
rb_ary_push(outputArr, DBL2NUM(X[i][0]));
with:
x[i][0]=NUM2DBL(rb_ary_pop(inputArr));
seemed to do the trick :)
I still wonder if this is the most efficient way to do something, but it works.
source share