moved matrix transpose to C; much faster