#fix arithmetic bug, and add the transpose function