Magnetization dynamics of single-domain nanodots and minimum energy dissipation during either irreversible or reversible switching