First-principles calculations of optical and electronic properties of pure and Sm3+-doped TiO2