Ab initio calculations of the electronic and optical properties of group IV semiconductor nanostructures embedded in different matrices