Skip to content

norm="ortho" does not take into account the actual transformed axes #336

Description

@vincefn

Using norm="ortho" the array norm should be preserved but it is not:

import numpy as np
import mkl_fft

s = 16,18
ax = 0,

a = np.random.uniform(0,1,s) + 1j * np.random.uniform(0,1,s)
a /= np.sqrt((abs(a)**2).sum()) # normalise

a_np = np.fft.fftn(a, axes=ax, norm="ortho")
a_mkl = mkl_fft.fftn(a, axes=ax, norm="ortho")

print(f"  Array norm: {(abs(a)**2).sum():.6f}")
print(f" np-fft norm: {(abs(a_np)**2).sum():.6f}")
print(f"mkl_fft norm: {(abs(a_mkl)**2).sum():.6f}")

Gives:

  Array norm: 1.000000
 np-fft norm: 1.000000
mkl_fft norm: 0.055556

The ratio of the norms here is 18, the size of the non-transformed axis. So norm="ortho" does not take into account the actual list of transformed axes.

Tested with numpy 2.3.5 and mkl_fft 2.2.1, all from conda-forge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions