BOOST_FORCEINLINE static void doit2(const T& a, value_type& b, Out0& r) { r.resize(extent(a)); typedef typename A0::index_type index_type; typedef table<value_type, index_type> result_type; bool is_ltz_b = is_ltz(b); if(is_ltz(b)) b = -b; value_type m = nt2::trunc(b); value_type f = b-m; result_type q, t; // tie(q, t) = schur(a,'N'/*"complex"*/); // t is complex schur form. result_type e, v; if (false && isdiagonal(t)) { t = nt2::from_diag(nt2::pow(diag_of(t), m)); if(is_ltz_b) t = nt2::inv(t); r = nt2::mtimes(q, nt2::mtimes(t, nt2::trans(nt2::conj(q)))); return; } else { //use iterative method r = nt2::eye(nt2::size(a), meta::as_<value_type>()); result_type rf = r; if (m) { result_type a00 = a; while (m >= nt2::One<value_type>()) { if (nt2::is_odd(m)) { r = nt2::mtimes(a00, r); } a00 = nt2::mtimes(a00, a00); m = nt2::trunc(m/2); //Half<value_type>(); or >> 1 } } if(!f) { if(is_ltz_b) r = nt2::inv(r); return; } else { result_type a00 = nt2::sqrtm(a); value_type thresh = nt2::Half<value_type>(); while (f > Zero<value_type>()) { if (f >= thresh) { rf = nt2::mtimes(rf, a00); f -= thresh; } thresh *= nt2::Half<value_type>(); a00 = nt2::sqrtm(a00); } } r= nt2::mtimes(r, rf); if(is_ltz_b) r = nt2::inv(r); } }
static int rectriangulate (item_t *itemp, point_t *pp, int pn) { int i, ip1, ip2; int ccwres; again: if (pn > 3) { for (i = 0; i < pn; i++) { ip1 = (i + 1) % pn; ip2 = (i + 2) % pn; if ((ccwres = ccw (pp[i], pp[ip1], pp[ip2])) == ISCW) continue; if (ccwres == ISON) { for (i = ip1; i < pn - 1; i++) pp[i] = pp[i + 1]; pn--; goto again; } else if (isdiagonal (i, ip2, pp, pn)) { if (!gettri (itemp, pp[i], pp[ip1], pp[ip2])) { SUwarning (1, "rectriangulate", "gettri failed (1)"); return -1; } for (i = ip1; i < pn - 1; i++) pp[i] = pp[i + 1]; rectriangulate (itemp, pp, pn - 1); return 0; } } SUwarning (0, "rectriangulate", "failed for %d points", pn); for (i = 0; i < pn; i++) SUwarning (0, "rectriangulate", "%d %f %f", i, pp[i].x, pp[i].y); } else if (pn == 3) { if (!gettri (itemp, pp[0], pp[1], pp[2]) == -1) { SUwarning (1, "rectriangulate", "gettri failed (2)"); return -1; } } return 0; }
int check_win(char *board) { return (ishorizontal(board) || isvertical(board) || isdiagonal(board)); }