Calculation of the metric in the Hilbert space of a -symmetric model via the spectral theorem