From 1364d4652c65fe697fd78b10540cb080efaaf93c Mon Sep 17 00:00:00 2001
From: wierenga <sdos@astron.nl>
Date: Thu, 16 Nov 2006 13:52:00 +0000
Subject: [PATCH] BugID: 973 Taking the conjugate of the beamformer weight
 before sending it to the hardware was missing. This is needed because:

  //
  // conjugate weights to get the correct matrix

  // weight a_r + i . a_i
  //
  // (a_r + i . a_i) . (x_r + i . x_i) = ( a_r . x_r - a_i . x_i ) + i ( a_i . x_r + a_r . x_i )
  //
  // This is equal to:
  //
  // ( x_out_r )   ( a_r  -a_i )   ( x_in_r )
  // (         ) = (           ) * (        )
  // ( x_out_i )   ( a_i   a_r )   ( x_in_i )
  //
  // and the same for y
  //
  // To send to correct weights to the beamformer we must therefore
  // take the conjugate of the weight (a_r, a_i) to produce (a_r, -a_i)
  // for the x_our_r component and take the conjugate AND multiply by i
  // the weight (a_r, a_i) to produce (a_i, a_r).
  //
---
 MAC/APL/PIC/RSPDriver/src/BWWrite.cc | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/MAC/APL/PIC/RSPDriver/src/BWWrite.cc b/MAC/APL/PIC/RSPDriver/src/BWWrite.cc
index f8cfa60777e..57d3b8e3a6f 100644
--- a/MAC/APL/PIC/RSPDriver/src/BWWrite.cc
+++ b/MAC/APL/PIC/RSPDriver/src/BWWrite.cc
@@ -157,7 +157,27 @@ void BWWrite::sendrequest()
   m_remaining -= size;
   m_offset    += size;
 
-  //int xc_gain = GET_CONFIG("RSPDriver.XC_GAIN", i);
+  //
+  // conjugate weights to get the correct matrix
+
+  // weight a_r + i . a_i
+  //
+  // (a_r + i . a_i) . (x_r + i . x_i) = ( a_r . x_r - a_i . x_i ) + i ( a_i . x_r + a_r . x_i )
+  //
+  // This is equal to:
+  //
+  // ( x_out_r )   ( a_r  -a_i )   ( x_in_r )
+  // (         ) = (           ) * (        )
+  // ( x_out_i )   ( a_i   a_r )   ( x_in_i )
+  // 
+  // and the same for y
+  //
+  // To send to correct weights to the beamformer we must therefore
+  // take the conjugate of the weight (a_r, a_i) to produce (a_r, -a_i)
+  // for the x_our_r component and take the conjugate AND multiply by i
+  // the weight (a_r, a_i) to produce (a_i, a_r).
+  //
+  weights = conj(weights);
 
   switch (m_regid)
   {
@@ -173,6 +193,7 @@ void BWWrite::sendrequest()
 
     case MEPHeader::BF_XIOUT:
     {
+      // multiply by i to get correct weights
       // weights for x-imaginary part
       weights *= complex<int16>(0,1);
 
@@ -193,6 +214,7 @@ void BWWrite::sendrequest()
     
     case MEPHeader::BF_YIOUT:
     {
+      // multiply by i to get correct weights
       // weights for y-imaginary part
       weights *= complex<int16>(0,1);
 
-- 
GitLab