add multithread and singlethread matrix generation