typekey, theta from lib_mat

updated all elems, untested