Transient optical properties of dielectrics and semiconductors excited by an ultrashort laser pulse