46 bvec temp(1 << (m - 1));
51 for (
int i = 0; i < m - 1; i++) {
64 for (i = 0; i < a.size(); i++)
75 for (i = 0; i < a.size(); i++)
85 it_assert(n > 0,
"waterfilling(): alpha vector cannot have zero length");
86 it_assert(P > 0,
"waterfilling(): Power constraint must be positive");
88 ivec ind = sort_index(alpha);
89 it_assert(alpha(ind(0)) > 0,
"waterfilling(): Gains must be positive");
93 for (
int m = 0; m < n; m++) {
96 for (
int j = m; j < n; j++) {
97 t += 1.0 / alpha(ind(j));
99 t = (t + P) / (n - m);
101 if (lambda < alpha(ind(m)))
106 for (
int j = 0; j < n; j++) {
107 result(j) = ((lambda < alpha(j)) ? (1.0 / lambda - 1.0 / alpha(j)) : 0.0);