From f1f4fc8a632733b3d658d350de31c5e3bf531310 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Fri, 6 Oct 2023 15:40:08 +0800 Subject: [PATCH] ses_split_r(), ses_merge_r() --- ses_core.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/ses_core.h b/ses_core.h index c06f3a1..0a11187 100644 --- a/ses_core.h +++ b/ses_core.h @@ -164,4 +164,44 @@ static inline void ses_split_i(double* a, double* ja, double ta, double jta, dou *ja = (jt * r - t * jr) / R; } +static inline void ses_split_r(double* r1, double* jr1, double tr, double jtr, double r0, double jr0) +{ + double R; + + R = tr * tr + jtr * jtr; + tr /= R; + jtr /= -R; + + R = r0* r0 + jr0 * jr0; + r0 /= R; + jr0 /= -R; + + tr -= r0; + jtr -= jr0; + + R = tr * tr + jtr * jtr; + *r1 = tr / R; + *jr1 = jtr / -R; +} + +static inline void ses_merge_r(double* tr, double* jtr, double r0, double jr0, double r1, double jr1) +{ + double R; + + R = r0* r0 + jr0 * jr0; + r0 /= R; + jr0 /= -R; + + R = r1* r1 + jr1 * jr1; + r1 /= R; + jr1 /= -R; + + r0 += r1; + jr0 += jr1; + + R = r0* r0 + jr0 * jr0; + *tr = r0 / R; + *jtr = jr0 / -R; +} + #endif -- 2.25.1