Problem with 'quantum_density_operation'

Bjoern Butscher bjoern at epith.de
Fri Jan 7 20:18:14 CET 2005


On Friday 07 January 2005 15:31, Jaroslaw Miszczak wrote:
> Hi,
> I have started using libquantum and I have problem with
> 'quantum_density_operation' macro.
>
> Here is the source:
> --- starts here
>       1 #include <quantum.h>
>       2 #include <stdio.h>
>       3 () {
>       4 int main() { ro;
>       5   quantum_density_op ro;
>       6   quantum_reg x, y, z;
>       7 ts = 3;
>       8   int qbts = 3;
>       9   quantum_reg tab[3];0.4};
>      10   float prbs[3] = {0.1, 0.5, 0.4};
>      11 antum_new_qureg(1,2);
>      12   x = quantum_new_qureg(1,2);
>      13   y = quantum_new_qureg(0,2);
>      14   z = quantum_new_qureg(2,2);
>      15   tab[0] = x;
>      16   tab[1] = y;
>      17   tab[2] = z;
>      18 uantum_new_density_op (qbts,prbs,tab);
>      19   ro = quantum_new_density_op (qbts,prbs,tab);
>      20   puts("Initial density operator");
>      21   quantum_print_density_matrix (&ro);
>      22 m_set_decoherence(0.1);
>      23   quantum_set_decoherence(0.1);damard, ro ) ;
>      24   quantum_density_operation (quantum_hadamard, ro ) ;
>      25   quantum_print_density_matrix (&ro);
>      26   return(0);
>      27 }
> --- end
>
> After compilation I get error:
> $ gcc -lquantum -o dmop dmop.c -Wall
> dmop.c: In function `main':
> dmop.c:24: error: syntax error before ',' token
> dmop.c:24: error: syntax error before ',' token

Hi Jaroslaw,

the definition of quantum_density_operation is 

#define quantum_density_operation(function, rho, ...)

so, as you invoke quantum_density_operation with function-argument 
quantum_hadamard, you also need to specify the parameters you would need to 
if you were using register-representation.

So if you want the hadamard-operation to act on the first qubit, just change 
line 24 to
 quantum_density_operation (quantum_hadamard, ro, 0) ;

or, if you want it to act on the second qubit, try

 quantum_density_operation (quantum_hadamard, ro, 1) ;


I didn't try this for quantum_hadamard, but using quantum_cnot it worked for 
me.

Bjoern



More information about the libquantum-users mailing list