FastNFT / FNFT

Fast numerical computation of (inverse) nonlinear Fourier transforms
https://fastnft.github.io/FNFT/
GNU General Public License v2.0
42 stars 12 forks source link

Usage of const variables #27

Open marbre opened 6 years ago

marbre commented 6 years ago

There are several functions, where variables are declared, assigned a few lines later and not reassigned later on. E.g. the variable eps_t in refine_roots_newton:

    REAL re_bound_val, im_bound_val, eps_t;
    UINT trunc_index;
    trunc_index = D;
    eps_t = (T[1] - T[0])/(D - 1);

Does it respect your style if refactored as follows?

    REAL re_bound_val, im_bound_val;
    UINT trunc_index;
    trunc_index = D;
    const REAL eps_t = (T[1] - T[0])/(D - 1);
wahls commented 6 years ago

Yes, const-correctness is considered good practice.

It is also fine if the variable is declared where it is needed (instead of in the beginning).

marbre commented 6 years ago

Yeah, that was actually the question if the assignment should either move up to where the variables are declared or if the declaration might move down (keeping the position of the assignment untouched). A PR will follow shortly if all tests pass on my machine.