Exemplo n.º 1
0
def lookup_lrange_cache(cache, lmin, lmax):
    """
    Looks up a (possible slice of) a cached matrix in a list of the form
    [ (lmin, lmax, M), (lmin, lmax, M), ... ]. M is assumed to be stored
    as a covar-like matrix in real form.

    Returns None if not found.
    """
    for it_lmin, it_lmax, M in cache:
        if it_lmin <= lmin and it_lmax >= lmax:
            start = lm_to_idx_full(lmin, -lmin, it_lmin)
            stop = lm_to_idx_full(lmax, lmax, it_lmin) + 1
            return M[start:stop, start:stop]
    return None
Exemplo n.º 2
0
 def set_l_range(self, lmin, lmax):
     self.lmin = lmin
     self.lmax = lmax
     # Update lmin, lmax
     self.lstarts[0] = lmin
     self.lstarts[-1] = lmax + 1
     
     # Now that lmin is given, it is possible to convert
     # the lstarts given in the constructors to splitting indices.
     # Each index indicates the start point of that preconditioner.
     self.split_indices = [lm_to_idx_full(l, -l, lmin)
                           for l in self.lstarts]
     self.child_start_stop = []
     # Make sure to drop any unused children
     idx_stop = lm_to_idx_full(lmax, lmax, lmin) + 1
     for idx, child in enumerate(self.children):
         if self.lstarts[idx] > lmax:
             break
         lstop = min(self.lstarts[idx + 1] - 1, lmax)
         child.set_l_range(self.lstarts[idx], lstop)
         self.child_start_stop.append(
             (child, self.split_indices[idx],
              min(self.split_indices[idx + 1], idx_stop)))