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);
Various functions on vectors and matrices - header file.
ITPP_EXPORT bvec ones_b(int size)
A Binary vector of ones.
Vec< T > reverse(const Vec< T > &in)
Reverse the input vector.
ITPP_EXPORT bvec zeros_b(int size)
A Binary vector of zeros.
#define it_assert(t, s)
Abort if t is not true.
int length(const Vec< T > &v)
Length of vector.
int weight(const bvec &a)
Calculate the Hamming weight of a.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
Definitions of converters between different vector and matrix types.
Definitions of some specific functions useful in communications.
vec waterfilling(const vec &alpha, double P)
Compute the water-filling solutionThis function computes the solution of the water-filling problem s...
bmat graycode(int m)
Generate Gray code of blocklength m.The codes are contained as binary codewords {0,1} in the rows of the returned matrix. See also the gray() function in math/scalfunc.h.
Definitions of special vectors and matrices.
Binary arithmetic (boolean) class.
bmat to_bmat(const Mat< T > &m)
Converts a Mat<T> to bmat.
int hamming_distance(const bvec &a, const bvec &b)
Calculate the Hamming distance between a and b.
Mat< bin > bmat
bin matrix
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.