49 nr_int32_t boundary = 1 << 30;
50 nr_int32_t current = 1;
51 if (x >= boundary)
return boundary;
52 while (current < x) current <<= 1;
58 nr_double_t
emi::f_ideal (nr_double_t fc, nr_double_t bw, nr_double_t f) {
59 nr_double_t lo = fc - bw / 2;
60 nr_double_t hi = fc + bw / 2;
61 if (f >= lo && f < hi)
70 nr_double_t q = fc / bw;
78 nr_double_t
emi::f_gauss (nr_double_t fc, nr_double_t bw, nr_double_t f) {
79 nr_double_t a =
log (0.5) / bw / bw;
80 nr_double_t
s = f - fc;
81 return exp (a * s * s);
88 vector *
emi::receiver (nr_double_t * ida, nr_double_t duration,
int ilength) {
92 vector * ed =
new vector ();
101 for (i = 2; i <
points; i++) {
102 ida[
i] /= points / 2;
106 fres = 1.0 / duration;
109 nr_double_t *
d = ida;
110 for (n = 0, i = 0; i < points / 2; i++, n += 2){
112 d[
i] =
xhypot (ida[n], ida[n + 1]);
120 { 200, 150e3, 200, 200 },
121 { 150e3, 30e6, 9e3, 9e3 },
122 { 30e6, 1e9, 120e3, 120e3 },
127 nr_double_t noise =
std::pow (10.0, (-100.0 / 40.0)) * 1e-6;
130 nr_double_t fcur, dcur;
134 for (i = 0; settings[
i].
bandwidth != 0; i++ ) {
137 nr_double_t fstart = settings[
i].
start;
138 nr_double_t fstop = settings[
i].
stop;
139 nr_double_t fstep = settings[
i].
stepsize;
142 for (fcur = fstart; fcur <= fstop; fcur += fstep) {
145 nr_double_t lo = fcur - bw / 2;
146 nr_double_t hi = fcur + bw / 2;
147 if (hi < fres)
continue;
155 if (ir >= 0 && il < points - 1) {
158 if (ir > points - 1) ir = points - 1;
162 for (
int j = 0; j < ir - il; j++){
163 nr_double_t f = fres * (il + j);
168 dcur += noise *
sqrt (bw);
186 int i, nlen, olen = da->getSize ();
189 if (len < da->getSize ()) len = da->getSize ();
194 nr_double_t tstart =
real (dt->get (0));
195 nr_double_t tstop =
real (dt->get (olen - 1));
196 nr_double_t duration = tstop - tstart;
202 interpolator * inter =
new interpolator ();
203 inter->rvectors (da, dt);
207 nr_double_t * ida =
new nr_double_t[2 * nlen];
208 nr_double_t tstep = duration / (nlen - 1);
209 for (i = 0; i < nlen; i++) {
210 nr_double_t
t = i * tstep + tstart;
211 ida[2 * i + 0] = inter->rinterpolate (t);
219 vector * res =
receiver (ida, duration, nlen);
std::complex< nr_double_t > nr_complex_t
void _fft_1d(nr_double_t *, int, int isign=1)
matrix real(matrix a)
Real part matrix.
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
nr_complex_t sqrt(const nr_complex_t z)
Compute principal value of square root.
nr_double_t xhypot(const nr_complex_t a, const nr_complex_t b)
Euclidean distance function for complex argument.
qucs::vector * receiver(nr_double_t *, nr_double_t, int)
nr_double_t f_gauss(nr_double_t, nr_double_t, nr_double_t)
Global math constants header file.
nr_complex_t floor(const nr_complex_t z)
Complex floor.
nr_int32_t nearestbin32(int)
nr_double_t norm(const nr_complex_t z)
Compute euclidian norm of complex number.
nr_complex_t exp(const nr_complex_t z)
Compute complex exponential.
nr_double_t f_ideal(nr_double_t, nr_double_t, nr_double_t)
nr_complex_t log(const nr_complex_t z)
Compute principal value of natural logarithm of z.
nr_double_t f_2ndorder(nr_double_t, nr_double_t, nr_double_t)