60 "Fading_Generator::set_LOS_power(): Relative_power can not be negative");
68 it_warning(
"Fading_Generator::set_LOS_doppler(): This function has no effect on this kind of generator");
73 it_warning(
"Fading_Generator::set_time_offset(): This function has no effect on this kind of generator");
78 it_warning(
"Fading_Generator::set_norm_doppler(): This function has no effect on this kind of generator");
83 it_warning(
"Fading_Generator::set_filter_length(): This function has no effect on this kind of generator");
88 it_warning(
"Fading_Generator::set_doppler_spectrum(): This function has no effect on this kind of generator");
93 it_warning(
"Fading_Generator::set_no_frequencies(): This function has no effect on this kind of generator");
98 it_warning(
"Fading_Generator::set_rice_method(): This function has no effect on this kind of generator");
103 it_warning(
"Fading_Generator::get_LOS_doppler(): This function has no effect on this kind of generator");
109 it_warning(
"Fading_Generator::get_time_offset(): This function has no effect on this kind of generator");
115 it_warning(
"Fading_Generator::get_filter_length(): This function has no effect on this kind of generator");
121 it_warning(
"Fading_Generator::get_norm_doppler(): This function has no effect on this kind of generator");
127 it_warning(
"Fading_Generator::get_doppler_spectrum(): This function has no effect on this kind of generator");
133 it_warning(
"Fading_Generator::get_no_frequencies(): This function has no effect on this kind of generator");
139 it_warning(
"Fading_Generator::get_rice_method(): This function has no effect on this kind of generator");
145 it_warning(
"Fading_Generator::shift_time_offset(): This function has no effect on this kind of generator");
162 output.set_size(no_samples,
false);
164 for (
int i = 0; i < no_samples; ++i) {
180 std::complex<double> static_sample =
randn_c();
186 static_sample_im = static_sample.imag();
195 output.set_size(no_samples,
false);
212 it_assert((norm_doppler > 0) && (norm_doppler <= 1.0),
213 "Correlated_Fading_Generator: Normalized Doppler out of range");
220 it_assert((relative_doppler >= 0) && (relative_doppler <= 1.0),
221 "Correlated_Fading_Generator::set_LOS_doppler(): Relative Doppler out of range");
267 "Rice_Fading_Generator::set_no_frequencies(): Too low number of Doppler frequencies");
286 it_error(
"Rice_Fading_Generator::init(): Wrong Rice method for this fading generator");
297 output.set_size(no_samples,
false);
301 double tmp_re, tmp_im;
303 for (
int i = 0; i < no_samples; i++) {
306 output(i) = std::complex<double>(tmp_re, tmp_im);
311 for (
int i = 0; i < no_samples; i++) {
314 output(i) = std::complex<double>(tmp_re, tmp_im);
322 for (
int i = 0; i < no_samples; i++) {
348 f2 =
sin(
pi / (2 * (
Ni + 1)) * (n - 0.5));
372 sgm_0_2 = 0.15 / (
std::sqrt(10.0) + 0.15);
380 it_error(
"Rice_Fading_Generator::init_MEDS(): Wrong spectrum method for this fading generator");
399 "FIR_Fading_Generator::set_filter_length(): Filter length should be at least 50");
407 double norm_dopp =
n_dopp;
409 while (norm_dopp < 0.1) {
429 int no_upsamples =
ceil_i(static_cast<double>(no_samples -
left_overs.size())
435 left_overs = output.right(output.size() - no_samples);
436 output.set_size(no_samples,
true);
439 for (
int i = 0; i < no_samples; i++) {
450 vec x_pos(L), x_neg(L), x(2*L + 1), h(2*L + 1);
451 for (
int i = 1; i <= L; i++) {
455 double x0 = 1.468813 *
std::pow(norm_dopp, 0.25);
476 for (
int i = 0; i < no_samples; i++) {
487 double df = 1.0 / Nfft;
491 while (noisesamp <= 10) {
497 "IFFT_Fading_Generator::generate_Jakes(): Too low normalized doppler or too small blocks of data. Results in an inefficient algorithm with lots of zero-padding");
500 vec Fpos =
linspace(0, 0.5, Nfft / 2 + 1);
504 for (
int i = 0; i < F.size(); i++) {
505 if (std::fabs(F(i)) <
n_dopp)
507 else if (std::fabs(F(i)) ==
n_dopp)
516 for (
int i = 0; i < noisesamp; ++i) {
518 x(Nfft - 1 - i) = S(Nfft - 1 - i) *
randn_c();
523 output = x.mid(0, no_samples);
532 const vec &delay_prof)
545 "Channel_Specification::set_channel_profile(): Minimum relative delay must be 0");
546 it_assert(avg_power_dB.size() == delay_prof.size(),
547 "Channel_Specification::set_channel_profile(): Power and delay vectors must be of equal length");
549 "Channel_Specification::set_channel_profile(): First tap must be at zero delay");
550 for (
int i = 1; i < delay_prof.size(); i++) {
551 it_assert(delay_prof(i) > delay_prof(i - 1),
552 "Channel_Specification::set_channel_profile(): Delays should be sorted and unique");
555 N_taps = delay_prof.size();
571 case ITU_Vehicular_A:
573 vec(
"0 310 710 1090 1730 2510") * 1e-9);
576 case ITU_Vehicular_B:
578 vec(
"0 300 8900 12900 17100 20000") * 1e-9);
581 case ITU_Pedestrian_A:
583 vec(
"0 110 190 410") * 1e-9);
586 case ITU_Pedestrian_B:
588 vec(
"0 200 800 1200 2300 3700") * 1e-9);
593 set_channel_profile(vec(
"-5.7 -7.6 -10.1 -10.2 -10.2 -11.5 -13.4 -16.3 -16.9 -17.1 -17.4 -19 -19 -19.8 -21.5 -21.6 -22.1 -22.6 -23.5 -24.3"),
594 vec(
"0 217 512 514 517 674 882 1230 1287 1311 1349 1533 1535 1622 1818 1836 1884 1943 2048 2140") * 1e-9);
599 vec(
"0 42 101 129 149 245 312 410 469 528") * 1e-9);
604 set_channel_profile(vec(
"-3.6 -8.9 -10.2 -11.5 -11.8 -12.7 -13.0 -16.2 -17.3 -17.7 -17.6 -22.7 -24.1 -25.8 -25.8 -26.2 -29 -29.9 -30 -30.7"),
605 vec(
"0 356 441 528 546 609 625 842 916 941 15000 16172 16492 16876 16882 16978 17615 17827 17849 18016") * 1e-9);
611 vec(
"0 200 400 600") * 1e-9);
617 vec(
"0 100 200 300 400 500") * 1e-9);
623 vec(
"0 200 600 1600 2400 5000") * 1e-9);
632 vec(
"0 200 500 1600 2300 5000") * 1e-9);
640 vec(
"0 200 400 600 800 1200 1400 1800 2400 3000 3200 5000") * 1e-9);
652 case COST207_TU12alt:
654 vec(
"0 200 400 600 800 1200 1400 1800 2400 3000 3200 5000") * 1e-9);
667 vec(
"0 400 1000 1600 5000 6600") * 1e-9);
676 vec(
"0 300 1000 1600 5000 6600") * 1e-9);
685 vec(
"0 200 400 800 1600 2200 3200 5000 6000 7200 8200 10000") * 1e-9);
697 case COST207_BU12alt:
699 vec(
"0 100 300 700 1600 2200 3100 5000 6000 7200 8100 10000") * 1e-9);
714 vec(
"0 200 400 600 15000 17200") * 1e-9);
721 vec(
"0 100 300 500 15000 17200") * 1e-9);
728 vec(
"0 200 400 600 800 2000 2400 15000 15200 15800 17200 20000") * 1e-9);
740 case COST207_HT12alt:
742 vec(
"0 100 300 500 700 1000 1300 15000 15200 15700 17200 20000") * 1e-9);
758 for (
int i = 0; i <
N_taps; i++)
768 double relative_doppler)
771 "Channel_Specification::set_LOS(): Cannot set LOS component if not set channel profile");
773 "Channel_Specification::set_LOS(): Tap number out of range");
774 it_assert((relative_doppler >= 0) && (relative_doppler <= 1.0),
775 "Channel_Specification::set_LOS(): Normalized Doppler out of range");
777 "Channel_Specification::set_LOS(): Rice factor out of range");
782 los_dopp(tap_number) = relative_doppler;
786 const vec& relative_doppler)
789 "Channel_Specification::set_LOS(): Improper size of input vectors");
791 if (relative_doppler.size() == 0) {
792 los_power.set_size(relative_power.size());
793 los_dopp.set_size(relative_power.size());
794 for (
int i = 0; i < relative_power.size(); i++) {
796 "Channel_Specification::set_LOS(): Rice factor out of range");
803 "Channel_Specification::set_LOS(): Improper size of input vectors");
804 los_power.set_size(relative_power.size());
805 los_dopp.set_size(relative_power.size());
806 for (
int i = 0; i < relative_power.size(); i++) {
807 it_assert((relative_doppler(i) >= 0) && (relative_doppler(i) <= 1.0),
808 "Channel_Specification::set_LOS(): Normalized Doppler out of range");
810 "Channel_Specification::set_LOS(): Rice factor out of range");
818 vec &delay_prof)
const
827 "Channel_Specification::get_doppler_spectrum(): Index of of range");
840 double a = a_prof *
d_prof /
sum(a_prof);
852 init_flag(false), n_dopp(0.0), fading_type(Independent), method(Rice_MEDS),
853 filter_length(0), nrof_freq(16), discrete_Ts(0.0)
866 init_flag(false), n_dopp(0.0), fading_type(Independent), method(Rice_MEDS),
867 filter_length(0), nrof_freq(16), discrete_Ts(sampling_time)
888 const ivec &delay_prof)
891 "TDL_Channel::set_channel_profile(): Minimum relative delay must be 0.");
892 it_assert(avg_power_dB.size() == delay_prof.size(),
893 "TDL_Channel::set_channel_profile(): Power and delay vectors must be of equal length!");
895 "TDL_Channel::set_channel_profile(): First tap must be at zero delay");
896 for (
int i = 1; i < delay_prof.size(); i++) {
897 it_assert(delay_prof(i) > delay_prof(i - 1),
898 "TDL_Channel::set_channel_profile(): Delays should be sorted and unique");
901 N_taps = delay_prof.size();
919 it_assert(no_taps >= 1,
"TDL_Channel::set_channel_profile_uniform(): Minimum number of taps is 1.");
921 vec avg_power_dB =
zeros(no_taps);
922 ivec delay_prof(no_taps);
923 for (
int i = 0; i < no_taps; i++)
931 it_assert(no_taps >= 1,
"TDL_Channel::set_channel_profile_exponential(): Minimum number of taps is 1.");
933 vec avg_power_dB(no_taps);
934 ivec delay_prof(no_taps);
935 for (
int i = 0; i < no_taps; i++) {
938 avg_power_dB(i) =
dB(
std::exp(static_cast<double>(-i)));
952 N_taps = avg_power_dB.size();
972 method = correlated_method;
985 it_assert((norm_doppler > 0) && (norm_doppler <= 1.0),
986 "TDL_Channel::set_norm_doppler(): Normalized Doppler out of range");
997 "TDL_Channel::set_LOS(): Improper size of input vectors");
999 if (relative_doppler.size() == 0) {
1000 los_power.set_size(relative_power.size());
1001 los_dopp.set_size(relative_power.size());
1002 for (
int i = 0; i < relative_power.size(); i++) {
1004 "TDL_Channel::set_LOS(): Rice factor out of range");
1006 los_dopp(i) = (relative_power(i) > 0) ? 0.7 : 0.0;
1011 "TDL_Channel::set_LOS(): Improper size of input vectors");
1012 los_power.set_size(relative_power.size());
1013 los_dopp.set_size(relative_power.size());
1014 for (
int i = 0; i < relative_power.size(); i++) {
1015 it_assert((relative_doppler(i) >= 0) && (relative_doppler(i) <= 1.0),
1016 "TDL_Channel::set_LOS(): Normalized Doppler out of range");
1018 "TDL_Channel::set_LOS(): Rice factor out of range");
1028 "TDL_Channel::set_LOS_power(): Improper size of input vector");
1030 los_power.set_size(relative_power.size());
1031 los_dopp.set_size(relative_power.size());
1032 for (
int i = 0; i <
los_power.size(); ++i) {
1034 los_dopp(i) = (relative_power(i) > 0) ? 0.7 : 0.0;
1042 "TDL_Channel::set_LOS_doppler(): Improper size of input vector");
1044 it_assert(
n_dopp > 0,
"TDL_Channel::set_LOS_doppler(): Normalized Doppler needs to be non zero to set the LOS Doppler in a Correlated fading generator");
1046 los_dopp.set_size(relative_doppler.size());
1047 for (
int i = 0; i < relative_doppler.size(); ++i) {
1048 it_assert((relative_doppler(i) >= 0) && (relative_doppler(i) <= 1.0),
1049 "TDL_Channel::set_LOS_doppler(): Normalized Doppler out of range");
1059 it_assert(
N_taps > 0,
"TDL_Channel::set_doppler_spectrum(): Channel profile not defined yet");
1061 it_assert(
n_dopp > 0,
"TDL_Channel::set_doppler_spectrum(): Normalized Doppler needs to be non zero to set the Doppler spectrum in the Correlated Rice MEDS fading generator");
1067 for (
int i = 0; i <
N_taps; i++)
1076 "TDL_Channel::set_doppler_spectrum(): Improper tap number");
1078 it_assert(
n_dopp > 0,
"TDL_Channel::set_doppler_spectrum(): Normalized Doppler needs to be non zero to set the Doppler spectrum in the Correlated Rice MEDS fading generator");
1091 it_assert(
n_dopp > 0,
"TDL_Channel::set_no_frequencies(): Normalized Doppler needs to be non zero to set the number of frequencies in the Correlated Rice MEDS fading generator");
1102 it_assert(
n_dopp > 0,
"TDL_Channel::set_filter_length(): Normalized Doppler needs to be non zero to use the Correlated FIR fading generator");
1114 it_assert(
n_dopp > 0,
"TDL_Channel::set_time_offset(): Normalized Doppler needs to be non zero to set time offset in a Correlated fading generator");
1119 for (
int i = 0; i <
N_taps; i++) {
1127 it_assert(
n_dopp > 0,
"TDL_Channel::shift_time_offset(): Normalized Doppler needs to be non zero to shift time offset in a Correlated fading generator");
1132 for (
int i = 0; i <
N_taps; i++) {
1133 fading_gen(i)->shift_time_offset(no_samples);
1139 ivec &delay_prof)
const
1173 it_assert(
N_taps > 0,
"TDL_Channel::init(): Channel profile not defined yet");
1175 "TDL_Channel::init(): LOS profile does not mach the channel profile");
1191 for (
int i = 0; i <
N_taps; ++i) {
1200 for (
int i = 0; i <
N_taps; ++i) {
1210 "TDL_Channel::init(): Correlated fading requires non zero normalized Doppler");
1217 for (
int i = 0; i <
N_taps; ++i) {
1229 for (
int i = 0; i <
N_taps; ++i) {
1231 "TDL_Channel::init(): FIR fading generator can be used with Jakes spectrum only");
1244 for (
int i = 0; i <
N_taps; ++i) {
1246 "TDL_Channel::init(): IFFT fading generator can be used with Jakes spectrum only");
1257 it_error(
"TDL_Channel::init(): No such fading generation method");
1262 it_error(
"TDL_Channel::init(): No such fading type");
1274 for (
int i = 0; i <
N_taps; i++)
1283 channel_coeff.set_size(no_samples,
N_taps,
false);
1284 for (
int i = 0; i <
N_taps; i++)
1293 output.set_size(input.size() + maxdelay,
false);
1296 for (
int i = 0; i <
N_taps; i++)
1304 output.set_size(input.size() + maxdelay,
false);
1307 for (
int i = 0; i <
N_taps; i++)
1313 generate(input.size(), channel_coeff);
1319 generate(input.size(), channel_coeff);
1326 filter(input, output, channel_coeff);
1333 filter(input, output, channel_coeff);
1340 filter(input, output, channel_coeff);
1353 filter(input, output, channel_coeff);
1358 filter(input, output, channel_coeff);
1364 return filter(input, channel_coeff);
1369 return filter(input, channel_coeff);
1380 it_assert(
init_flag ==
true,
"calc_impulse_response: TDL_Channel is not initialized");
1381 it_assert(
N_taps == channel_coeff.
size(),
"calc_impulse_response: number of channel taps do not match");
1383 int no_samples = channel_coeff(0).
size();
1384 it_assert(no_samples > 0,
"calc_impulse_response: channel_coeff must contain samples");
1386 impulse_response.
set_size(no_samples);
1388 for (
int i = 0; i < no_samples; i++) {
1390 impulse_response(i).zeros();
1392 for (
int j = 0; j <
N_taps; j++)
1393 impulse_response(i)(
d_prof(j)) = channel_coeff(j)(i);
1400 it_assert(
init_flag ==
true,
"calc_frequency_response: TDL_Channel is not initialized");
1401 it_assert(
N_taps == channel_coeff.
size(),
"calc_frequency_response: number of channel taps do not match");
1403 int no_samples = channel_coeff(0).
size();
1404 it_assert(no_samples > 0,
"calc_frequency_response: channel_coeff must contain samples");
1406 frequency_response.
set_size(no_samples);
1408 it_assert(fft_size >
d_prof(
N_taps - 1),
"calc_frequency_response: fft_size must be larger than the maximum delay in samples");
1409 cvec impulse_response(fft_size);
1411 for (
int i = 0; i < no_samples; i++) {
1412 impulse_response.zeros();
1414 for (
int j = 0; j <
N_taps; j++)
1415 impulse_response(
d_prof(j)) = channel_coeff(j)(i);
1417 fft(impulse_response, frequency_response(i));
1424 it_assert(
init_flag ==
true,
"calc_frequency_response: TDL_Channel is not initialized");
1425 it_assert(
N_taps == channel_coeff.cols(),
"calc_frequency_response: number of channel taps do not match");
1427 int no_samples = channel_coeff.rows();
1428 it_assert(no_samples > 0,
"calc_frequency_response: channel_coeff must contain samples");
1430 frequency_response.set_size(fft_size, no_samples,
false);
1432 it_assert(fft_size >
d_prof(
N_taps - 1),
"calc_frequency_response: fft_size must be larger than the maximum delay in samples");
1433 cvec impulse_response(fft_size);
1436 for (
int i = 0; i < no_samples; i++) {
1437 impulse_response.zeros();
1439 for (
int j = 0; j <
N_taps; j++)
1440 impulse_response(
d_prof(j)) = channel_coeff(i, j);
1442 fft(impulse_response, freq);
1443 frequency_response.set_col(i, freq);
1449 it_assert(
N_taps > 0,
"TDL_Channel::discretize(): No channel profile specified");
1450 it_assert(delay_profile(0) == 0,
"TDL_Channel::discretize(): First tap should be at zero delay");
1454 "TDL_Channel:: discretize(): Channel profile lenghts must be equal to the number of taps");
1465 power(0) = p_prof(0);
1466 spower = p_prof(0) / (1 +
los_power(0));
1467 scattered(0) = spower;
1473 int j = 0, j_delay = 0;
1474 for (
int i = 1; i <
N_taps; i++) {
1475 if (delay_profile(i) > (j_delay + 0.5)*
discrete_Ts) {
1477 while (delay_profile(i) > (j_delay + 0.5)*
discrete_Ts) { j_delay++; }
1480 delay_prof(j) = j_delay;
1481 power(j) = p_prof(i);
1482 spower = p_prof(i) / (1 +
los_power(i));
1483 scattered(j) = spower;
1490 power(j) += p_prof(i);
1491 spower = p_prof(i) / (1 +
los_power(i));
1492 scattered(j) += spower;
1495 "TDL_Channel::discretize(): Sampling frequency too low. Can not discretize the channel with different Doppler spectra on merged taps.");
1496 it_warning(
"TDL_Channel::discretize(): Sampling frequency too low. Merging original tap " << i <<
" with new tap " << j <<
".");
1497 if (los_doppler(j) !=
los_dopp(i)) {
1498 los_doppler(j) = 0.7;
1499 it_warning(
"TDL_Channel::discretize(): LOS Doppler value reset to 0.7 for tap " << j <<
" due to the merging process.");
1504 int no_taps = j + 1;
1505 if (no_taps < N_taps) {
1506 delay_prof.set_size(no_taps,
true);
1507 power.set_size(no_taps,
true);
1508 direct.set_size(no_taps,
true);
1509 scattered.set_size(no_taps,
true);
1510 los_doppler.set_size(no_taps,
true);
1511 tap_spectrum.
set_size(no_taps,
true);
1531 int i,
length = input.length();
1532 bvec output(length);
1534 for (i = 0; i <
length; i++) {
1536 output(i) = input(i) +
bin(1);
1539 output(i) = input(i);
1552 int n = input.size();
1562 int n = input.size();