add check of matrix_type to from_json