# Path: cubical/kernels/generics.py
# def compute_2x2_inverse(x, xinv, flags, eps, flagbit):
# def compute_diag_inverse(x, xinv, flags, eps, flagbit):
# def compute_chisq(r, chisq):
# def compute_chisq_diag(r, chisq):
# def compute_chisq_offdiag(r, chisq):


from builtins import range
from numba import jit, prange
from cubical.kernels import generics
import numpy as np
import cubical.kernels
    broadcast_freqs = np.array([f//f_int for f in range(n_fre)])
    broadcast_dirs = np.array([d%g_dir for d in range(n_dir)])

    for aa in prange(n_ant):
        for t in range(n_tim):
            bt = broadcast_times[t]
            for f in range(n_fre):
                bf = broadcast_freqs[f]
                for d in range(n_dir):
                    bd = broadcast_dirs[d]

                    g00 = g[d,t,f,aa,0,0]
                    g01 = g[d,t,f,aa,0,1]
                    g10 = g[d,t,f,aa,1,0]
                    g11 = g[d,t,f,aa,1,1]

                    g_next00 = g_next[bd,bt,bf,aa,0,0]
                    g_next01 = g_next[bd,bt,bf,aa,0,1]
                    g_next10 = g_next[bd,bt,bf,aa,1,0]
                    g_next11 = g_next[bd,bt,bf,aa,1,1]

                    g[d,t,f,aa,0,0] = (g00*g_next00 + g01*g_next10)
                    g[d,t,f,aa,0,1] = (g00*g_next01 + g01*g_next11)
                    g[d,t,f,aa,1,0] = (g10*g_next00 + g11*g_next10)
                    g[d,t,f,aa,1,1] = (g10*g_next01 + g11*g_next11)

# Map the J^H.J inversion method to a generic inversion.
compute_jhjinv = generics.compute_2x2_inverse

# Map inversion to generic 2x2 inverse.

# Path: cubical/kernels/generics.py
# def compute_2x2_inverse(x, xinv, flags, eps, flagbit):
# def compute_diag_inverse(x, xinv, flags, eps, flagbit):
# def compute_chisq(r, chisq):
# def compute_chisq_diag(r, chisq):
# def compute_chisq_offdiag(r, chisq):


# Path: cubical/kernels/full_complex.py
from builtins import range
from numba import jit, prange
from cubical.kernels import generics
import numpy as np
import cubical.kernels

    broadcast_freqs = np.array([f//f_int for f in range(n_fre)])
    broadcast_dirs = np.array([d%g_dir for d in range(n_dir)])

    for aa in prange(n_ant):
        for t in range(n_tim):
            bt = broadcast_times[t]
            for f in range(n_fre):
                bf = broadcast_freqs[f]
                for d in range(n_dir):
                    bd = broadcast_dirs[d]

                    g00 = g[d,t,f,aa,0,0]
                    g01 = g[d,t,f,aa,0,1]
                    g10 = g[d,t,f,aa,1,0]
                    g11 = g[d,t,f,aa,1,1]

                    g_next00 = g_next[bd,bt,bf,aa,0,0]
                    g_next01 = g_next[bd,bt,bf,aa,0,1]
                    g_next10 = g_next[bd,bt,bf,aa,1,0]
                    g_next11 = g_next[bd,bt,bf,aa,1,1]

                    g[d,t,f,aa,0,0] = (g00*g_next00 + g01*g_next10)
                    g[d,t,f,aa,0,1] = (g00*g_next01 + g01*g_next11)
                    g[d,t,f,aa,1,0] = (g10*g_next00 + g11*g_next10)
                    g[d,t,f,aa,1,1] = (g10*g_next01 + g11*g_next11)

# Map the J^H.J inversion method to a generic inversion.
compute_jhjinv = generics.compute_2x2_inverse

# Map inversion to generic 2x2 inverse.

invert_gains = generics.compute_2x2_inverse