From c75ac3d68f1ebc303d85ef46330adfbe80b7c87b Mon Sep 17 00:00:00 2001
From: Peter Bannister <prb@fmrib.ox.ac.uk>
Date: Sun, 22 Jun 2003 12:48:10 +0000
Subject: [PATCH] added in_slice option to optimise.[h,cc]

---
 optimise.cc | 9 ++++++---
 optimise.h  | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/optimise.cc b/optimise.cc
index 75ac5aa..9c6f24c 100644
--- a/optimise.cc
+++ b/optimise.cc
@@ -247,7 +247,7 @@ namespace MISCMATHS {
   
   float optimise(ColumnVector &pt, int numopt, const ColumnVector &tol, 
 		 float (*func)(const ColumnVector &), int &iterations_done, 
-		 int max_iter, const ColumnVector& boundguess)
+		 int max_iter, const ColumnVector& boundguess, const bool in_slice)
   {
     // Calculate dot product of dir by tol
     //  st (x1-x2)*dir_tol = average number of tolerances between x1 and x2
@@ -270,8 +270,11 @@ namespace MISCMATHS {
 	for (int n=1; n<=numopt; n++) {
 	  dir = 0.0;
 	  dir(n) = 1.0;
-	  fval = optimise1d(pt,dir,tol,lit,func,100,fval,bndguess);
-	  littot += lit;
+	  // if the in_slice flag has been set, only correct in z_rot, x_trans and y_trans
+	  if ((!in_slice) || (n == 3) || (n == 4) || (n == 5)) {
+	    fval = optimise1d(pt,dir,tol,lit,func,100,fval,bndguess);
+	    littot += lit;
+	  }
 	}
 	// check to see if the point has moved more than one average tolerance
 	float avtol = SP((initpt - pt),inv_tol).SumAbsoluteValue();
diff --git a/optimise.h b/optimise.h
index 302f600..39b6b6a 100644
--- a/optimise.h
+++ b/optimise.h
@@ -27,7 +27,7 @@ float optimise1d(ColumnVector &pt, const ColumnVector dir,
 
  float optimise(ColumnVector &pt, int numopt, const ColumnVector &tol, 
 		float (*func)(const ColumnVector &), int &iterations_done, 
-		int max_iter, const ColumnVector& boundguess);
+		int max_iter, const ColumnVector& boundguess, const bool in_slice=false);
 
 }
 
-- 
GitLab