Пример #1
0
  def set_optimal_weights(self, *args):
    """Set the optimal (linear) weights."""

    t = templates[self.lang]

    super(FunctionGenerator, self).set_optimal_weights(*args)

    self.global_omega = {}
    pm = ['p', 'm']
    for l in range(self.n):
      if self.split[l]:
        for r in range(self.k):
          for s in (0, 1):
            self.global_omega[l,r,s] = symbol(t['omega'].format(l=l, r=r, s=s))

      else:
        for r in range(self.k):
            self.global_omega[l,r] = symbol(t['omega'].format(l=l, r=r, s=0))
Пример #2
0
  def set_reconstruction_coefficients(self, *args):
    """Set the reconstruction coefficients."""

    t = templates[self.lang]

    super(FunctionGenerator, self).set_reconstruction_coefficients(*args)

    self.global_f_star = {}
    for l in range(self.n):
      self.global_f_star[l] = symbol(t['fs'].format(l=l))
Пример #3
0
  def set_smoothness(self, *args):
    """Set the smoothness indicator coefficients."""

    t = templates[self.lang]

    super(FunctionGenerator, self).set_smoothness(*args)

    self.global_sigma = {}
    for r in range(0, self.k):
      self.global_sigma[r] = symbol(t['sigma'].format(r=r))
Пример #4
0
  def _set_vars(self, dest, source):
    """Set local/global variables from global/local variables."""

    src = []
    for k in sorted(source.keys()):
      if isinstance(k, tuple) or isinstance(k, int):
        d = dest[k]
        if not isinstance(dest[k], Symbol):
          d = symbol(dest[k])
        src.append(self.assign(d, source[k]))
    return '\n'.join(src)
Пример #5
0
  def set_nonuniform(self, k, n):
    """Set reconstruction coeffs, optimal weights, and smoothness
    coeffs to symbols appropriate for non-uniform reconstructions."""

    t = templates[self.lang]
    self.nonuniform = True

    self.k = k
    self.n = n

    # reconstruction coeffs
    c = { 'n': n, 'k': k }
    for l in range(n):
      for r in range(k):
        for j in range(k):
          c[l,r,j] = symbol(t['coeffs'].format(l=l, r=r, j=j))

    self.set_reconstruction_coefficients(c)

    # optimal weights
    varpi = { 'n': n, 'k': k }
    split = { 'n': n }
    for l in range(n):
      split[l] = False

      for r in range(k):
        varpi[l,r] = symbol(t['varpi'].format(l=l, r=r))

    self.set_optimal_weights(varpi, split)

    # smoothness coeffs
    beta = { 'k': k }
    for r in range(k):
      for m in range(k):
        for n in range(m, k):
          beta[r,m,n] = symbol(t['beta'].format(r=r, m=m, n=n))

    self.set_smoothness(beta)