Пример #1
0
def rdft_lu_solver(a,b,r=[]):
  (fra, fr) = rdft(a,r)
  frb       = fr.dot(b)
  (l,u) = lu.lu(fra)
  y     = lu.l_step(l,frb)
  x     = lu.u_step(u,y)
  return x
Пример #2
0
def rdft_lu_solver(a, b, r=[]):
    (fra, fr) = rdft(a, r)
    frb = fr.dot(b)
    (l, u) = lu.lu(fra)
    y = lu.l_step(l, frb)
    x = lu.u_step(u, y)
    return x
Пример #3
0
def rdft_lu_solver_with_lu(a,b,r=[]):
  (fra, fr) = rdft(a,r)
  frb       = fr.dot(b)
  fra_save  = np.array(fra)
  frb_save  = np.array(frb)
  (l,u) = lu.lu(fra)
  y     = lu.l_step(l,frb)
  x     = lu.u_step(u,y)
  return (x, l, u, fra_save, frb_save, fr)
Пример #4
0
def rdft_lu_solver_with_lu(a, b, r=[]):
    (fra, fr) = rdft(a, r)
    frb = fr.dot(b)
    fra_save = np.array(fra)
    frb_save = np.array(frb)
    (l, u) = lu.lu(fra)
    y = lu.l_step(l, frb)
    x = lu.u_step(u, y)
    return (x, l, u, fra_save, frb_save, fr)
Пример #5
0
def solve_gauss(a, b, x):
    (size, _) = a.shape
    g = rdft.generate_g(size)
    ga = g.dot(a)
    ga_save = np.array(ga)
    gb = g.dot(b)
    (l, u) = lu.lu(ga)
    y = lu.l_step(l, gb)
    x1 = lu.u_step(u, y)
    x2 = np.array(x1)
    x2 = iteration.iteration_another(a, l, u, g, b, x2, linalg.cond(ga))
    return (x2, ga, a, x1)
Пример #6
0
def solve_gauss(a,b,x):
  (size,_) = a.shape
  g   = rdft.generate_g(size)
  ga  = g.dot(a)
  ga_save  = np.array(ga)
  gb  = g.dot(b)
  (l,u) = lu.lu(ga)
  y     = lu.l_step(l,gb)
  x1    = lu.u_step(u,y)
  x2 = np.array(x1)
  x2  = iteration.iteration_another(a, l, u, g, b, x2, linalg.cond(ga))
  return (x2, ga, a, x1)
Пример #7
0
def iteration_step_result(a, l, u, b, x, a_cond):
  (size,_) = a.shape
  itera, itermax = 0, 1
  a_nrm = linalg.norm(a, float("inf"))
  x_nrm = linalg.norm(x, float("inf"))
  x_step_result = [x]
  cte   = math.log10(a_cond) * math.sqrt(size)/10
  r     = b - a.dot(x)
  r_nrm = linalg.norm(r, float("inf"))
  while itera < min(cte, itermax):
    y = lu.l_step(l, r)
    z = lu.u_step(u, y)
    x = x + z
    x_step_result.append(x)
    r = b - a.dot(x)
    x_nrm = linalg.norm(x, float("inf"))
    r_nrm = linalg.norm(r, float("inf"))
    itera = itera + 1
  return x_step_result
Пример #8
0
def solve_rdft_givens_both(a,b,x):
  (size,_) = a.shape
  f   = rdft.generate_f(size)
  r   = rdft.generate_r(size)
  g1  = givens.givens_generation(size)
  g2  = givens.givens_generation(size)
  fr  = f.dot(r)
  frg = fr.dot(g1)
  frgb = frg.dot(b)
  ag  = a.dot(g2)
  frgag = frg.dot(ag)
  (l,u) = lu.lu(frgag)
  y     = lu.l_step(l,frgb)
  z     = lu.u_step(u,y)
  x1    = g2.dot(z)
  x2  = np.array(x1)
  x2  = iteration.iteration_another(a, l, u, frg, b, x2, linalg.cond(frgag), g2)
  x2  = iteration.remove_imag(x2)
  return (x2, x1)
Пример #9
0
def iteration_another(a, l, u, fr, b, x, a_cond, rm=[]):
  (size,_) = a.shape
  itera, itermax = 0, 1
  a_nrm = linalg.norm(a, float("inf"))
  x_nrm = linalg.norm(x, float("inf"))
  #cte   = math.log10(a_cond) * math.sqrt(size)/10
  r     = fr.dot(b - a.dot(x))
  r_nrm = linalg.norm(r, float("inf"))
  while itera < itermax:
    y = lu.l_step(l, r)
    z = lu.u_step(u, y)
    if rm == []:
      x = x + z
    else:
      x = x + rm.dot(z)
    r = fr.dot(b - a.dot(x))
    x_nrm = linalg.norm(x, float("inf"))
    r_nrm = linalg.norm(r, float("inf"))
    itera = itera + 1
  return x
Пример #10
0
def solve_rdft_givens_both(a, b, x):
    (size, _) = a.shape
    f = rdft.generate_f(size)
    r = rdft.generate_r(size)
    g1 = givens.givens_generation(size)
    g2 = givens.givens_generation(size)
    fr = f.dot(r)
    frg = fr.dot(g1)
    frgb = frg.dot(b)
    ag = a.dot(g2)
    frgag = frg.dot(ag)
    (l, u) = lu.lu(frgag)
    y = lu.l_step(l, frgb)
    z = lu.u_step(u, y)
    x1 = g2.dot(z)
    x2 = np.array(x1)
    x2 = iteration.iteration_another(a, l, u, frg, b, x2, linalg.cond(frgag),
                                     g2)
    x2 = iteration.remove_imag(x2)
    return (x2, x1)
Пример #11
0
def lu_solver(a,b):
	(l,u,c) = plu(a,b)
	y     = lu.l_step(l,c)
	x     = lu.u_step(u,y)
	return x