
/*******************************************************************************
*
* File Qhat_dble.c
*
* Copyright (C) 2005 Martin Luescher, 2007 Bjoern Leder, 2011 Andrea Nobile
*
* This software is distributed under the terms of the GNU General Public
* License (GPL)
*
* Application of the even-odd preconditioned Wilson-Dirac operator
*
* The externally accessible functions are
*
*   void Qhat_dble(int k,int l)
*     Applies Qhat to the global double-precision field *psd[k][] and assigns
*     the result to *psd[l][]
*
*   void Qoe_dble(int k,int l)
*     Applies the operator Qoe to the even part of the global double-precision
*     field *psd[k][] and assigns the result to *psd[l][]
*
*   void Qeo_dble(int k,int l)
*     Applies the operator Qeo to the odd part of the global double-precision
*     field *psd[k][] and *subtracts* the result from *psd[l][]
*
*   void Qnohat_dble(int k,int l)
*     Applies the full Dirac operator Q to the global double-precision field
*     *psd[k][] and assigns the result to *psd[l][]
*
*   void Qhat_blk_dble(block_t *b,int k,int l)
*     Applies Qhat to the double-precision field b.sd[k][] on the block b and
*     assigns the result to b.sd[l][]
*
*   void Qoe_blk_dble(block_t *b,int k,int l)
*     Applies the operator Qoe to the even part of the double-precision field
*     b.sd[k][] on the block b and assigns the result to b.sd[l][]
*
*   void Qeo_blk_dble(block_t *b,int k,int l)
*     Applies the operator Qeo to the odd part of the double-precision field
*     b.sd[k][] on the block b and *subtracts* the result from b.sd[l][]
*
*   void Qnohat_blk_dble(block_t *b,int k,int l)
*     Applies the full Dirac operator Q to the double-precision field b.sd[k][]
*     on the block b and assigns the result to b.sd[l][]
*
* Notes:
*
* The notation and normalization conventions are specified in the notes
* "Implementation of the lattice Dirac operator" (file doc/dirac.ps)
*
* In all these programs it is assumed that Qee and Qoo (or 1/Qoo in the
* case of the preconditioned operator) are stored in the appropriate sw
* arrays. Whether the field arrays are in the proper condition can normally
* be determined by querying the flags data base [see flags.c]
*
* All non-block programs in this file act globally and should be called
* from all processes with the same parameters. Communication buffers are
* allocated automatically when needed
*
* The block programs, on the other hand, act locally. Any errors occuring in
* these are recorded by the error_loc [utils.c] function
*
*******************************************************************************/

#define QHAT_DBLE_C

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "mpi.h"
#include "su3.h"
#include "flags.h"
#include "start.h"
#include "block.h"
#include "sw_term.h"
#include "dirac.h"
#include "global.h"

static double coe,ceo;
static const spinor_dble sd0={{{0.0}}};

#if (defined SSE2)
#include "sse2.h"

static spinor_dble rs __attribute__ ((aligned (32)));

#define _load_cst(c) \
__asm__ __volatile__ ("movsd %0, %%xmm6 \n\t" \
                      "unpcklpd %%xmm6, %%xmm6" \
                      : \
                      : \
                      "m" (c) \
                      : \
                      "xmm6")

#define _load_csts(c) \
__asm__ __volatile__ ("movsd %0, %%xmm7 \n\t" \
                      "movsd %0, %%xmm6 \n\t" \
                      "xorpd %1, %%xmm7 \n\t" \
                      "unpcklpd %%xmm6, %%xmm6 \n\t" \
                      "unpcklpd %%xmm7, %%xmm7" \
                      : \
                      : \
                      "m" (c), \
                      "m" (_sse_sgn_dble) \
                      : \
                      "xmm6", "xmm7")

#define _mul_cst() \
__asm__ __volatile__ ("mulpd %%xmm6, %%xmm0 \n\t" \
                      "mulpd %%xmm6, %%xmm1 \n\t" \
                      "mulpd %%xmm6, %%xmm2" \
                      : \
                      : \
                      : \
                      "xmm0", "xmm1", "xmm2")

#define _mul_cst_up() \
__asm__ __volatile__ ("mulpd %%xmm6, %%xmm3 \n\t" \
                      "mulpd %%xmm6, %%xmm4 \n\t" \
                      "mulpd %%xmm6, %%xmm5" \
                      : \
                      : \
                      : \
                      "xmm3", "xmm4", "xmm5")

#define _mul_csts() \
__asm__ __volatile__ ("mulpd %%xmm7, %%xmm0 \n\t" \
                      "mulpd %%xmm7, %%xmm1 \n\t" \
                      "mulpd %%xmm7, %%xmm2" \
                      : \
                      : \
                      : \
                      "xmm0", "xmm1", "xmm2")

#define _mul_csts_up() \
__asm__ __volatile__ ("mulpd %%xmm7, %%xmm3 \n\t" \
                      "mulpd %%xmm7, %%xmm4 \n\t" \
                      "mulpd %%xmm7, %%xmm5" \
                      : \
                      : \
                      : \
                      "xmm3", "xmm4", "xmm5")


static void qoe(int *piup,int *pidn,su3_dble *u,spinor_dble *pk)
{
   spinor_dble *sp,*sm;

/******************************* direction +0 *********************************/

   sp=pk+(*(piup++));

   _sse_load_dble((*sp).c1);
   _sse_load_up_dble((*sp).c3);

   sm=pk+(*(pidn++));
   _prefetch_spinor_dble(sm);
   _sse_vector_add_dble();
   _sse_su3_multiply_dble(*u);
   _sse_store_up_dble(rs.c1);
   _sse_store_up_dble(rs.c3);

   _sse_load_dble((*sp).c2);
   _sse_load_up_dble((*sp).c4);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;
   _sse_vector_add_dble();
   _sse_su3_multiply_dble(*u);

   _sse_store_up_dble(rs.c2);
   _sse_store_up_dble(rs.c4);

/******************************* direction -0 *********************************/

   _sse_load_dble((*sm).c1);
   _sse_load_up_dble((*sm).c3);

   sp=pk+(*(piup++));
   _prefetch_spinor_dble(sp);
   _sse_vector_sub_dble();
   u+=1;
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble(rs.c1);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c1);

   _sse_load_dble(rs.c3);
   _sse_vector_sub_dble();
   _sse_store_dble(rs.c3);

   _sse_load_dble((*sm).c2);
   _sse_load_up_dble((*sm).c4);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;   
   _sse_vector_sub_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble(rs.c2);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c2);

   _sse_load_dble(rs.c4);
   _sse_vector_sub_dble();
   _sse_store_dble(rs.c4);

/******************************* direction +1 *********************************/

   _sse_load_dble((*sp).c1);
   _sse_load_up_dble((*sp).c4);

   sm=pk+(*(pidn++));
   _prefetch_spinor_dble(sm);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   u+=1;
   _sse_su3_multiply_dble(*u);

   _sse_load_dble(rs.c1);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c1);

   _sse_load_dble(rs.c4);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_store_dble(rs.c4);

   _sse_load_dble((*sp).c2);
   _sse_load_up_dble((*sp).c3);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_su3_multiply_dble(*u);

   _sse_load_dble(rs.c2);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c2);

   _sse_load_dble(rs.c3);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_store_dble(rs.c3);

/******************************* direction -1 *********************************/

   _sse_load_dble((*sm).c1);
   _sse_load_up_dble((*sm).c4);

   sp=pk+(*(piup++));
   _prefetch_spinor_dble(sp);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   u+=1;
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble(rs.c1);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c1);

   _sse_load_dble(rs.c4);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_store_dble(rs.c4);

   _sse_load_dble((*sm).c2);
   _sse_load_up_dble((*sm).c3);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble(rs.c2);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c2);

   _sse_load_dble(rs.c3);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_store_dble(rs.c3);

/******************************* direction +2 *********************************/

   _sse_load_dble((*sp).c1);
   _sse_load_up_dble((*sp).c4);

   sm=pk+(*(pidn++));
   _prefetch_spinor_dble(sm);
   _sse_vector_add_dble();
   u+=1;
   _sse_su3_multiply_dble(*u);

   _sse_load_dble(rs.c1);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c1);

   _sse_load_dble(rs.c4);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c4);

   _sse_load_dble((*sp).c2);
   _sse_load_up_dble((*sp).c3);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;
   _sse_vector_sub_dble();
   _sse_su3_multiply_dble(*u);

   _sse_load_dble(rs.c2);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c2);

   _sse_load_dble(rs.c3);
   _sse_vector_sub_dble();
   _sse_store_dble(rs.c3);

/******************************* direction -2 *********************************/

   _sse_load_dble((*sm).c1);
   _sse_load_up_dble((*sm).c4);

   sp=pk+(*(piup));
   _prefetch_spinor_dble(sp);
   _sse_vector_sub_dble();
   u+=1;
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble(rs.c1);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c1);

   _sse_load_dble(rs.c4);
   _sse_vector_sub_dble();
   _sse_store_dble(rs.c4);

   _sse_load_dble((*sm).c2);
   _sse_load_up_dble((*sm).c3);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;
   _sse_vector_add_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble(rs.c2);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c2);

   _sse_load_dble(rs.c3);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c3);

/******************************* direction +3 *********************************/

   _sse_load_dble((*sp).c1);
   _sse_load_up_dble((*sp).c3);

   sm=pk+(*(pidn));
   _prefetch_spinor_dble(sm);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   u+=1;
   _sse_su3_multiply_dble(*u);

   _sse_load_dble(rs.c1);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c1);

   _sse_load_dble(rs.c3);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_store_dble(rs.c3);

   _sse_load_dble((*sp).c2);
   _sse_load_up_dble((*sp).c4);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_su3_multiply_dble(*u);

   _sse_load_dble(rs.c2);
   _sse_vector_add_dble();
   _sse_store_dble(rs.c2);

   _sse_load_dble(rs.c4);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_store_dble(rs.c4);

/******************************* direction -3 *********************************/

   _sse_load_dble((*sm).c1);
   _sse_load_up_dble((*sm).c3);

   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   u+=1;
   _sse_su3_inverse_multiply_dble(*u);

   _load_csts(coe);
   _sse_load_dble(rs.c1);
   _sse_vector_add_dble();
   _mul_csts();
   _sse_store_dble(rs.c1);

   _sse_load_dble(rs.c3);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _mul_cst();
   _sse_store_dble(rs.c3);

   _sse_load_dble((*sm).c2);
   _sse_load_up_dble((*sm).c4);

   u+=1;
   _prefetch_su3_dble(u);
   u-=1;
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _load_csts(coe);
   _sse_load_dble(rs.c2);
   _sse_vector_add_dble();
   _mul_csts();
   _sse_store_dble(rs.c2);

   _sse_load_dble(rs.c4);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _mul_cst();
   _sse_store_dble(rs.c4);
}


static void qeo(int *piup,int *pidn,su3_dble *u,spinor_dble *pl)
{
   spinor_dble *sp,*sm;

/******************************* direction +0 *********************************/

   sp=pl+(*(piup++));
   _prefetch_spinor_dble(sp);

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c3);

   sm=pl+(*(pidn++));
   _prefetch_spinor_dble(sm);
   _sse_vector_sub_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c1);

   _sse_load_dble((*sp).c3);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c3);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c4);

   _sse_vector_sub_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c2);

   _sse_load_dble((*sp).c4);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c4);

/******************************* direction -0 *********************************/

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c3);

   sp=pl+(*(piup++));
   _prefetch_spinor_dble(sp);
   _sse_vector_add_dble();
   u+=1;
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c1);

   _sse_load_dble((*sm).c3);
   _sse_vector_add_dble();
   _sse_store_dble((*sm).c3);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c4);

   _sse_vector_add_dble();
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c2);

   _sse_load_dble((*sm).c4);
   _sse_vector_add_dble();
   _sse_store_dble((*sm).c4);

/******************************* direction +1 *********************************/

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c4);

   sm=pl+(*(pidn++));
   _prefetch_spinor_dble(sm);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   u+=1;   
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c1);

   _sse_load_dble((*sp).c4);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_store_dble((*sp).c4);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c3);

   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c2);

   _sse_load_dble((*sp).c3);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_store_dble((*sp).c3);

/******************************* direction -1 *********************************/

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c4);

   sp=pl+(*(piup++));
   _prefetch_spinor_dble(sp);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   u+=1;
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c1);

   _sse_load_dble((*sm).c4);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c4);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c3);

   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c2);

   _sse_load_dble((*sm).c3);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c3);

/******************************* direction +2 *********************************/

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c4);

   sm=pl+(*(pidn++));
   _prefetch_spinor_dble(sm);
   _sse_vector_sub_dble();
   u+=1;
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c1);

   _sse_load_dble((*sp).c4);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c4);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c3);

   _sse_vector_add_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c2);

   _sse_load_dble((*sp).c3);
   _sse_vector_add_dble();
   _sse_store_dble((*sp).c3);

/******************************* direction -2 *********************************/

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c4);

   sp=pl+(*(piup));
   _prefetch_spinor_dble(sp);
   _sse_vector_add_dble();
   u+=1;
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c1);

   _sse_load_dble((*sm).c4);
   _sse_vector_add_dble();
   _sse_store_dble((*sm).c4);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c3);

   _sse_vector_sub_dble();
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c2);

   _sse_load_dble((*sm).c3);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c3);

/******************************* direction +3 *********************************/

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c3);

   sm=pl+(*(pidn));
   _prefetch_spinor_dble(sm);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   u+=1;
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c1);

   _sse_load_dble((*sp).c3);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_store_dble((*sp).c3);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c4);

   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_su3_inverse_multiply_dble(*u);

   _sse_load_dble((*sp).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c2);

   _sse_load_dble((*sp).c4);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_store_dble((*sp).c4);

/******************************* direction -3 *********************************/

   _sse_load_dble(rs.c1);
   _sse_load_up_dble(rs.c3);

   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   u+=1;
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c1);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c1);

   _sse_load_dble((*sm).c3);
   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c3);

   _sse_load_dble(rs.c2);
   _sse_load_up_dble(rs.c4);

   _sse_vector_i_mul_dble();
   _sse_vector_sub_dble();
   _sse_su3_multiply_dble(*u);

   _sse_load_dble((*sm).c2);
   _sse_vector_sub_dble();
   _sse_store_dble((*sm).c2);

   _sse_load_dble((*sm).c4);
   _sse_vector_i_mul_dble();
   _sse_vector_add_dble();
   _sse_store_dble((*sm).c4);
}

#elif (defined DH)
#include "dh.h"

#define _dh_static_vector_declare(a) \
              static double _Complex  dcr##a##1,dcr##a##2,dcr##a##3

_dh_static_vector_declare(rs1);
_dh_static_vector_declare(rs2);
_dh_static_vector_declare(rs3);
_dh_static_vector_declare(rs4);

static void qoe(int *piup,int *pidn,su3_dble *u,spinor_dble *pk)
{
   spinor_dble *sp,*sm;

#pragma disjoint(*u,*sp,*sm)
   __alignx(16,sp);
   __alignx(16,sm);
   __alignx(16,u);

   _dh_vector_declare(1);
   _dh_vector_declare(2);
   _dh_su3_declare(1);

/******************************* direction +0 *********************************/

      sp=pk+(*(piup++));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sp).c1,1);
      _dh_vector_load((*sp).c3,2);

      _dh_vector_add(1,1,2);

      _dh_vector_load((*sp).c2,1);
      _dh_vector_load((*sp).c4,2);

      _dh_vector_add(2,1,2);

      _dh_su3_multiply(1,2,1);

      u+=1;

      _dh_vector_assign(rs1,1);
      _dh_vector_assign(rs2,2);
      _dh_vector_assign(rs3,1);
      _dh_vector_assign(rs4,2);

/******************************* direction -0 *********************************/

      sm=pk+(*(pidn++));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sm).c1,1);
      _dh_vector_load((*sm).c3,2);

      _dh_vector_sub(1,1,2);

      _dh_vector_load((*sm).c2,1);
      _dh_vector_load((*sm).c4,2);

      _dh_vector_sub(2,1,2);

      _dh_su3_inverse_multiply(1,2,1);

      u+=1;

      _dh_vector_add_assign(rs1,1);
      _dh_vector_add_assign(rs2,2);
      _dh_vector_sub_assign(rs3,1);
      _dh_vector_sub_assign(rs4,2);

/******************************* direction +1 *********************************/

      sp=pk+(*(piup++));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sp).c1,1);
      _dh_vector_load((*sp).c4,2);

      _dh_vector_i_add(1,1,2);

      _dh_vector_load((*sp).c2,1);
      _dh_vector_load((*sp).c3,2);

      _dh_vector_i_add(2,1,2);

      _dh_su3_multiply(1,2,1);

      u+=1;

      _dh_vector_add_assign(rs1,1);
      _dh_vector_add_assign(rs2,2);
      _dh_vector_i_sub_assign(rs3,2);
      _dh_vector_i_sub_assign(rs4,1);

/******************************* direction -1 *********************************/

      sm=pk+(*(pidn++));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sm).c1,1);
      _dh_vector_load((*sm).c4,2);

      _dh_vector_i_sub(1,1,2);

      _dh_vector_load((*sm).c2,1);
      _dh_vector_load((*sm).c3,2);

      _dh_vector_i_sub(2,1,2);

      _dh_su3_inverse_multiply(1,2,1);

      u+=1;

      _dh_vector_add_assign(rs1,1);
      _dh_vector_add_assign(rs2,2);
      _dh_vector_i_add_assign(rs3,2);
      _dh_vector_i_add_assign(rs4,1);

/******************************* direction +2 *********************************/

      sp=pk+(*(piup++));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sp).c1,1);
      _dh_vector_load((*sp).c4,2);

      _dh_vector_add(1,1,2);

      _dh_vector_load((*sp).c2,1);
      _dh_vector_load((*sp).c3,2);

      _dh_vector_sub(2,1,2);

      _dh_su3_multiply(1,2,1);

      u+=1;

      _dh_vector_add_assign(rs1,1);
      _dh_vector_add_assign(rs2,2);
      _dh_vector_sub_assign(rs3,2);
      _dh_vector_add_assign(rs4,1);

/******************************* direction -2 *********************************/

      sm=pk+(*(pidn++));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sm).c1,1);
      _dh_vector_load((*sm).c4,2);

      _dh_vector_sub(1,1,2);

      _dh_vector_load((*sm).c2,1);
      _dh_vector_load((*sm).c3,2);

      _dh_vector_add(2,1,2);

      _dh_su3_inverse_multiply(1,2,1);

      u+=1;

      _dh_vector_add_assign(rs1,1);
      _dh_vector_add_assign(rs2,2);
      _dh_vector_add_assign(rs3,2);
      _dh_vector_sub_assign(rs4,1);

/******************************* direction +3 *********************************/

      sp=pk+(*(piup));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sp).c1,1);
      _dh_vector_load((*sp).c3,2);

      _dh_vector_i_add(1,1,2);

      _dh_vector_load((*sp).c2,1);
      _dh_vector_load((*sp).c4,2);

      _dh_vector_i_sub(2,1,2);

      _dh_su3_multiply(1,2,1);

      u+=1;

      _dh_vector_add_assign(rs1,1);
      _dh_vector_add_assign(rs2,2);
      _dh_vector_i_sub_assign(rs3,1);
      _dh_vector_i_add_assign(rs4,2);

/******************************* direction -3 *********************************/

      sm=pk+(*(pidn));

      _dh_su3_load(*u,1);

      _dh_vector_load((*sm).c1,1);
      _dh_vector_load((*sm).c3,2);

      _dh_vector_i_sub(1,1,2);

      _dh_vector_load((*sm).c2,1);
      _dh_vector_load((*sm).c4,2);

      _dh_vector_i_add(2,1,2);

      _dh_su3_inverse_multiply(1,2,1);

      _dh_vector_add_assign(rs1,1);
      _dh_vector_add_assign(rs2,2);
      _dh_vector_i_add_assign(rs3,1);
      _dh_vector_i_sub_assign(rs4,2);

      _dh_vector_mul_assign(rs1,-coe);
      _dh_vector_mul_assign(rs2,-coe);
      _dh_vector_mul_assign(rs3,coe);
      _dh_vector_mul_assign(rs4,coe);

}


static void qeo(int *piup,int *pidn,su3_dble *u,spinor_dble *pl)
{
   spinor_dble *sp,*sm;

#pragma disjoint(*u,*sp,*sm)
   __alignx(16,sp);
   __alignx(16,sm);
   __alignx(16,u);

   _dh_vector_declare(1);
   _dh_vector_declare(2);
   _dh_vector_declare1(s1);
   _dh_vector_declare1(s2);
   _dh_su3_declare(1);

/******************************* direction +0 *********************************/

      sp=pl+(*(piup++));

      _dh_vector_sub(1,rs1,rs3);
      _dh_vector_sub(2,rs2,rs4);

      _dh_su3_load(*u,1);

      _dh_su3_inverse_multiply(1,2,1);

      _dh_vector_load((*sp).c1,s1);
      _dh_vector_load((*sp).c3,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_sub_assign(s2,1);

      _dh_vector_store((*sp).c1,s1);
      _dh_vector_store((*sp).c3,s2);

      _dh_vector_load((*sp).c2,s1);
      _dh_vector_load((*sp).c4,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_sub_assign(s2,2);

      _dh_vector_store((*sp).c2,s1);
      _dh_vector_store((*sp).c4,s2);

/******************************* direction -0 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _dh_vector_add(1,rs1,rs3);
      _dh_vector_add(2,rs2,rs4);

      _dh_su3_load(*u,1);

      _dh_su3_multiply(1,2,1);

      _dh_vector_load((*sm).c1,s1);
      _dh_vector_load((*sm).c3,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_add_assign(s2,1);

      _dh_vector_store((*sm).c1,s1);
      _dh_vector_store((*sm).c3,s2);

      _dh_vector_load((*sm).c2,s1);
      _dh_vector_load((*sm).c4,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_add_assign(s2,2);

      _dh_vector_store((*sm).c2,s1);
      _dh_vector_store((*sm).c4,s2);

/******************************* direction +1 *********************************/

      sp=pl+(*(piup++));
      u+=1;

      _dh_vector_i_sub(1,rs1,rs4);
      _dh_vector_i_sub(2,rs2,rs3);

      _dh_su3_load(*u,1);

      _dh_su3_inverse_multiply(1,2,1);

      _dh_vector_load((*sp).c1,s1);
      _dh_vector_load((*sp).c4,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_i_add_assign(s2,1);

      _dh_vector_store((*sp).c1,s1);
      _dh_vector_store((*sp).c4,s2);

      _dh_vector_load((*sp).c2,s1);
      _dh_vector_load((*sp).c3,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_i_add_assign(s2,2);

      _dh_vector_store((*sp).c2,s1);
      _dh_vector_store((*sp).c3,s2);

/******************************* direction -1 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _dh_vector_i_add(1,rs1,rs4);
      _dh_vector_i_add(2,rs2,rs3);

      _dh_su3_load(*u,1);

      _dh_su3_multiply(1,2,1);

      _dh_vector_load((*sm).c1,s1);
      _dh_vector_load((*sm).c4,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_i_sub_assign(s2,1);

      _dh_vector_store((*sm).c1,s1);
      _dh_vector_store((*sm).c4,s2);

      _dh_vector_load((*sm).c2,s1);
      _dh_vector_load((*sm).c3,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_i_sub_assign(s2,2);

      _dh_vector_store((*sm).c2,s1);
      _dh_vector_store((*sm).c3,s2);

/******************************* direction +2 *********************************/

      sp=pl+(*(piup++));
      u+=1;

      _dh_vector_sub(1,rs1,rs4);
      _dh_vector_add(2,rs2,rs3);

      _dh_su3_load(*u,1);

      _dh_su3_inverse_multiply(1,2,1);

      _dh_vector_load((*sp).c1,s1);
      _dh_vector_load((*sp).c4,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_sub_assign(s2,1);

      _dh_vector_store((*sp).c1,s1);
      _dh_vector_store((*sp).c4,s2);

      _dh_vector_load((*sp).c2,s1);
      _dh_vector_load((*sp).c3,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_add_assign(s2,2);

      _dh_vector_store((*sp).c2,s1);
      _dh_vector_store((*sp).c3,s2);

/******************************* direction -2 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _dh_vector_add(1,rs1,rs4);
      _dh_vector_sub(2,rs2,rs3);

      _dh_su3_load(*u,1);

      _dh_su3_multiply(1,2,1);

      _dh_vector_load((*sm).c1,s1);
      _dh_vector_load((*sm).c4,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_add_assign(s2,1);

      _dh_vector_store((*sm).c1,s1);
      _dh_vector_store((*sm).c4,s2);

      _dh_vector_load((*sm).c2,s1);
      _dh_vector_load((*sm).c3,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_sub_assign(s2,2);

      _dh_vector_store((*sm).c2,s1);
      _dh_vector_store((*sm).c3,s2);

/******************************* direction +3 *********************************/

      sp=pl+(*(piup));
      u+=1;

      _dh_vector_i_sub(1,rs1,rs3);
      _dh_vector_i_add(2,rs2,rs4);

      _dh_su3_load(*u,1);

      _dh_su3_inverse_multiply(1,2,1);

      _dh_vector_load((*sp).c1,s1);
      _dh_vector_load((*sp).c3,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_i_add_assign(s2,1);

      _dh_vector_store((*sp).c1,s1);
      _dh_vector_store((*sp).c3,s2);

      _dh_vector_load((*sp).c2,s1);
      _dh_vector_load((*sp).c4,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_i_sub_assign(s2,2);

      _dh_vector_store((*sp).c2,s1);
      _dh_vector_store((*sp).c4,s2);

/******************************* direction -3 *********************************/

      sm=pl+(*(pidn));
      u+=1;

      _dh_vector_i_add(1,rs1,rs3);
      _dh_vector_i_sub(2,rs2,rs4);

      _dh_su3_load(*u,1);

      _dh_su3_multiply(1,2,1);

      _dh_vector_load((*sm).c1,s1);
      _dh_vector_load((*sm).c3,s2);

      _dh_vector_sub_assign(s1,1);
      _dh_vector_i_sub_assign(s2,1);

      _dh_vector_store((*sm).c1,s1);
      _dh_vector_store((*sm).c3,s2);

      _dh_vector_load((*sm).c2,s1);
      _dh_vector_load((*sm).c4,s2);

      _dh_vector_sub_assign(s1,2);
      _dh_vector_i_add_assign(s2,2);

      _dh_vector_store((*sm).c2,s1);
      _dh_vector_store((*sm).c4,s2);

}

#elif (defined QPX)
#include "qpx.h"

//#if (defined VERBOSE_DEBUG)
#if 0
#define _print_dir(mu) \
    printf( "\ndir %s\n", mu )

#define _cv_print(a) \
    printf( "vecX = {%f+j%f, %f+j%f, %f+j%f}\n", a.c1.re, a.c1.im, a.c2.re, a.c2.im, a.c3.re, a.c3.im ) 

#define _cv_print2(a,b) \
    printf( "vecA = {%f+j%f, %f+j%f, %f+j%f}\n", a.c1.re, a.c1.im, a.c2.re, a.c2.im, a.c3.re, a.c3.im ); \
    printf( "vecB = {%f+j%f, %f+j%f, %f+j%f}\n", b.c1.re, b.c1.im, b.c2.re, b.c2.im, b.c3.re, b.c3.im ) 

#define _qpx_debug_vectorpair_print(p) \
    _qpx_vectorpair_print(p)

#else
#define _print_dir(mu)
#define _cv_print(a)
#define _cv_print2(a,b)
#define _qpx_debug_vectorpair_print(p)

#endif // get rid of debug output

_qpx_vectorpair_static_declare(r12);
_qpx_vectorpair_static_declare(r34);

static void qoe(int *piup,int *pidn, su3_dble *u, spinor_dble *pk)
{
   spinor_dble *sp,*sm;

#pragma disjoint(*u,*sp,*sm)
   __alignx(32,sp);
   __alignx(32,sm);
   __alignx(32,u);

    _qpx_su3_declare(cm);
    _qpx_vectorpair_declare(p1);
    _qpx_vectorpair_declare(p2);

/******************************* direction +0 *********************************/

      sp=pk+(*(piup++));

      _print_dir("+0");

      //_qpx_vectorpair_au_load(p1,(*sp).c1,(*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load(p2,(*sp).c3,(*sp).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(p1,p2,(*sp),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_debug_vectorpair_print( p1 );
      _qpx_debug_vectorpair_print( p2 );

      _qpx_vectorpair_add( p1, p1, p2 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( r12, cm, p1 );
      _qpx_vectorpair_assign( r34, r12 );
      
      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

/******************************* direction -0 *********************************/

      sm=pk+(*(pidn++));
      u+=1;

      _print_dir("-0");

      //_qpx_vectorpair_au_load( p1, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p2, (*sm).c3, (*sm).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(p1,p2,(*sm),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( p1, p1, p2 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      _qpx_vectorpair_add( r12, r12, p2 );
      _qpx_vectorpair_sub( r34, r34, p2 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

/******************************* direction +1 *********************************/

      sp=pk+(*(piup++));
      u+=1;

      _print_dir("+1");

      //_qpx_vectorpair_au_load( p1, (*sp).c1, (*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_ua_load( p2, (*sp).c4, (*sp).c3, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor43_load(p1,p2,(*sp),cm_1_0,cm_1_1,cm_1_2,cm_2_0);

      _qpx_vectorpair_i_add( p1, p1, p2, cm_1_0 );
      _qpx_debug_vectorpair_print( p1 );

      // p2 = U*{ s1+i*s4, s2+i*s3 }
      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      // r12 += U*{ s1+i*s4, s2+i*s3 }
      // r34 -= i*U*{ s2+i*s3, s1+i*s4 }
      _qpx_vectorpair_add( r12, r12, p2 );
      _qpx_vectorpair_i_xsub( r34, r34, p2, cm_1, cm_2_0 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

/******************************* direction -1 *********************************/

      sm=pk+(*(pidn++));
      u+=1;

      _print_dir("-1");

      //_qpx_vectorpair_au_load( p1, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_ua_load( p2, (*sm).c4, (*sm).c3, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor43_load(p1,p2,(*sm),cm_1_0,cm_1_1,cm_1_2,cm_2_0);

      _qpx_vectorpair_i_sub( p1, p1, p2, cm_1_0 );
      _qpx_debug_vectorpair_print( p1 );

      // p2 = U*{ s1-i*s4, s2-i*s3 }
      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      // r12 += U*{ s1-i*s4, s2-i*s3 }
      // r34 += i*U*{ s2-i*s3, s1-i*s4 }
      _qpx_vectorpair_add( r12, r12, p2 );
      _qpx_vectorpair_i_xadd( r34, r34, p2, cm_1, cm_2_0 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

/******************************* direction +2 *********************************/

      sp=pk+(*(piup++));
      u+=1;

      _print_dir("+2");

      //_qpx_vectorpair_au_load( p1, (*sp).c1, (*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_ua_load( p2, (*sp).c4, (*sp).c3, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor43_load(p1,p2,(*sp),cm_1_0,cm_1_1,cm_1_2,cm_2_0);

      _qpx_vectorpair_1add2sub( p1, p1, p2, cm_1_0 );
      _qpx_debug_vectorpair_print( p1 );

      // p2 = U*{ s1+s4, s2-s3 }
      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      // r12 += U*{ s1+s4, s2-s3 }
      // r34 += U*{ -1 * s2-s3, s1+s4 }
      _qpx_vectorpair_add( r12, r12, p2 );
      _qpx_vectorpair_x1sub2add( r34, r34, p2, cm_1, cm_2_0 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

/******************************* direction -2 *********************************/

      sm=pk+(*(pidn++));
      u+=1;

      _print_dir("-2");

      //_qpx_vectorpair_au_load( p1, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_ua_load( p2, (*sm).c4, (*sm).c3, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor43_load(p1,p2,(*sm),cm_1_0,cm_1_1,cm_1_2,cm_2_0);

      _qpx_vectorpair_1sub2add( p1, p1, p2, cm_1_0 );
      _qpx_debug_vectorpair_print( p1 );

      // p2 = U*{ s1-s4, s2+s3 }
      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      // r12 += U*{ s1-s4, s2+s3 }
      // r34 += U*{ s2+s3, -1 * s1-s4 }
      _qpx_vectorpair_add( r12, r12, p2 );
      _qpx_vectorpair_x1add2sub( r34, r34, p2, cm_1, cm_2_0 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

/******************************* direction +3 *********************************/

      sp=pk+(*(piup));
      u+=1;

      _print_dir("+3");

      //_qpx_vectorpair_au_load( p1, (*sp).c1, (*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p2, (*sp).c3, (*sp).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(p1,p2,(*sp),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_i_1add2sub( p1, p1, p2, cm_1_0 );
      _qpx_debug_vectorpair_print( p1 );

      // p2 = U*{ s1+i*s3, s2-i*s4 }
      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      // r12 += U*{ s1+i*s3, s2-i*s4 }
      // r34 += i*U*{ -1 * s1+i*s3, s2-i*s4 }
      _qpx_vectorpair_add( r12, r12, p2 );
      _qpx_vectorpair_i_1sub2add( r34, r34, p2, cm_1_0 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

/******************************* direction -3 *********************************/

      sm=pk+(*(pidn));
      u+=1;

      _print_dir("-3");

      //_qpx_vectorpair_au_load( p1, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p2, (*sm).c3, (*sm).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(p1,p2,(*sm),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_i_1sub2add( p1, p1, p2, cm_1_0 );
      _qpx_debug_vectorpair_print( p1 );

      // p2 = U*{ s1-i*s3, s2+i*s4 }
      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      // r12 += U*{ s1-i*s3, s2+i*s4 }
      // r34 += i*U*{ s1-i*s3, -1 * s2+i*s4 }
      _qpx_vectorpair_add( r12, r12, p2 );
      _qpx_vectorpair_i_1add2sub( r34, r34, p2, cm_1_0 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );

      cm_1_0 = VEC_LOAD_S( 0l, &coe );
      _qpx_vectorpair_mul( r34, r34, cm_1_0 );
      cm_1_0 = vec_neg( cm_1_0 );
      _qpx_vectorpair_mul( r12, r12, cm_1_0 );

      _qpx_debug_vectorpair_print( r12 );
      _qpx_debug_vectorpair_print( r34 );
}

static void qeo(int *piup,int *pidn,su3_dble *u,spinor_dble *pl)
{
   spinor_dble *sp,*sm;

#pragma disjoint(*u,*sp,*sm)
   __alignx(32,sp);
   __alignx(32,sm);
   __alignx(32,u);

    _qpx_su3_declare(cm);
    _qpx_vectorpair_declare(p1);
    _qpx_vectorpair_declare(p2);

    _qpx_debug_vectorpair_print( r12 );
    _qpx_debug_vectorpair_print( r34 );

/******************************* direction +0 *********************************/

      sp=pl+(*(piup++));

      _print_dir("+0");

      _qpx_vectorpair_sub( p1, r12, r34 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      //_qpx_vectorpair_au_load( cm_0, (*sp).c1, (*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sp).c3, (*sp).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sp),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_sub( p1, p1, p2 );

      //_qpx_vectorpair_au_store( (*sp).c1, (*sp).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sp).c3, (*sp).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sp), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sp).c1, (*sp).c2 );
      _cv_print2( (*sp).c3, (*sp).c4 );

/******************************* direction -0 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _print_dir("-0");

      _qpx_vectorpair_add( p1, r12, r34 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      _cv_print2( (*sm).c1, (*sm).c2 );
      _cv_print2( (*sm).c3, (*sm).c4 );

      //_qpx_vectorpair_au_load( cm_0, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sm).c3, (*sm).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sm),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_add( p1, p1, p2 );

      //_qpx_vectorpair_au_store( (*sm).c1, (*sm).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sm).c3, (*sm).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sm), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sm).c1, (*sm).c2 );
      _cv_print2( (*sm).c3, (*sm).c4 );

/******************************* direction +1 *********************************/

      sp=pl+(*(piup++));
      u+=1;

      _print_dir("+1");

      _qpx_vectorpair_i_xsub( p1, r12, r34, cm_1, cm_2_0 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      //_qpx_vectorpair_au_load( cm_0, (*sp).c1, (*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sp).c3, (*sp).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sp),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_i_xadd( p1, p1, p2, cm_1, cm_2_0 );

      //_qpx_vectorpair_au_store( (*sp).c1, (*sp).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sp).c3, (*sp).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sp), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sp).c1, (*sp).c2 );
      _cv_print2( (*sp).c3, (*sp).c4 );

/******************************* direction -1 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _print_dir("-1");

      _qpx_vectorpair_i_xadd( p1, r12, r34, cm_1, cm_2_0 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      //_qpx_vectorpair_au_load( cm_0, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sm).c3, (*sm).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sm),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_i_xsub( p1, p1, p2, cm_1, cm_2_0 );

      //_qpx_vectorpair_au_store( (*sm).c1, (*sm).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sm).c3, (*sm).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sm), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sm).c1 , (*sm).c2 );
      _cv_print2( (*sm).c3 , (*sm).c4 );

/******************************* direction +2 *********************************/

      sp=pl+(*(piup++));
      u+=1;

      _print_dir("+2");

      _qpx_vectorpair_x1sub2add( p1, r12, r34, cm_1, cm_2_0 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      //_qpx_vectorpair_au_load( cm_0, (*sp).c1, (*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sp).c3, (*sp).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sp),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_x1add2sub( p1, p1, p2, cm_1, cm_2_0 );

      //_qpx_vectorpair_au_store( (*sp).c1, (*sp).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sp).c3, (*sp).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sp), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sp).c1, (*sp).c2 );
      _cv_print2( (*sp).c3, (*sp).c4 );

/******************************* direction -2 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _print_dir("-2");

      _qpx_vectorpair_x1add2sub( p1, r12, r34, cm_1, cm_2_0 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      //_qpx_vectorpair_au_load( cm_0, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sm).c3, (*sm).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sm),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_x1sub2add( p1, p1, p2, cm_1, cm_2_0 );

      //_qpx_vectorpair_au_store( (*sm).c1, (*sm).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sm).c3, (*sm).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sm), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sm).c1, (*sm).c2 );
      _cv_print2( (*sm).c3, (*sm).c4 );

/******************************* direction +3 *********************************/

      sp=pl+(*(piup));
      u+=1;

      _print_dir("+3");

      _qpx_vectorpair_i_1sub2add( p1, r12, r34, p2_0 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_a_load( cm, (*u), p2_0 );
      _qpx_su3_inv_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      //_qpx_vectorpair_au_load( cm_0, (*sp).c1, (*sp).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sp).c3, (*sp).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sp),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_i_1add2sub( p1, p1, p2, cm_1_0 );

      //_qpx_vectorpair_au_store( (*sp).c1, (*sp).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sp).c3, (*sp).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sp), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sp).c1, (*sp).c2 );
      _cv_print2( (*sp).c3, (*sp).c4 );

/******************************* direction -3 *********************************/

      sm=pl+(*(pidn));
      u+=1;

      _print_dir("-3");

      _qpx_vectorpair_i_1add2sub( p1, r12, r34, p2_0 );
      _qpx_debug_vectorpair_print( p1 );

      _qpx_su3_u_load( cm, (*u), p2_0 );
      _qpx_su3_multiply( p2, cm, p1 );
      _qpx_debug_vectorpair_print( p2 );

      //_qpx_vectorpair_au_load( cm_0, (*sm).c1, (*sm).c2, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_load( p1, (*sm).c3, (*sm).c4, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_load(cm_0,p1,(*sm),cm_1_0,cm_1_1,cm_1_2 );

      _qpx_vectorpair_sub( cm_0, cm_0, p2 );
      _qpx_vectorpair_i_1sub2add( p1, p1, p2, cm_1_0 );

      //_qpx_vectorpair_au_store( (*sm).c1, (*sm).c2, cm_0, cm_1_0, cm_1_1 );
      //_qpx_vectorpair_au_store( (*sm).c3, (*sm).c4, p1, cm_1_0, cm_1_1 );
      _qpx_vectorpair_spinor34_store( (*sm), cm_0, p1, cm_1_0, cm_1_1, cm_1_2 );

      _cv_print2( (*sm).c1, (*sm).c2 );
      _cv_print2( (*sm).c3, (*sm).c4 );
}



#else

#define _vector_mul_assign(r,c) \
   (r).c1.re*=(c); \
   (r).c1.im*=(c); \
   (r).c2.re*=(c); \
   (r).c2.im*=(c); \
   (r).c3.re*=(c); \
   (r).c3.im*=(c)

static spinor_dble rs;


static void qoe(int *piup,int *pidn,su3_dble *u,spinor_dble *pk)
{
   spinor_dble *sp,*sm;
   su3_vector_dble psi,chi;

/******************************* direction +0 *********************************/

      sp=pk+(*(piup++));

      _vector_add(psi,(*sp).c1,(*sp).c3);
      _su3_multiply(rs.c1,*u,psi);
      rs.c3=rs.c1;

      _vector_add(psi,(*sp).c2,(*sp).c4);
      _su3_multiply(rs.c2,*u,psi);
      rs.c4=rs.c2;

/******************************* direction -0 *********************************/

      sm=pk+(*(pidn++));
      u+=1;

      _vector_sub(psi,(*sm).c1,(*sm).c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c1,chi);
      _vector_sub_assign(rs.c3,chi);

      _vector_sub(psi,(*sm).c2,(*sm).c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c2,chi);
      _vector_sub_assign(rs.c4,chi);

/******************************* direction +1 *********************************/

      sp=pk+(*(piup++));
      u+=1;

      _vector_i_add(psi,(*sp).c1,(*sp).c4);
      _su3_multiply(chi,*u,psi);
      _vector_add_assign(rs.c1,chi);
      _vector_i_sub_assign(rs.c4,chi);

      _vector_i_add(psi,(*sp).c2,(*sp).c3);
      _su3_multiply(chi,*u,psi);
      _vector_add_assign(rs.c2,chi);
      _vector_i_sub_assign(rs.c3,chi);

/******************************* direction -1 *********************************/

      sm=pk+(*(pidn++));
      u+=1;

      _vector_i_sub(psi,(*sm).c1,(*sm).c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c1,chi);
      _vector_i_add_assign(rs.c4,chi);

      _vector_i_sub(psi,(*sm).c2,(*sm).c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c2,chi);
      _vector_i_add_assign(rs.c3,chi);

/******************************* direction +2 *********************************/

      sp=pk+(*(piup++));
      u+=1;

      _vector_add(psi,(*sp).c1,(*sp).c4);
      _su3_multiply(chi,*u,psi);
      _vector_add_assign(rs.c1,chi);
      _vector_add_assign(rs.c4,chi);

      _vector_sub(psi,(*sp).c2,(*sp).c3);
      _su3_multiply(chi,*u,psi);
      _vector_add_assign(rs.c2,chi);
      _vector_sub_assign(rs.c3,chi);

/******************************* direction -2 *********************************/

      sm=pk+(*(pidn++));
      u+=1;

      _vector_sub(psi,(*sm).c1,(*sm).c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c1,chi);
      _vector_sub_assign(rs.c4,chi);

      _vector_add(psi,(*sm).c2,(*sm).c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c2,chi);
      _vector_add_assign(rs.c3,chi);

/******************************* direction +3 *********************************/

      sp=pk+(*(piup));
      u+=1;

      _vector_i_add(psi,(*sp).c1,(*sp).c3);
      _su3_multiply(chi,*u,psi);
      _vector_add_assign(rs.c1,chi);
      _vector_i_sub_assign(rs.c3,chi);

      _vector_i_sub(psi,(*sp).c2,(*sp).c4);
      _su3_multiply(chi,*u,psi);
      _vector_add_assign(rs.c2,chi);
      _vector_i_add_assign(rs.c4,chi);

/******************************* direction -3 *********************************/

      sm=pk+(*(pidn));
      u+=1;

      _vector_i_sub(psi,(*sm).c1,(*sm).c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c1,chi);
      _vector_i_add_assign(rs.c3,chi);

      _vector_i_add(psi,(*sm).c2,(*sm).c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_add_assign(rs.c2,chi);
      _vector_i_sub_assign(rs.c4,chi);

      _vector_mul_assign(rs.c1,-coe);
      _vector_mul_assign(rs.c2,-coe);
      _vector_mul_assign(rs.c3,coe);
      _vector_mul_assign(rs.c4,coe);
}


static void qeo(int *piup,int *pidn,su3_dble *u,spinor_dble *pl)
{
   spinor_dble *sp,*sm;
   su3_vector_dble psi,chi;

/******************************* direction +0 *********************************/

      sp=pl+(*(piup++));

      _vector_sub(psi,rs.c1,rs.c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c1,chi);
      _vector_sub_assign((*sp).c3,chi);

      _vector_sub(psi,rs.c2,rs.c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c2,chi);
      _vector_sub_assign((*sp).c4,chi);

/******************************* direction -0 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _vector_add(psi,rs.c1,rs.c3);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c1,chi);
      _vector_add_assign((*sm).c3,chi);

      _vector_add(psi,rs.c2,rs.c4);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c2,chi);
      _vector_add_assign((*sm).c4,chi);

/******************************* direction +1 *********************************/

      sp=pl+(*(piup++));
      u+=1;

      _vector_i_sub(psi,rs.c1,rs.c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c1,chi);
      _vector_i_add_assign((*sp).c4,chi);

      _vector_i_sub(psi,rs.c2,rs.c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c2,chi);
      _vector_i_add_assign((*sp).c3,chi);

/******************************* direction -1 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _vector_i_add(psi,rs.c1,rs.c4);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c1,chi);
      _vector_i_sub_assign((*sm).c4,chi);

      _vector_i_add(psi,rs.c2,rs.c3);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c2,chi);
      _vector_i_sub_assign((*sm).c3,chi);

/******************************* direction +2 *********************************/

      sp=pl+(*(piup++));
      u+=1;

      _vector_sub(psi,rs.c1,rs.c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c1,chi);
      _vector_sub_assign((*sp).c4,chi);

      _vector_add(psi,rs.c2,rs.c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c2,chi);
      _vector_add_assign((*sp).c3,chi);

/******************************* direction -2 *********************************/

      sm=pl+(*(pidn++));
      u+=1;

      _vector_add(psi,rs.c1,rs.c4);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c1,chi);
      _vector_add_assign((*sm).c4,chi);

      _vector_sub(psi,rs.c2,rs.c3);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c2,chi);
      _vector_sub_assign((*sm).c3,chi);

/******************************* direction +3 *********************************/

      sp=pl+(*(piup));
      u+=1;

      _vector_i_sub(psi,rs.c1,rs.c3);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c1,chi);
      _vector_i_add_assign((*sp).c3,chi);

      _vector_i_add(psi,rs.c2,rs.c4);
      _su3_inverse_multiply(chi,*u,psi);
      _vector_sub_assign((*sp).c2,chi);
      _vector_i_sub_assign((*sp).c4,chi);

/******************************* direction -3 *********************************/

      sm=pl+(*(pidn));
      u+=1;

      _vector_i_add(psi,rs.c1,rs.c3);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c1,chi);
      _vector_i_sub_assign((*sm).c3,chi);

      _vector_i_sub(psi,rs.c2,rs.c4);
      _su3_multiply(chi,*u,psi);
      _vector_sub_assign((*sm).c2,chi);
      _vector_i_add_assign((*sm).c4,chi);
}

#endif

void Qhat_dble(int k,int l)
{
   int *piup,*pidn,iprms[2];
   su3_dble *u,*um;
   pauli_dble *m;
   spinor_dble *pk,*pl;

#if (defined DH)
#pragma disjoint(*m,*u,*pk,*pl)
   __alignx(16,u);
   __alignx(16,m);
   __alignx(16,pk);
   __alignx(16,pl);

   _dh_weyl_vector_declare(1);
   _dh_pauli_matrix_declare(1);
#elif (defined QPX)
#pragma disjoint(*m,*u,*pk,*pl)
   __alignx(32,u);
   __alignx(32,m);
   __alignx(32,pk);
   __alignx(32,pl);

   _qpx_pauli_declare(pm);
   _qpx_vectorpair_declare(pm_x);
   _qpx_vector_declare(perm);
   _qpx_vector_declare(work);
#endif


   iprms[0]=k;
   iprms[1]=l;

   MPI_Bcast(iprms,2,MPI_INT,0,MPI_COMM_WORLD);

   error((iprms[0]!=k)||(iprms[1]!=l),1,
         "Qhat_dble [Qhat_dble.c]","Parameters k,l are not global");

   error_root((k<0)||(k>=no_sd)||(l<0)||(l>=no_sd)||(k==l),1,
              "Qhat_dble [Qhat_dble.c]","Improper arguments");

   pk=psd[k][0];
   pl=psd[l][0];

   apply_sw_dble(VOLUME/2,swd,pk,pl);

   if (NPROC>1) {
   set_sd2zero(BNDRY/2,pl+VOLUME);
   cpsd_int_bnd(k);
   }


   coe=-0.25;
   piup=&iup[(VOLUME/2)][0];
   pidn=&idn[(VOLUME/2)][0];
   m=swd+VOLUME;
   u=pud[VOLUME/2][0];
   um=u+4*VOLUME;

   for (;u<um;u+=8)
   {
#if (defined SSE2)
      _prefetch_pauli_dble(m);
      qoe(piup,pidn,u,pk);
      m+=1;
      _prefetch_pauli_dble(m);
      m-=1;
#else
      qoe(piup,pidn,u,pk);
#endif
#if (defined DH)
      _dh_weyl_vector_assign(1,rs1,rs2);
      _dh_pauli_load(*m,1);
      _dh_mul_pauli(1,1);
      m+=1;
      _dh_vector_weyl_assign(rs1,rs2,1);

      _dh_weyl_vector_assign(1,rs3,rs4);
      _dh_pauli_load(*m,1);
      m-=1;
      _dh_mul_pauli(1,1);
      _dh_vector_weyl_assign(rs3,rs4,1);

#elif (defined QPX)
      _qpx_pauli_load_all(pm,(*m));
      m+=1;
      _qpx_pauli_multiply_unsafe(pm_x,pm,r12, perm,work);
      _qpx_vectorpair_assign( r12, pm_x );

      _qpx_pauli_load_all(pm,(*m));
      m-=1;
      _qpx_pauli_multiply_unsafe(pm_x,pm,r34, perm,work);
      _qpx_vectorpair_assign( r34, pm_x );
#else
      mul_pauli_dble(m,(weyl_dble*)(&rs.c1),(weyl_dble*)(&rs.c1));
      mul_pauli_dble(m+1,(weyl_dble*)(&rs.c1)+1,(weyl_dble*)(&rs.c1)+1);
#endif
      qeo(piup,pidn,u,pl);

      piup+=4;
      pidn+=4;
      m+=2;
   }

if (NPROC>1)
   cpsd_ext_bnd(l);

}


void Qoe_dble(int k,int l)
{
   int *piup,*pidn,iprms[2];
   su3_dble *u,*um;
   spinor_dble *pk,*pl;

#if (defined DH)
#pragma disjoint(*u,*pk,*pl)
   __alignx(16,u);
   __alignx(16,pk);
   __alignx(16,pl);
#elif (defined QPX)
#pragma disjoint(*u,*pk,*pl)
   __alignx(32,u);
   __alignx(32,pk);
   __alignx(32,pl);
   _qpx_vector_declare(work1);
   _qpx_vector_declare(work2);
   _qpx_vector_declare(work3);
#endif

   iprms[0]=k;
   iprms[1]=l;

   MPI_Bcast(iprms,2,MPI_INT,0,MPI_COMM_WORLD);

   error((iprms[0]!=k)||(iprms[1]!=l),1,
         "Qoe_dble [Qhat_dble.c]","Parameters k,l are not global");

   error_root((k<0)||(k>=no_sd)||(l<0)||(l>=no_sd),1,
              "Qoe_dble [Qhat_dble.c]","Improper arguments");

   pk=psd[k][0];
   pl=psd[l][VOLUME/2];

if (NPROC>1)
   cpsd_int_bnd(k);


   coe=0.5;
   piup=&iup[VOLUME/2][0];
   pidn=&idn[VOLUME/2][0];
   u=pud[VOLUME/2][0];
   um=u+4*VOLUME;

   for (;u<um;u+=8)
   {
      qoe(piup,pidn,u,pk);

#if (defined SSE2)
      _sse_load_dble(rs.c1);
      _sse_load_up_dble(rs.c2);
      _sse_store_dble((*pl).c1);
      _sse_store_up_dble((*pl).c2);
      _sse_load_dble(rs.c3);
      _sse_load_up_dble(rs.c4);
      _sse_store_dble((*pl).c3);
      _sse_store_up_dble((*pl).c4);
#elif (defined DH)
      _dh_vector_store((*pl).c1,rs1);
      _dh_vector_store((*pl).c2,rs2);
      _dh_vector_store((*pl).c3,rs3);
      _dh_vector_store((*pl).c4,rs4);
#elif (defined QPX)
      //_qpx_vectorpair_au_store( (*pl).c1, (*pl).c2, r12, work1, work2 );
      //_qpx_vectorpair_au_store( (*pl).c3, (*pl).c4, r34, work1, work2 );
      _qpx_vectorpair_spinor34_store( (*pl), r12, r34, work1, work2, work3 );
#else
      *pl=rs;
#endif

      piup+=4;
      pidn+=4;
      pl+=1;
   }
}


void Qeo_dble(int k,int l)
{
   int *piup,*pidn,iprms[2];
   su3_dble *u,*um;
   spinor_dble *pk,*pl;

#if (defined DH)
#pragma disjoint(*u,*pk,*pl)
   __alignx(16,u);
   __alignx(16,pk);
   __alignx(16,pl);
#elif (defined QPX)
#pragma disjoint(*u,*pk,*pl)
   __alignx(32,u);
   __alignx(32,pk);
   __alignx(32,pl);
   _qpx_vector_declare(work1);
   _qpx_vector_declare(work2);
   _qpx_vector_declare(work3);
#endif

   iprms[0]=k;
   iprms[1]=l;

   MPI_Bcast(iprms,2,MPI_INT,0,MPI_COMM_WORLD);

   error((iprms[0]!=k)||(iprms[1]!=l),1,
         "Qeo_dble [Qhat_dble.c]","Parameters k,l are not global");

   error_root((k<0)||(k>=no_sd)||(l<0)||(l>=no_sd),1,
              "Qeo_dble [Qhat_dble.c]","Improper arguments");

   pk=psd[k][VOLUME/2];
   pl=psd[l][0];

if (NPROC>1)
   set_sd2zero(BNDRY/2,pl+VOLUME);


   ceo=-0.5;
   piup=&iup[VOLUME/2][0];
   pidn=&idn[VOLUME/2][0];
   u=pud[VOLUME/2][0];
   um=u+4*VOLUME;

   for (;u<um;u+=8)
   {
#if (defined SSE2)
      _load_cst(ceo);
      _sse_load_dble((*pk).c1);
      _sse_load_up_dble((*pk).c2);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c1);
      _sse_store_up_dble(rs.c2);

      _sse_load_dble((*pk).c3);
      _sse_load_up_dble((*pk).c4);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c3);
      _sse_store_up_dble(rs.c4);
#elif (defined DH)
      _dh_vector_load((*pk).c1,rs1);
      _dh_vector_load((*pk).c2,rs2);
      _dh_vector_load((*pk).c3,rs3);
      _dh_vector_load((*pk).c4,rs4);

      _dh_vector_mul_assign(rs1,ceo);
      _dh_vector_mul_assign(rs2,ceo);
      _dh_vector_mul_assign(rs3,ceo);
      _dh_vector_mul_assign(rs4,ceo);
#elif (defined QPX)
      //_qpx_vectorpair_au_load(r12,(*pk).c1,(*pk).c2, work1, work2 );
      //_qpx_vectorpair_au_load(r34,(*pk).c3,(*pk).c4, work1, work2 );
      _qpx_vectorpair_spinor34_load( r12, r34, (*pk), work1, work2, work3 );

      work1 = VEC_LOAD_S( 0l, &ceo );
      _qpx_vectorpair_mul( r12, r12, work1 );
      _qpx_vectorpair_mul( r34, r34, work1 );
#else
      _vector_mul(rs.c1,ceo,(*pk).c1);
      _vector_mul(rs.c2,ceo,(*pk).c2);
      _vector_mul(rs.c3,ceo,(*pk).c3);
      _vector_mul(rs.c4,ceo,(*pk).c4);
#endif

      qeo(piup,pidn,u,pl);

      piup+=4;
      pidn+=4;
      pk+=1;
   }

if (NPROC>1)
   cpsd_ext_bnd(l);

}


void Qnohat_dble(int k,int l)
{
   int *piup,*pidn,iprms[2];
   su3_dble *u,*um;
   pauli_dble *m;
   spinor_dble *pke,*pko,*ple,*plo;

#if (defined DH)
#pragma disjoint(*m,*u,*pke,*ple,*pko,*plo)
   __alignx(16,u);
   __alignx(16,m);
   __alignx(16,pke);
   __alignx(16,ple);
   __alignx(16,pko);
   __alignx(16,plo);

   _dh_weyl_vector_declare(1);
   _dh_pauli_matrix_declare(1);
   _dh_vector_declare1(s1);
   _dh_vector_declare1(s2);
#elif (defined QPX)
#pragma disjoint(*m,*u,*pke,*ple,*pko,*plo)
   __alignx(32,u);
   __alignx(32,m);
   __alignx(32,pke);
   __alignx(32,ple);
   __alignx(32,pko);
   __alignx(32,plo);

   _qpx_pauli_declare(pm);
   _qpx_vectorpair_declare(pm_x);
   _qpx_vectorpair_declare(x);
   _qpx_vector_declare(work1);
   _qpx_vector_declare(work2);
#endif

   iprms[0]=k;
   iprms[1]=l;
   /*
   MPI_Bcast(iprms,2,MPI_INT,0,MPI_COMM_WORLD);

   error((iprms[0]!=k)||(iprms[1]!=l),1,
         "Qnohat_dble [Qhat_dble.c]","Parameters k,l are not global");

   error_root((k<0)||(k>=no_sd)||(l<0)||(l>=no_sd)||(k==l),1,
              "Qnohat_dble [Qhat_dble.c]","Improper arguments");
   */
   pke=psd[k][0];
   pko=psd[k][VOLUME/2];
   ple=psd[l][0];
   plo=psd[l][VOLUME/2];

   apply_sw_dble(VOLUME/2,swd,pke,ple);

   if (NPROC>1) {
   set_sd2zero(BNDRY/2,ple+VOLUME);
   cpsd_int_bnd(k);
   }


   coe=0.5;
   ceo=0.5;
   piup=&iup[VOLUME/2][0];
   pidn=&idn[VOLUME/2][0];
   m=swd+VOLUME;
   u=pud[VOLUME/2][0];
   um=u+4*VOLUME;

   for (;u<um;u+=8)
   {
#if (defined SSE2)
      _prefetch_pauli_dble(m);
#endif      
      qoe(piup,pidn,u,pke);
#if (defined SSE2)
      m+=1;
      _prefetch_pauli_dble(m);
      m-=1;
#endif

#if (defined QPX)
      //_qpx_vectorpair_au_load( x, (*pko).c1, (*pko).c2, work1, work2 );
      _qpx_vectorpair_weyl_load( x, (*pko), work1, work2 );
      _qpx_pauli_load_all(pm,(*m));
      m+=1;
      _qpx_pauli_multiply_unsafe(pm_x,pm,x, work1, work2 );
      _qpx_vectorpair_add( pm_x, pm_x, r12 );
      //_qpx_vectorpair_au_store( (*plo).c1, (*plo).c2, pm_x, work1, work2 );
      _qpx_vectorpair_weyl_store( (*plo), pm_x, x, work1 );

      //_qpx_vectorpair_au_load( x, (*pko).c3, (*pko).c4, work1, work2 );
      _qpx_vectorpair_weyl34_load( x, (*pko), work1, work2 );
      _qpx_pauli_load_all(pm,(*m));
      m-=1;
      _qpx_pauli_multiply_unsafe(pm_x,pm,x, work1, work2 );
      _qpx_vectorpair_add( pm_x, pm_x, r34 );
      //_qpx_vectorpair_au_store( (*plo).c3, (*plo).c4, pm_x, work1, work2 );
      _qpx_vectorpair_weyl34_store( (*plo), pm_x, x, work1 );
#else
      mul_pauli_dble(m,(weyl_dble*)(pko),(weyl_dble*)(plo));
      mul_pauli_dble(m+1,(weyl_dble*)(pko)+1,(weyl_dble*)(plo)+1);
#endif 


#if (defined SSE2)      
      _sse_load_dble((*plo).c1);
      _sse_load_up_dble((*plo).c2);

      __asm__ __volatile__ ("addpd %0, %%xmm0 \n\t"
                            "addpd %1, %%xmm1 \n\t"
                            "addpd %2, %%xmm2 \n\t"
                            "addpd %3, %%xmm3 \n\t"
                            "addpd %4, %%xmm4 \n\t"
                            "addpd %5, %%xmm5"
                            : \
                            :
                            "m" (rs.c1.c1.re),
                            "m" (rs.c1.c2.re),
                            "m" (rs.c1.c3.re),
                            "m" (rs.c2.c1.re),
                            "m" (rs.c2.c2.re),
                            "m" (rs.c2.c3.re)
                            :
                            "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5");
                            
      _sse_store_dble((*plo).c1);
      _sse_store_up_dble((*plo).c2);

      _sse_load_dble((*plo).c3);
      _sse_load_up_dble((*plo).c4);

      __asm__ __volatile__ ("addpd %0, %%xmm0 \n\t"
                            "addpd %1, %%xmm1 \n\t"
                            "addpd %2, %%xmm2 \n\t"
                            "addpd %3, %%xmm3 \n\t"
                            "addpd %4, %%xmm4 \n\t"
                            "addpd %5, %%xmm5"
                            : \
                            :
                            "m" (rs.c3.c1.re),
                            "m" (rs.c3.c2.re),
                            "m" (rs.c3.c3.re),
                            "m" (rs.c4.c1.re),
                            "m" (rs.c4.c2.re),
                            "m" (rs.c4.c3.re)
                            :
                            "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5");
                            
      _sse_store_dble((*plo).c3);
      _sse_store_up_dble((*plo).c4);

      _load_cst(ceo);
      _sse_load_dble((*pko).c1);
      _sse_load_up_dble((*pko).c2);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c1);
      _sse_store_up_dble(rs.c2);

      _sse_load_dble((*pko).c3);
      _sse_load_up_dble((*pko).c4);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c3);
      _sse_store_up_dble(rs.c4);
#elif (defined DH)
      _dh_vector_load((*plo).c1,s1);
      _dh_vector_load((*plo).c2,s2);
      _dh_vector_add_assign(s1,rs1);
      _dh_vector_add_assign(s2,rs2);
      _dh_vector_store((*plo).c1,s1);
      _dh_vector_store((*plo).c2,s2);

      _dh_vector_load((*plo).c3,s1);
      _dh_vector_load((*plo).c4,s2);
      _dh_vector_add_assign(s1,rs3);
      _dh_vector_add_assign(s2,rs4);
      _dh_vector_store((*plo).c3,s1);
      _dh_vector_store((*plo).c4,s2);

      _dh_vector_load((*pko).c1,rs1);
      _dh_vector_load((*pko).c2,rs2);
      _dh_vector_load((*pko).c3,rs3);
      _dh_vector_load((*pko).c4,rs4);

      _dh_vector_mul_assign(rs1,ceo);
      _dh_vector_mul_assign(rs2,ceo);
      _dh_vector_mul_assign(rs3,ceo);
      _dh_vector_mul_assign(rs4,ceo);
#elif (defined QPX)
      //_qpx_vectorpair_au_load( x, (*pko).c1, (*pko).c2, work1, work2 );
      //_qpx_vectorpair_au_load( pm_x, (*pko).c3, (*pko).c4, work1, work2 );
      _qpx_vectorpair_spinor34_load( x, pm_x, (*pko), work1, work2, pm_0 );

      work1 = VEC_LOAD_S( 0l, &ceo );
      _qpx_vectorpair_mul( r12, x, work1 );
      _qpx_vectorpair_mul( r34, pm_x, work1 );
#else
      _vector_add_assign((*plo).c1,rs.c1);
      _vector_add_assign((*plo).c2,rs.c2);
      _vector_add_assign((*plo).c3,rs.c3);
      _vector_add_assign((*plo).c4,rs.c4);

      _vector_mul(rs.c1,ceo,(*pko).c1);
      _vector_mul(rs.c2,ceo,(*pko).c2);
      _vector_mul(rs.c3,ceo,(*pko).c3);
      _vector_mul(rs.c4,ceo,(*pko).c4);
#endif
      qeo(piup,pidn,u,ple);

      piup+=4;
      pidn+=4;
      pko+=1;
      plo+=1;
      m+=2;
   }

   if (NPROC>1)
     cpsd_ext_bnd(l);

}


/*
void Qnohat_dble_ptr(spinor_dble *psdk, spinor_dble *psdl)
{
   int *piup,*pidn,iprms[2];
   su3_dble *u,*um;
   pauli_dble *m;
   spinor_dble *pke,*pko,*ple,*plo;
   int k, l;

   k = (psdk-psd[0][0])/NSPIN;
   l = (psdl-psd[0][0])/NSPIN;

#if (defined DH)
#pragma disjoint(*m,*u,*pke,*ple,*pko,*plo)
   __alignx(16,u);
   __alignx(16,m);
   __alignx(16,pke);
   __alignx(16,ple);
   __alignx(16,pko);
   __alignx(16,plo);

   _dh_weyl_vector_declare(1);
   _dh_pauli_matrix_declare(1);
   _dh_vector_declare1(s1);
   _dh_vector_declare1(s2);
#endif

   iprms[0]=k;
   iprms[1]=l;

   MPI_Bcast(iprms,2,MPI_INT,0,MPI_COMM_WORLD);

   error((iprms[0]!=k)||(iprms[1]!=l),1,
         "Qnohat_dble [Qhat_dble.c]","Parameters k,l are not global");

   error_root((k<0)||(k>=no_sd)||(l<0)||(l>=no_sd)||(k==l),1,
              "Qnohat_dble [Qhat_dble.c]","Improper arguments");

   pke=psd[k][0];
   pko=psd[k][VOLUME/2];
   ple=psd[l][0];
   plo=psd[l][VOLUME/2];

   apply_sw_dble(VOLUME/2,swd,pke,ple);

   if (NPROC>1) {
   set_sd2zero(BNDRY/2,ple+VOLUME);
   cpsd_int_bnd(k);
   }


   coe=0.5;
   ceo=0.5;
   piup=&iup[VOLUME/2][0];
   pidn=&idn[VOLUME/2][0];
   m=swd+VOLUME;
   u=pud[VOLUME/2][0];
   um=u+4*VOLUME;

   for (;u<um;u+=8)
   {
#if (defined SSE2)
      _prefetch_pauli_dble(m);
#endif      
      qoe(piup,pidn,u,pke);
#if (defined SSE2)
      m+=1;
      _prefetch_pauli_dble(m);
      m-=1;
#endif
      mul_pauli_dble(m,(weyl_dble*)(pko),(weyl_dble*)(plo));
      mul_pauli_dble(m+1,(weyl_dble*)(pko)+1,(weyl_dble*)(plo)+1);
      
#if (defined SSE2)      
      _sse_load_dble((*plo).c1);
      _sse_load_up_dble((*plo).c2);

      __asm__ __volatile__ ("addpd %0, %%xmm0 \n\t"
                            "addpd %1, %%xmm1 \n\t"
                            "addpd %2, %%xmm2 \n\t"
                            "addpd %3, %%xmm3 \n\t"
                            "addpd %4, %%xmm4 \n\t"
                            "addpd %5, %%xmm5"
                            : \
                            :
                            "m" (rs.c1.c1.re),
                            "m" (rs.c1.c2.re),
                            "m" (rs.c1.c3.re),
                            "m" (rs.c2.c1.re),
                            "m" (rs.c2.c2.re),
                            "m" (rs.c2.c3.re)
                            :
                            "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5");
                            
      _sse_store_dble((*plo).c1);
      _sse_store_up_dble((*plo).c2);

      _sse_load_dble((*plo).c3);
      _sse_load_up_dble((*plo).c4);

      __asm__ __volatile__ ("addpd %0, %%xmm0 \n\t"
                            "addpd %1, %%xmm1 \n\t"
                            "addpd %2, %%xmm2 \n\t"
                            "addpd %3, %%xmm3 \n\t"
                            "addpd %4, %%xmm4 \n\t"
                            "addpd %5, %%xmm5"
                            : \
                            :
                            "m" (rs.c3.c1.re),
                            "m" (rs.c3.c2.re),
                            "m" (rs.c3.c3.re),
                            "m" (rs.c4.c1.re),
                            "m" (rs.c4.c2.re),
                            "m" (rs.c4.c3.re)
                            :
                            "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5");
                            
      _sse_store_dble((*plo).c3);
      _sse_store_up_dble((*plo).c4);

      _load_cst(ceo);
      _sse_load_dble((*pko).c1);
      _sse_load_up_dble((*pko).c2);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c1);
      _sse_store_up_dble(rs.c2);

      _sse_load_dble((*pko).c3);
      _sse_load_up_dble((*pko).c4);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c3);
      _sse_store_up_dble(rs.c4);
#elif (defined DH)
      _dh_vector_load((*plo).c1,s1);
      _dh_vector_load((*plo).c2,s2);
      _dh_vector_add_assign(s1,rs1);
      _dh_vector_add_assign(s2,rs2);
      _dh_vector_store((*plo).c1,s1);
      _dh_vector_store((*plo).c2,s2);

      _dh_vector_load((*plo).c3,s1);
      _dh_vector_load((*plo).c4,s2);
      _dh_vector_add_assign(s1,rs3);
      _dh_vector_add_assign(s2,rs4);
      _dh_vector_store((*plo).c3,s1);
      _dh_vector_store((*plo).c4,s2);

      _dh_vector_load((*pko).c1,rs1);
      _dh_vector_load((*pko).c2,rs2);
      _dh_vector_load((*pko).c3,rs3);
      _dh_vector_load((*pko).c4,rs4);

      _dh_vector_mul_assign(rs1,ceo);
      _dh_vector_mul_assign(rs2,ceo);
      _dh_vector_mul_assign(rs3,ceo);
      _dh_vector_mul_assign(rs4,ceo);
#else
      _vector_add_assign((*plo).c1,rs.c1);
      _vector_add_assign((*plo).c2,rs.c2);
      _vector_add_assign((*plo).c3,rs.c3);
      _vector_add_assign((*plo).c4,rs.c4);

      _vector_mul(rs.c1,ceo,(*pko).c1);
      _vector_mul(rs.c2,ceo,(*pko).c2);
      _vector_mul(rs.c3,ceo,(*pko).c3);
      _vector_mul(rs.c4,ceo,(*pko).c4);
#endif
      qeo(piup,pidn,u,ple);

      piup+=4;
      pidn+=4;
      pko+=1;
      plo+=1;
      m+=2;
   }

   if (NPROC>1)
     cpsd_ext_bnd(l);

}
*/

 /*

void Qhat_blk_dble(block_t *b,int k,int l)
{
   int *piup,*pidn;
   su3_dble *u,*um;
   spinor_dble *pk,*pl;
   pauli_dble *m;

#if (defined DH)
#pragma disjoint(*m,*u,*pk,*pl)
   __alignx(16,u);
   __alignx(16,m);
   __alignx(16,pk);
   __alignx(16,pl);

   _dh_weyl_vector_declare(1);
   _dh_pauli_matrix_declare(1);
#endif

   if (error_loc((k<0)||(k>=(*b).nsd)||(l<0)||(l>=(*b).nsd)||(k==l),1,
                 "Qhat_blk_dble [Qhat_dble.c]","Improper arguments")!=0)
      return;

   pk=(*b).sd[k];
   pl=(*b).sd[l];

   apply_sw_dble((*b).volh,(*b).swd,pk,pl);

   pk[(*b).vol]=sd0;
   pl[(*b).vol]=sd0;

   coe=-0.25;
   piup=(*b).iup[(*b).volh];
   pidn=(*b).idn[(*b).volh];
   m=(*b).swd+(*b).vol;
   u=(*b).ud[0];
   um=u+4*(*b).vol;

   for (;u<um;u+=8)
   {
#if (defined SSE2)
      _prefetch_pauli_dble(m);
#endif      
      qoe(piup,pidn,u,pk);
#if (defined SSE2)
      m+=1;
      _prefetch_pauli_dble(m);
      m-=1;
#endif
#if (defined DH)
      _dh_weyl_vector_assign(1,rs1,rs2);
      _dh_pauli_load(*m,1);
      _dh_mul_pauli(1,1);
      m+=1;
      _dh_vector_weyl_assign(rs1,rs2,1);

      _dh_weyl_vector_assign(1,rs3,rs4);
      _dh_pauli_load(*m,1);
      m-=1;
      _dh_mul_pauli(1,1);
      _dh_vector_weyl_assign(rs3,rs4,1);
#else
      mul_pauli_dble(m,(weyl_dble*)(&rs.c1),(weyl_dble*)(&rs.c1));
      mul_pauli_dble(m+1,(weyl_dble*)(&rs.c1)+1,(weyl_dble*)(&rs.c1)+1);
#endif

      qeo(piup,pidn,u,pl);

      piup+=4;
      pidn+=4;
      m+=2;
   }
}


void Qoe_blk_dble(block_t *b,int k,int l)
{
   int *piup,*pidn;
   su3_dble *u,*um;
   spinor_dble *pk,*pl;

#if (defined DH)
#pragma disjoint(*u,*pk,*pl)
   __alignx(16,u);
   __alignx(16,pk);
   __alignx(16,pl);
#endif

   if (error_loc((k<0)||(k>=(*b).nsd)||(l<0)||(l>=(*b).nsd),1,
                 "Qoe_blk_dble [Qhat_dble.c]","Improper arguments")!=0)
      return;

   pk=(*b).sd[k];
   pl=(*b).sd[l]+(*b).volh;

   pk[(*b).vol]=sd0;

   coe=0.5;
   piup=(*b).iup[(*b).volh];
   pidn=(*b).idn[(*b).volh];
   u=(*b).ud[0];
   um=u+4*(*b).vol;

   for (;u<um;u+=8)
   {
      qoe(piup,pidn,u,pk);

#if (defined SSE2)
      _sse_load_dble(rs.c1);
      _sse_load_up_dble(rs.c2);
      _sse_store_dble((*pl).c1);
      _sse_store_up_dble((*pl).c2);
      _sse_load_dble(rs.c3);
      _sse_load_up_dble(rs.c4);
      _sse_store_dble((*pl).c3);
      _sse_store_up_dble((*pl).c4);
#elif (defined DH)
      _dh_vector_store((*pl).c1,rs1);
      _dh_vector_store((*pl).c2,rs2);
      _dh_vector_store((*pl).c3,rs3);
      _dh_vector_store((*pl).c4,rs4);
#else
      *pl=rs;
#endif

      piup+=4;
      pidn+=4;
      pl+=1;
   }
}


void Qeo_blk_dble(block_t *b,int k,int l)
{
   int *piup,*pidn;
   su3_dble *u,*um;
   spinor_dble *pk,*pl;

#if (defined DH)
#pragma disjoint(*u,*pk,*pl)
   __alignx(16,u);
   __alignx(16,pk);
   __alignx(16,pl);
#endif

   if (error_loc((k<0)||(k>=(*b).nsd)||(l<0)||(l>=(*b).nsd),1,
                 "Qeo_blk_dble [Qhat_dble.c]","Improper arguments")!=0)
      return;

   pk=(*b).sd[k]+(*b).volh;
   pl=(*b).sd[l];

   pl[(*b).vol]=sd0;

   ceo=-0.5;
   piup=(*b).iup[(*b).volh];
   pidn=(*b).idn[(*b).volh];
   u=(*b).ud[0];
   um=u+4*(*b).vol;

   for (;u<um;u+=8)
   {
#if (defined SSE2)
      _load_cst(ceo);
      _sse_load_dble((*pk).c1);
      _sse_load_up_dble((*pk).c2);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c1);
      _sse_store_up_dble(rs.c2);

      _sse_load_dble((*pk).c3);
      _sse_load_up_dble((*pk).c4);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c3);
      _sse_store_up_dble(rs.c4);
#elif (defined DH)
      _dh_vector_load((*pk).c1,rs1);
      _dh_vector_load((*pk).c2,rs2);
      _dh_vector_load((*pk).c3,rs3);
      _dh_vector_load((*pk).c4,rs4);

      _dh_vector_mul_assign(rs1,ceo);
      _dh_vector_mul_assign(rs2,ceo);
      _dh_vector_mul_assign(rs3,ceo);
      _dh_vector_mul_assign(rs4,ceo);
#else
      _vector_mul(rs.c1,ceo,(*pk).c1);
      _vector_mul(rs.c2,ceo,(*pk).c2);
      _vector_mul(rs.c3,ceo,(*pk).c3);
      _vector_mul(rs.c4,ceo,(*pk).c4);
#endif

      qeo(piup,pidn,u,pl);

      piup+=4;
      pidn+=4;
      pk+=1;
   }
}


void Qnohat_blk_dble(block_t *b,int k,int l)
{
   int *piup,*pidn;
   su3_dble *u,*um;
   spinor_dble *pke,*pko,*ple,*plo;
   pauli_dble *m;

#if (defined DH)
#pragma disjoint(*m,*u,*pke,*ple,*pko,*plo)
   __alignx(16,u);
   __alignx(16,m);
   __alignx(16,pke);
   __alignx(16,ple);
   __alignx(16,pko);
   __alignx(16,plo);

   _dh_weyl_vector_declare(1);
   _dh_pauli_matrix_declare(1);
   _dh_vector_declare1(s1);
   _dh_vector_declare1(s2);
#endif

   if (error_loc((k<0)||(k>=(*b).nsd)||(l<0)||(l>=(*b).nsd)||(k==l),1,
                 "Qnohat_blk_dble [Qhat_dble.c]","Improper arguments")!=0)
      return;

   pke=(*b).sd[k];
   pko=(*b).sd[k]+(*b).volh;
   ple=(*b).sd[l];
   plo=(*b).sd[l]+(*b).volh;

   apply_sw_dble((*b).volh,(*b).swd,pke,ple);

   pke[(*b).vol]=sd0;
   ple[(*b).vol]=sd0;

   coe=0.5;
   ceo=0.5;
   piup=(*b).iup[(*b).volh];
   pidn=(*b).idn[(*b).volh];
   m=(*b).swd+(*b).vol;
   u=(*b).ud[0];
   um=u+4*(*b).vol;

   for (;u<um;u+=8)
   {
#if (defined SSE2)
      _prefetch_pauli_dble(m);
#endif
      qoe(piup,pidn,u,pke);
#if (defined SSE2)
      m+=1;
      _prefetch_pauli_dble(m);
      m-=1;
#endif      
      mul_pauli_dble(m,(weyl_dble*)(pko),(weyl_dble*)(plo));
      mul_pauli_dble(m+1,(weyl_dble*)(pko)+1,(weyl_dble*)(plo)+1);

#if (defined SSE2)      
      _sse_load_dble((*plo).c1);
      _sse_load_up_dble((*plo).c2);

      __asm__ __volatile__ ("addpd %0, %%xmm0 \n\t"
                            "addpd %1, %%xmm1 \n\t"
                            "addpd %2, %%xmm2 \n\t"
                            "addpd %3, %%xmm3 \n\t"
                            "addpd %4, %%xmm4 \n\t"
                            "addpd %5, %%xmm5"
                            : \
                            :
                            "m" (rs.c1.c1.re),
                            "m" (rs.c1.c2.re),
                            "m" (rs.c1.c3.re),
                            "m" (rs.c2.c1.re),
                            "m" (rs.c2.c2.re),
                            "m" (rs.c2.c3.re)
                            :
                            "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5");
                            
      _sse_store_dble((*plo).c1);
      _sse_store_up_dble((*plo).c2);

      _sse_load_dble((*plo).c3);
      _sse_load_up_dble((*plo).c4);

      __asm__ __volatile__ ("addpd %0, %%xmm0 \n\t"
                            "addpd %1, %%xmm1 \n\t"
                            "addpd %2, %%xmm2 \n\t"
                            "addpd %3, %%xmm3 \n\t"
                            "addpd %4, %%xmm4 \n\t"
                            "addpd %5, %%xmm5"
                            : \
                            :
                            "m" (rs.c3.c1.re),
                            "m" (rs.c3.c2.re),
                            "m" (rs.c3.c3.re),
                            "m" (rs.c4.c1.re),
                            "m" (rs.c4.c2.re),
                            "m" (rs.c4.c3.re)
                            :
                            "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5");
                            
      _sse_store_dble((*plo).c3);
      _sse_store_up_dble((*plo).c4);

      _load_cst(ceo);
      _sse_load_dble((*pko).c1);
      _sse_load_up_dble((*pko).c2);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c1);
      _sse_store_up_dble(rs.c2);

      _sse_load_dble((*pko).c3);
      _sse_load_up_dble((*pko).c4);
      _mul_cst();
      _mul_cst_up();
      _sse_store_dble(rs.c3);
      _sse_store_up_dble(rs.c4);
#elif (defined DH)
      _dh_vector_load((*plo).c1,s1);
      _dh_vector_load((*plo).c2,s2);
      _dh_vector_add_assign(s1,rs1);
      _dh_vector_add_assign(s2,rs2);
      _dh_vector_store((*plo).c1,s1);
      _dh_vector_store((*plo).c2,s2);

      _dh_vector_load((*plo).c3,s1);
      _dh_vector_load((*plo).c4,s2);
      _dh_vector_add_assign(s1,rs3);
      _dh_vector_add_assign(s2,rs4);
      _dh_vector_store((*plo).c3,s1);
      _dh_vector_store((*plo).c4,s2);

      _dh_vector_load((*pko).c1,rs1);
      _dh_vector_load((*pko).c2,rs2);
      _dh_vector_load((*pko).c3,rs3);
      _dh_vector_load((*pko).c4,rs4);

      _dh_vector_mul_assign(rs1,ceo);
      _dh_vector_mul_assign(rs2,ceo);
      _dh_vector_mul_assign(rs3,ceo);
      _dh_vector_mul_assign(rs4,ceo);
#else
      _vector_add_assign((*plo).c1,rs.c1);
      _vector_add_assign((*plo).c2,rs.c2);
      _vector_add_assign((*plo).c3,rs.c3);
      _vector_add_assign((*plo).c4,rs.c4);

      _vector_mul(rs.c1,ceo,(*pko).c1);
      _vector_mul(rs.c2,ceo,(*pko).c2);
      _vector_mul(rs.c3,ceo,(*pko).c3);
      _vector_mul(rs.c4,ceo,(*pko).c4);
#endif

      qeo(piup,pidn,u,ple);

      piup+=4;
      pidn+=4;
      pko+=1;
      plo+=1;
      m+=2;
   }
}
*/
