prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  ihfft
  
  
  </issue>
  <code>
  [start of ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py]
  1 import ivy
  2 from ivy.functional.frontends.numpy.func_wrapper import to_ivy_arrays_and_back
  3 from ivy.func_wrapper import with_unsupported_dtypes
  4 
  5 
  6 @to_ivy_arrays_and_back
  7 def ifft(a, n=None, axis=-1, norm=None):
  8     a = ivy.array(a, dtype=ivy.complex128)
  9     if norm is None:
  10         norm = "backward"
  11     return ivy.ifft(a, axis, norm=norm, n=n)
  12 
  13 
  14 @to_ivy_arrays_and_back
  15 @with_unsupported_dtypes({"1.24.3 and below": ("float16",)}, "numpy")
  16 def ifftshift(x, axes=None):
  17     x = ivy.asarray(x)
  18 
  19     if axes is None:
  20         axes = tuple(range(x.ndim))
  21         shift = [-(dim // 2) for dim in x.shape]
  22     elif isinstance(
  23         axes,
  24         (int, type(ivy.uint8), type(ivy.uint16), type(ivy.uint32), type(ivy.uint64)),
  25     ):
  26         shift = -(x.shape[axes] // 2)
  27     else:
  28         shift = [-(x.shape[ax] // 2) for ax in axes]
  29 
  30     roll = ivy.roll(x, shift, axis=axes)
  31 
  32     return roll
  33 
  34 
  35 @to_ivy_arrays_and_back
  36 def fft(a, n=None, axis=-1, norm=None):
  37     return ivy.fft(ivy.astype(a, ivy.complex128), axis, norm=norm, n=n)
  38 
  39 
  40 @to_ivy_arrays_and_back
  41 @with_unsupported_dtypes({"1.24.3 and below": ("float16",)}, "numpy")
  42 def fftshift(x, axes=None):
  43     x = ivy.asarray(x)
  44 
  45     if axes is None:
  46         axes = tuple(range(x.ndim))
  47         shift = [(dim // 2) for dim in x.shape]
  48     elif isinstance(
  49         axes,
  50         (int, type(ivy.uint8), type(ivy.uint16), type(ivy.uint32), type(ivy.uint64)),
  51     ):
  52         shift = x.shape[axes] // 2
  53     else:
  54         shift = [(x.shape[ax] // 2) for ax in axes]
  55 
  56     roll = ivy.roll(x, shift, axis=axes)
  57 
  58     return roll
  59 
  60 
  61 @with_unsupported_dtypes({"1.9.0 and below": ("float16",)}, "torch")
  62 @to_ivy_arrays_and_back
  63 def rfft(a, n=None, axis=-1, norm=None):
  64     if norm is None:
  65         norm = "backward"
  66     a = ivy.array(a, dtype=ivy.float64)
  67     return ivy.dft(a, axis=axis, inverse=False, onesided=True, dft_length=n, norm=norm)
  68 
  69 
  70 @with_unsupported_dtypes({"2.4.2 and below": ("int",)}, "paddle")
  71 @to_ivy_arrays_and_back
  72 def fftfreq(n, d=1.0):
  73     if not isinstance(
  74         n, (int, type(ivy.int8), type(ivy.int16), type(ivy.int32), type(ivy.int64))
  75     ):
  76         raise ValueError("n should be an integer")
  77 
  78     N = (n - 1) // 2 + 1
  79     val = 1.0 / (n * d)
  80     results = ivy.empty(tuple([n]), dtype=int)
  81 
  82     p1 = ivy.arange(0, N, dtype=int)
  83     results[:N] = p1
  84     p2 = ivy.arange(-(n // 2), 0, dtype=int)
  85     results[N:] = p2
  86 
  87     return results * val
  88
  [end of ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
  --- a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
  +++ b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
  @@ -3,6 +3,23 @@
   from ivy.func_wrapper import with_unsupported_dtypes
   
   
  +_SWAP_DIRECTION_MAP = {
  +    None: "forward",
  +    "backward": "forward",
  +    "ortho": "ortho",
  +    "forward": "backward",
  +}
  +
  +
  +def _swap_direction(norm):
  +    try:
  +        return _SWAP_DIRECTION_MAP[norm]
  +    except KeyError:
  +        raise ValueError(
  +            f'Invalid norm value {norm}; should be "backward", "ortho" or "forward".'
  +        ) from None
  +
  +
   @to_ivy_arrays_and_back
   def ifft(a, n=None, axis=-1, norm=None):
       a = ivy.array(a, dtype=ivy.complex128)
  @@ -67,6 +84,17 @@
       return ivy.dft(a, axis=axis, inverse=False, onesided=True, dft_length=n, norm=norm)
   
   
  +@to_ivy_arrays_and_back
  +@with_unsupported_dtypes({"1.12.0 and below": ("float16",)}, "numpy")
  +def ihfft(a, n=None, axis=-1, norm=None):
  +    a = ivy.array(a, dtype=ivy.float64)
  +    if n is None:
  +        n = a.shape[axis]
  +    norm = _swap_direction(norm)
  +    output = ivy.conj(rfft(a, n, axis, norm=norm).ivy_array)
  +    return output
  +
  +
   @with_unsupported_dtypes({"2.4.2 and below": ("int",)}, "paddle")
   @to_ivy_arrays_and_back
   def fftfreq(n, d=1.0):
  
verification_info: {"golden_diff": "diff --git a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py\n--- a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py\n+++ b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py\n@@ -3,6 +3,23 @@\n from ivy.func_wrapper import with_unsupported_dtypes\n \n \n+_SWAP_DIRECTION_MAP = {\n+    None: \"forward\",\n+    \"backward\": \"forward\",\n+    \"ortho\": \"ortho\",\n+    \"forward\": \"backward\",\n+}\n+\n+\n+def _swap_direction(norm):\n+    try:\n+        return _SWAP_DIRECTION_MAP[norm]\n+    except KeyError:\n+        raise ValueError(\n+            f'Invalid norm value {norm}; should be \"backward\", \"ortho\" or \"forward\".'\n+        ) from None\n+\n+\n @to_ivy_arrays_and_back\n def ifft(a, n=None, axis=-1, norm=None):\n     a = ivy.array(a, dtype=ivy.complex128)\n@@ -67,6 +84,17 @@\n     return ivy.dft(a, axis=axis, inverse=False, onesided=True, dft_length=n, norm=norm)\n \n \n+@to_ivy_arrays_and_back\n+@with_unsupported_dtypes({\"1.12.0 and below\": (\"float16\",)}, \"numpy\")\n+def ihfft(a, n=None, axis=-1, norm=None):\n+    a = ivy.array(a, dtype=ivy.float64)\n+    if n is None:\n+        n = a.shape[axis]\n+    norm = _swap_direction(norm)\n+    output = ivy.conj(rfft(a, n, axis, norm=norm).ivy_array)\n+    return output\n+\n+\n @with_unsupported_dtypes({\"2.4.2 and below\": (\"int\",)}, \"paddle\")\n @to_ivy_arrays_and_back\n def fftfreq(n, d=1.0):\n", "issue": "ihfft\n\n", "before_files": [{"content": "import ivy\nfrom ivy.functional.frontends.numpy.func_wrapper import to_ivy_arrays_and_back\nfrom ivy.func_wrapper import with_unsupported_dtypes\n\n\n@to_ivy_arrays_and_back\ndef ifft(a, n=None, axis=-1, norm=None):\n    a = ivy.array(a, dtype=ivy.complex128)\n    if norm is None:\n        norm = \"backward\"\n    return ivy.ifft(a, axis, norm=norm, n=n)\n\n\n@to_ivy_arrays_and_back\n@with_unsupported_dtypes({\"1.24.3 and below\": (\"float16\",)}, \"numpy\")\ndef ifftshift(x, axes=None):\n    x = ivy.asarray(x)\n\n    if axes is None:\n        axes = tuple(range(x.ndim))\n        shift = [-(dim // 2) for dim in x.shape]\n    elif isinstance(\n        axes,\n        (int, type(ivy.uint8), type(ivy.uint16), type(ivy.uint32), type(ivy.uint64)),\n    ):\n        shift = -(x.shape[axes] // 2)\n    else:\n        shift = [-(x.shape[ax] // 2) for ax in axes]\n\n    roll = ivy.roll(x, shift, axis=axes)\n\n    return roll\n\n\n@to_ivy_arrays_and_back\ndef fft(a, n=None, axis=-1, norm=None):\n    return ivy.fft(ivy.astype(a, ivy.complex128), axis, norm=norm, n=n)\n\n\n@to_ivy_arrays_and_back\n@with_unsupported_dtypes({\"1.24.3 and below\": (\"float16\",)}, \"numpy\")\ndef fftshift(x, axes=None):\n    x = ivy.asarray(x)\n\n    if axes is None:\n        axes = tuple(range(x.ndim))\n        shift = [(dim // 2) for dim in x.shape]\n    elif isinstance(\n        axes,\n        (int, type(ivy.uint8), type(ivy.uint16), type(ivy.uint32), type(ivy.uint64)),\n    ):\n        shift = x.shape[axes] // 2\n    else:\n        shift = [(x.shape[ax] // 2) for ax in axes]\n\n    roll = ivy.roll(x, shift, axis=axes)\n\n    return roll\n\n\n@with_unsupported_dtypes({\"1.9.0 and below\": (\"float16\",)}, \"torch\")\n@to_ivy_arrays_and_back\ndef rfft(a, n=None, axis=-1, norm=None):\n    if norm is None:\n        norm = \"backward\"\n    a = ivy.array(a, dtype=ivy.float64)\n    return ivy.dft(a, axis=axis, inverse=False, onesided=True, dft_length=n, norm=norm)\n\n\n@with_unsupported_dtypes({\"2.4.2 and below\": (\"int\",)}, \"paddle\")\n@to_ivy_arrays_and_back\ndef fftfreq(n, d=1.0):\n    if not isinstance(\n        n, (int, type(ivy.int8), type(ivy.int16), type(ivy.int32), type(ivy.int64))\n    ):\n        raise ValueError(\"n should be an integer\")\n\n    N = (n - 1) // 2 + 1\n    val = 1.0 / (n * d)\n    results = ivy.empty(tuple([n]), dtype=int)\n\n    p1 = ivy.arange(0, N, dtype=int)\n    results[:N] = p1\n    p2 = ivy.arange(-(n // 2), 0, dtype=int)\n    results[N:] = p2\n\n    return results * val\n", "path": "ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py"}]}