Tested algorithm library from NXP Semiconductors on power metering. Link here (PDF)
High accuracy metering is an essential feature of an electronic power meter application because inaccurate metering can result in substantial amounts of lost revenue. Moreover, inaccurate metering can also undesirably result in overcharging to customers. The common sources of metering inaccuracies, or error sources in a meter, include the sensor devices, the sensor conditioning circuitry, the Analog Front-End (AFE), and the metering algorithm executed either in a digital processing engine or a microcontroller.