You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following codes seems to realize the function: when input a integer nk, we want to get the total number of species of the Zernike polynomial Z_{n}^{l} with limitation 1≤n≤nk.
int maxZernike(const int nk)
{
int maxZernike = 0;
int l = 0;
int ni = 0;
int m0 = 0;
int m1 = 0;
int m = 0;
for (ni = 1; ni <= nk; ni++)
{
m0 = ni - 2 * (int)(ni / 2);
m1 = m0 + 2 * (int)(ni / 2);
for (m = m0; m <= m1; m = m + 2)
{
l = l + 1;
if (m != 0)
l++;
}
}
return l;
}
However, we can easily know that the number of species of the Zernike polynomial Z_{n}^{l} for a fixed n is n+1, so the result is simply the summation from 2 to nk+1, so the code can be simplified as:
int maxZernike(const int nk)
{
int l = 0;
l = (nk+3)*nk/2;
return l;
}
The following code doesn't be used in any other codes, and the function it realizes is weird
(If we want to tick each Zernike polynomials with Noll's sequential indices, the yellow parts should be minus value.
void nmlznk(const int maxZnkOrder, int &maxZnkDim, int *&nznk, int *&mznk)
{
int maxZernike = 0;
int l = 0;
int ni = 0;
int m0 = 0;
int m1 = 0;
int m = 0;
// int lz = 0;
int j = 0;
// int nm = 0;
for (ni = 1; ni <= maxZnkOrder; ni++)
{
m0 = ni - 2 * (int)(ni / 2);
m1 = m0 + 2 * (int)(ni / 2);
for (m = m0; m <= m1; m = m + 2)
{
l = l + 1;
if (l >= 1)
{
nznk[l] = ni; // zernike系数从1开始储存
mznk[l] = m;
// lz = lznk_a(l, ni);
// lznk[l] = lz;
// cout << ni << m << lz << endl;
}
if (m != 0)
{
l = l + 1;
if (l >= 1)
{
nznk[l] = ni; // zernike系数从1开始储存
mznk[l] = m;
// lz = lznk_a(l, ni);
// lznk[l] = lz;
// nm = (ni - m) / 2;
// cout << ni << m << lz << endl;
}
}
if (l >= maxZnkDim)
{
maxZnkDim = l;
return;
}
}
}
}
The function mnznk actually realize the function we want, i.e. tick each Zernike polynomials with OSA/ANSI standard indices. By the way, the variable maxZnkDim actually realize the function in issue 1.
The following code doesn't be used in any other codes (judge whether the parities of l and [ni/2] are the same). Maybe useless
int lznk_a(const int l, const int ni)
{
int lz = 0;
if ((ni / 2) / 2 != (ni / 2) * 0.5)
{
if (l / 2 == l * 0.5)
{
lz = 0;
}
else
{
lz = 1;
}
}
else
{
if (l / 2 == l * 0.5)
{
lz = 1;
}
else
{
lz = 0;
}
}
return lz;
}
A question: Why do we use a homemade random number generation method instead of C++ 's built-in random number algorithm in function rdm_gauss. Here we generate a new random number with uniform distribution in range [0,1) by multiplying the seed (or old random numbers) with the number rq = pi^{8+pi}+pi and taking the decimal part of the result. Does the random number generated by this method conform to the uniform distribution and pass the autocorrelation test?
Line 49. I'm confused about the physical meaning of the variable INPUT.mgs. In case we consider Gaussian beam, shouldn't it take the value 1? The value 0 seems to be a uniform beam.
// set inIntensity
a02 = INPUT.a0 * INPUT.a0;
for (int i = 0; i < INPUT.n_grid; i++) {
x = (i + 1 - INPUT.n1) * INPUT.dxy0; // +不加1
x2 = x * x;
for (int j = 0; j < INPUT.n_grid; j++) {
y = (j + 1 - INPUT.n1) * INPUT.dxy0;
y2 = y * y;
r2 = x2 + y2;
if (r2 <= a02) {
--> opt.ur0[i][j] = exp(-1 * pow(r2 / a02, INPUT.mgs)); <--
opt.ui0[i][j] = 0;
}
}
}
The text was updated successfully, but these errors were encountered:
These two functions are really not used, because the code I got is available so I did not delete them.
You can change it to c++ 's built-in random number function. Refer to the commented code in ./light/source/ optical_fiele.cpp.
[2] ./light/source/Optical_field.cpp
Since the error of amplitude is not considered in the current study, the initial beam is simplified to a uniform beam.
[1] ./light/source/Zernike.cpp
However, we can easily know that the number of species of the Zernike polynomial Z_{n}^{l} for a fixed n is n+1, so the result is simply the summation from 2 to nk+1, so the code can be simplified as:
(If we want to tick each Zernike polynomials with Noll's sequential indices, the yellow parts should be minus value.
The function mnznk actually realize the function we want, i.e. tick each Zernike polynomials with OSA/ANSI standard indices. By the way, the variable maxZnkDim actually realize the function in issue 1.
[2] ./light/source/Optical_field.cpp
The text was updated successfully, but these errors were encountered: