{"id":422,"date":"2019-11-11T06:07:35","date_gmt":"2019-11-11T14:07:35","guid":{"rendered":"http:\/\/fx-td.com\/houdiniandchill\/?p=422"},"modified":"2019-11-11T06:07:36","modified_gmt":"2019-11-11T14:07:36","slug":"archived-post-by-ajk48n-2","status":"publish","type":"post","link":"http:\/\/fx-td.com\/houdiniandchill\/2019\/11\/11\/archived-post-by-ajk48n-2\/","title":{"rendered":"Archived post by ajk48n"},"content":{"rendered":"<p class=\"\">For future reference, here&#8217;s a tridiagonal solver in vex (very much not optimised, but it&#8217;s based on some Mathematica code) @jake rice \ud83d\ude2e<br \/>\n&#8220;` #include <math.h> #include <complex.h><br \/>\nfunction complex cdiv(complex a, b) {     complex conjB = conj(b);     complex num = cmult(a, conjB);     complex den = cmult(b, conjB);     complex ans = cmult(num, CMPLX(1.0\/den.real, 0));     return ans; }<br \/>\nfunction complex[] TDMAsolver(complex a[], b[], c[], d[]) {     int nf = len(d); \/\/ number of equations     complex p[];     complex q[];          for (int i=0;i<nf;i++)     {         p[i] = CMPLX(0, 0);         q[i] = CMPLX(0,0);     }          p[0] = cdiv(c[0], b[0]);     q[0] = cdiv(d[0], b[0]);          for (int i=1;i<nf;i++)     {         complex divisor = csub( b[i], cmult(a[i-1], p[i-1]));         complex temp_p = CMPLX(0,0);         if (i < nf-1)             temp_p = c[i];                      p[i] = cdiv(temp_p, divisor);                  complex temp_q = csub(d[i], cmult(a[i-1], q[i-1]));                  q[i] = cdiv(temp_q, divisor);     }          for (int i=nf-2; i>=0; i&#8211;)     {         q[i] = csub(q[i], cmult(p[i], q[i+1]));     }          return q; } &#8220;`<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For future reference, here&#8217;s a tridiagonal solver in vex (very much not optimised, but it&#8217;s based on some Mathematica code) @jake rice \ud83d\ude2e &#8220;` #include #include function complex cdiv(complex a, b) { complex conjB = conj(b); complex num = cmult(a, conjB); complex den = cmult(b, conjB); complex ans = cmult(num, CMPLX(1.0\/den.real, 0)); return ans; } &hellip; <a href=\"http:\/\/fx-td.com\/houdiniandchill\/2019\/11\/11\/archived-post-by-ajk48n-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Archived post by ajk48n<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts\/422"}],"collection":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/comments?post=422"}],"version-history":[{"count":0,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/posts\/422\/revisions"}],"wp:attachment":[{"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/media?parent=422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/categories?post=422"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fx-td.com\/houdiniandchill\/wp-json\/wp\/v2\/tags?post=422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}