A direct method of determining complex depth profiles of residual stresses in thin films on a nanoscale