 			m_set(block_CA, i-1, j, m_get(block_CA_line, 0, j));
 		}
 		m_free(block_CA_line);
-		MatrixAptmp = m_multiplyblockdiag(MatrixAp, MatrixA, 2);
+		tmp_MatrixAp = m_multiplyblockdiag(MatrixAp, MatrixA, 2);
 
 		m_free(MatrixAp);
-		MatrixAp = MatrixAptmp;
+		MatrixAp = tmp_MatrixAp;
 	}
 
 

			printf("%f, ", sample[i+j]);
#endif
		}
	//	statetmp = m_multiplyblockdiag(MatrixAp,state,2);
		MatrixMultiplyKernel<<<dimGridA, dimBlockA>>>(dMatrixAp, dstate1, dstate2);
		dstatetmp = dstate1;
		dstate1 = dstate2;
		dstate2 = dstatetmp;
	//	state = statetmp;
		i = i + blocksize;
	}


	int i, j;
	float* sample;
	Matrix block_CA, block_CA_line, block_samples;
	Matrix MatrixAp, tmp_MatrixAp;
	Matrix MatrixCA;
	Matrix tmp_state;

	Matrix dMatrixAp, dblock_CA, dstate1, dstate2, dtmp_state, dblock_samples;

	cudaSetDevice(0);

