コード例 #1
0
void quantum_print_qureg( quantum_reg reg )
{
  int i = 0, j;
  for ( ; i < reg.size; i++ )
  {
    printf( "% f %+fi|%lli&gt; (%e) (|", quantum_real( reg.node[ i ].amplitude ), quantum_imag( reg.node[ i ].amplitude ), reg.node[ i ].state, quantum_prob_inline( reg.node[ i ].amplitude ) );
    j = reg.width - 1;
    for ( ; j >= 0; j-- )
    {
      if ( ( j % 4 ) == 3 )
        putchar( 32 );
      printf( "%i", (int)( reg.node[ i ].state >> (unsigned char)( j ) ) & 1 );
      //j--;
    }
    puts( "&gt;)" );
    //i++;
  }
  putchar( 10 );
  return;
}
コード例 #2
0
void quantum_print_matrix( quantum_matrix m )
{
  int i, j, z = 0;
  do
  {
    z++;
  }
  while ( ( ( ( 1 << z ) < m.rows ) & 255 ) != 0 );
  z--;
  i = 0;
  for ( ; i < m.rows; i++ )
  {
    j = 0;
    for ( ; j < m.cols; j++ )
    {
      printf( "%g %+gi ", quantum_real( m.t[ j + ( m.cols * i ) ] ), quantum_imag( m.t[ j + ( m.cols * i ) ] ) );
      //j++;
    }
    putchar( 10 );
    //i++;
  }
  putchar( 10 );
  return;
}