using matrix numpy api to do some stuff. still slow