The metric computation code