From 9e68d698ed3e3a98c556e3d6c52120b9e967e15a Mon Sep 17 00:00:00 2001
From: Jesper Andersson <jesper@fmrib.ox.ac.uk>
Date: Mon, 8 Oct 2012 13:16:46 +0000
Subject: [PATCH] fixed bug in submatrix function

---
 bfmatrix.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bfmatrix.cpp b/bfmatrix.cpp
index 64c542f..d0ef3a0 100644
--- a/bfmatrix.cpp
+++ b/bfmatrix.cpp
@@ -5,7 +5,7 @@
 //
 //    Copyright (C) 2007 University of Oxford 
 //
-/*  CCOPYRIGHT  */
+
 #include <iostream>
 #include <iomanip>
 #include <fstream>
@@ -25,9 +25,9 @@ NEWMAT::Matrix BFMatrix::SubMatrix(unsigned int fr, unsigned int lr, unsigned in
 {
   if (fr<1 || fc<1 || lr>Nrows() || lc>Ncols() || fr>lr || fc>lc) throw BFMatrixException("BFMatrix::SubMatrix: index out of range");
   NEWMAT::Matrix omat(lr-fr+1,lc-fc+1);
-  for (unsigned int r=fr; r<=lr; r++) {
-    for (unsigned int c=fc; c<lc; c++) {
-      omat(r,c) = this->Peek(r,c);
+  for (unsigned int r=fr, ri=1; r<=lr; r++, ri++) {
+    for (unsigned int c=fc, ci=1; c<=lc; c++, ci++) {
+      omat(ri,ci) = this->Peek(r,c);
     }
   }
   return(omat);
-- 
GitLab