Esempio n. 1
0
int main() {
  Hash_map hash_map;
  Data data= (Data) 123;
  Key key= (Key) 456;

  mcheck_pedantic(NULL);

  hash_map= create_example_hash_map();

  /* calling some of the functions with an empty Hash_map */
  if (!get(&hash_map, (Key) (long) 1, &data) &&
      !get_smallest(hash_map, &key, &data) &&  num_keys(hash_map, 0) == 0 &&
      index_of(hash_map, (Key) (long) 5) == -1 && data == (Data) 123 &&
      key == (Key) 456)
    printf("Your functions can handle an empty hash_map correctly!\n");
  else printf("Oops!  Error in handling anempty hash_map.\n");

  clear(&hash_map);

  if (mallinfo().uordblks != 0)
    printf("Memory leak of %d bytes. :(\n", mallinfo().uordblks);
  else printf("No memory leak detected. :)\n");

  return 0;
}
Esempio n. 2
0
//Implements the VBLAST decoding, a nulling and cancelling decoder
Matrix vblast_decoder(Matrix H, int NUM_TX, int NUM_RX, Matrix y, double scale, int PAM)
{
	Matrix y_VBLAST = y;
	Matrix picked(NUM_TX,1);
	Matrix VBLAST_OUT(NUM_TX,1);
	int i;
	for(i=0;i<NUM_TX;i++) picked(i,0) = 0;
	for(i=0;i<NUM_TX;i++)
	{
		int dim_left = NUM_TX - i;
		Matrix W(dim_left,NUM_RX);
		Matrix H_VBLAST(NUM_RX,dim_left);
		int upto = 0;
		for(int k = 0;k< NUM_TX; k++)
		{
			if(picked(k,0) == 0)
			{
				for(int j = 0;j < NUM_RX; j++)
					H_VBLAST(j,upto) = H(j,k);
				upto++;
			}
		}
		W = !( (~H_VBLAST) * H_VBLAST ) * (~H_VBLAST);
		int up_to = 0;
		int smallest_w = get_smallest(NUM_TX, NUM_RX, W, picked, up_to);
		picked(smallest_w,0) = 1;
		Matrix w_smallest(NUM_RX,1);
		Matrix h_smallest(NUM_RX,1);
		for(int j= 0;j< NUM_RX; j++)
		{
			w_smallest(j,0) = W(up_to,j);
			h_smallest(j,0) = H_VBLAST(j,up_to);
		}
		Matrix temp_VBLAST = (~w_smallest) * y_VBLAST;
		temp_VBLAST(0,0) = temp_VBLAST(0,0)/scale;
		Matrix VBLAST_sym = get_Eq_bits(1,temp_VBLAST,PAM);
		VBLAST_OUT(smallest_w,0) = VBLAST_sym(0,0);
		VBLAST_sym(0,0) = VBLAST_sym(0,0) * scale;
		y_VBLAST = y_VBLAST - ( h_smallest * VBLAST_sym );
	}
	return VBLAST_OUT;
}