#/*
#==============================================================================
#
# cg_d.h
#
#------------------------------------------------------------------------------
#
# Copyright (C) 2016 Hinnerk Stueben
#
# This file is part of BQCD -- Berlin Quantum ChromoDynamics program
#
# BQCD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BQCD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BQCD.  If not, see <http://www.gnu.org/licenses/>.
#
#------------------------------------------------------------------------------
#*/

# define reIN_fwd(ii,jj,kk) Real(SpincolIN(a_fwd, ii, jj, kk, jf))
# define imIN_fwd(ii,jj,kk) Imag(SpincolIN(a_fwd, ii, jj, kk, jf))
# define reIN_bwd(ii,jj,kk) Real(SpincolIN(a_bwd, ii, jj, kk, jb))
# define imIN_bwd(ii,jj,kk) Imag(SpincolIN(a_bwd, ii, jj, kk, jb))

# define reINPUT_fwd(ii,jj,kk,index) Real(SpincolIN(a_fwd, ii, jj, kk, index))
# define imINPUT_fwd(ii,jj,kk,index) Imag(SpincolIN(a_fwd, ii, jj, kk, index))
# define reINPUT_bwd(ii,jj,kk,index) Real(SpincolIN(a_bwd, ii, jj, kk, index))
# define imINPUT_bwd(ii,jj,kk,index) Imag(SpincolIN(a_bwd, ii, jj, kk, index))

# define reOUT(ii,jj,kk) Real(SpincolOUT(b, ii, jj, kk, i))
# define imOUT(ii,jj,kk) Imag(SpincolOUT(b, ii, jj, kk, i))

# define reU_fwd(ii,jj) Real(Gauge(u_fwd, ii, jj, i))
# define imU_fwd(ii,jj) Imag(Gauge(u_fwd, ii, jj, i))

#ifdef SIMD_HACK
# define reU_bwd(ii,jj) Real(Gauge(u_bwd, ii, jj, i))
# define imU_bwd(ii,jj) Imag(Gauge(u_bwd, ii, jj, i))
#else
# define reU_bwd(ii,jj) Real(Gauge(u_bwd, ii, jj, jb))
# define imU_bwd(ii,jj) Imag(Gauge(u_bwd, ii, jj, jb))
#endif

#ifdef SIMD
#ifdef LANGUAGE_C
#if SIMD_WIDTH == 1
static REAL ATTRIBUTE_ALIGNED mask0001[SIMD_WIDTH] = { 1 };
static REAL ATTRIBUTE_ALIGNED mask0111[SIMD_WIDTH] = { 0 };
static REAL ATTRIBUTE_ALIGNED mask1000[SIMD_WIDTH] = { 1 };
static REAL ATTRIBUTE_ALIGNED mask1110[SIMD_WIDTH] = { 0 };
#elif SIMD_WIDTH == 2
static REAL ATTRIBUTE_ALIGNED mask0001[SIMD_WIDTH] = { 0,1 };
static REAL ATTRIBUTE_ALIGNED mask0111[SIMD_WIDTH] = { 0,1 };
static REAL ATTRIBUTE_ALIGNED mask1000[SIMD_WIDTH] = { 1,0 };
static REAL ATTRIBUTE_ALIGNED mask1110[SIMD_WIDTH] = { 1,0 };
#elif SIMD_WIDTH == 4
static REAL ATTRIBUTE_ALIGNED mask0001[SIMD_WIDTH] = { 0,0,0,1 };
static REAL ATTRIBUTE_ALIGNED mask0111[SIMD_WIDTH] = { 0,1,1,1 };
static REAL ATTRIBUTE_ALIGNED mask1000[SIMD_WIDTH] = { 1,0,0,0 };
static REAL ATTRIBUTE_ALIGNED mask1110[SIMD_WIDTH] = { 1,1,1,0 };
#elif SIMD_WIDTH == 8
static REAL ATTRIBUTE_ALIGNED mask0001[SIMD_WIDTH] = { 0,0,0,0,0,0,0,1 };
static REAL ATTRIBUTE_ALIGNED mask0111[SIMD_WIDTH] = { 0,1,1,1,1,1,1,1 };
static REAL ATTRIBUTE_ALIGNED mask1000[SIMD_WIDTH] = { 1,0,0,0,0,0,0,0 };
static REAL ATTRIBUTE_ALIGNED mask1110[SIMD_WIDTH] = { 1,1,1,1,1,1,1,0 };
#elif SIMD_WIDTH == 16
static REAL ATTRIBUTE_ALIGNED mask0001[SIMD_WIDTH] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 };
static REAL ATTRIBUTE_ALIGNED mask0111[SIMD_WIDTH] = { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
static REAL ATTRIBUTE_ALIGNED mask1000[SIMD_WIDTH] = { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
static REAL ATTRIBUTE_ALIGNED mask1110[SIMD_WIDTH] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 };
#else
# error "unknown SIMD_WIDTH"
#endif
#endif
#endif
