Differential geometric models and optimization methods for dynamic analysis of electrocardiographic signals and the inverse problem of electrocardiography