Ionic and biradical mechanisms in thermal and photo cis-trans isomerizations