mat_vect
finished porting cm