From 23438fbcbe139f96968e500b905c3bef29e0ada8 Mon Sep 17 00:00:00 2001
From: Moises Fernandez <moisesf@fmrib.ox.ac.uk>
Date: Mon, 29 Apr 2013 13:22:18 +0000
Subject: [PATCH] Fix bug dividing subparts when only 1 subpart

---
 xfibres_gpu.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/xfibres_gpu.cc b/xfibres_gpu.cc
index d888985..2b0622a 100644
--- a/xfibres_gpu.cc
+++ b/xfibres_gpu.cc
@@ -107,9 +107,13 @@ int main(int argc, char *argv[]){
 	int last_sub_part = size_part - ((nsubparts-1)*SIZE_SUB_PART);
 
 	if(last_sub_part<(SIZE_SUB_PART*0.5)){ 	//if is too small the last part we distribute it between the others
-		size_sub_part = size_sub_part + last_sub_part/(nsubparts-1);
-		nsubparts--;
-		last_sub_part = size_part - ((nsubparts-1)*size_sub_part);		
+		if(nsubparts-1){
+			size_sub_partLR = size_sub_partLR + last_sub_partLR/(nsubparts-1);
+			nsubparts--;
+		}else{
+			size_sub_partLR = 0;
+		}
+		last_sub_partLR = size_partLR - ((nsubparts-1)*size_sub_partLR);
 	}
 
 	Matrix mydatam_part;	
-- 
GitLab