 void generateSignal() {
 	int i, j;
 	float* output;
-	Matrix MatrixCA, MatrixCA_line, output_chunk;
+	Matrix MatrixCA, MatrixCA_line;
+	Matrix output_chunk_read, output_chunk_write, output_chunk_tmp;
 	Matrix MatrixAp, MatrixAp_tmp;
 
 

	CUDA_SAFE_CALL(cudaMalloc((void**) &device_MatrixCA.elements, m_size(MatrixCA)));
	CUDA_SAFE_CALL(cudaMemcpy(device_MatrixCA.elements, MatrixCA.elements, m_size(MatrixCA), cudaMemcpyHostToDevice));

	CUDA_SAFE_CALL(cudaMalloc((void**) &device_output_chunk_read.elements, m_size(output_chunk)));
	CUDA_SAFE_CALL(cudaMemcpy(device_output_chunk_read.elements, output_chunk.elements, m_size(output_chunk), cudaMemcpyHostToDevice));

	CUDA_SAFE_CALL(cudaMalloc((void**) &device_output_chunk_write.elements, m_size(output_chunk)));
	CUDA_SAFE_CALL(cudaMemcpy(device_output_chunk_write.elements, output_chunk.elements, m_size(output_chunk), cudaMemcpyHostToDevice));

	CUDA_SAFE_CALL(cudaMalloc((void**) &device_state_read.elements, m_size(state)));
	CUDA_SAFE_CALL(cudaMemcpy(device_state_read.elements, state.elements, m_size(state), cudaMemcpyHostToDevice));

	blocksize = 100;

#if MODE == 1
	Matrix device_MatrixAp;
	Matrix device_MatrixCA;
	Matrix device_state_read, device_state_write, device_state_tmp;
	Matrix device_output_chunk_read, device_output_chunk_write, device_output_chunk_tmp;

	device_MatrixCA = m_new(blocksize, MatrixA.cols);
	device_output_chunk_read = m_new(blocksize,1);
