Stellar and solar magnetic fields