Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orthogonal normalization #175

Open
davebayer opened this issue May 26, 2024 · 4 comments
Open

Orthogonal normalization #175

davebayer opened this issue May 26, 2024 · 4 comments

Comments

@davebayer
Copy link

davebayer commented May 26, 2024

Hi,

I was wandering if it would be possible to extend the normalization options to include orthogonal normalization for both DFT and DTT. The behaviour should be like:

  1. DFT: multiply the output of forward or inverse transformation of size N by $\frac{1}{\sqrt{N}}$.
  2. DTT: it is a bit more compilcated as it depends on the DTT type. Before you multiply the output by $\frac{1}{\sqrt{N}}$, for each 1D subtransform:
    • DCT-I: multiply first and last input value by $\sqrt{2}$, multiply first and last output value by $\frac{1}{\sqrt{2}}$.
    • DCT-II : multiply first output value by $\frac{1}{\sqrt{2}}$.
    • DCT-III: multiply first input value by $\sqrt{2}$.
    • DCT-IV: nothing.
    • DST-I: nothing.
    • DST-II: multiply last output value by $\frac{1}{\sqrt{2}}$.
    • DST-III: multiply last input value by $\sqrt{2}$.
    • DST-IV: nothing.

I would suggest adding an enum to specify the type of the normalization:

typedef enum VkFFTNormalize
{
  VKFFT_NORMALIZE_NONE       = 0, // Do not normalize.
  VKFFT_NORMALIZE_UNITARY    = 1, // 1/N normalization applied to inverse transformation.
  VKFFT_NORMALIZE_ORTHOGONAL = 2  // 1/sqrt(N) normalization applied to both forward and inverse transformations, applies aditional operations to DTT transforms to make the transformation orthogonal.
} VkFFTNormalize;

In the VkFFTConfiguration structure I would suggest either to change the normalization member datatype to VkFFTNormalize datatype or just stick to the original pfUINT:

typedef struct {

  // ...

  pfUINT normalize; //normalize inverse transform (0 - off, 1 - on)
  // 1. -> VkFFTNormalize normalize;
  // 2. -> pfUINT normalize;

  // ...

} VkFFTConfiguration;

Both of the solutions work without warnings. See the code example.

Thanks.

David

@DTolm
Copy link
Owner

DTolm commented Jun 6, 2024

Hello,

I will add an option to change configuration.normalize to support orthogonal normalization (need to be careful with the real transforms there). Another thing is as there are too many ways to scale the numbers, maybe just making full support for callbacks is a good idea?

Best regards,
Dmitrii

@davebayer
Copy link
Author

davebayer commented Jun 12, 2024

Hi Dmitrii,

thanks for your response. The callbacks would definitely solve the problem with scaling. However I still have the feeling that when you want to do only the normalization, it would be much easier just to specify the forward/inverse scale or use the solution I proposed instead of studying and writing own callbacks. I don't mind writing callbacks myself, but I think there will be people having problems understanding them eventhough all they wanted was to run a normalized transformation.

I'm curious about your thoughts on this matter.

Thanks!

David

@DTolm
Copy link
Owner

DTolm commented Jun 13, 2024

Hello,

This is a valid point, I will try to add this before the next release.

Best regards,
Dmitrii

@davebayer
Copy link
Author

Perfect, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants