Skip to content
Snippets Groups Projects
Commit 9e68d698 authored by Jesper Andersson's avatar Jesper Andersson
Browse files

fixed bug in submatrix function

parent 6c979174
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// //
// Copyright (C) 2007 University of Oxford // Copyright (C) 2007 University of Oxford
// //
/* CCOPYRIGHT */
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
...@@ -25,9 +25,9 @@ NEWMAT::Matrix BFMatrix::SubMatrix(unsigned int fr, unsigned int lr, unsigned in ...@@ -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"); 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); NEWMAT::Matrix omat(lr-fr+1,lc-fc+1);
for (unsigned int r=fr; r<=lr; r++) { for (unsigned int r=fr, ri=1; r<=lr; r++, ri++) {
for (unsigned int c=fc; c<lc; c++) { for (unsigned int c=fc, ci=1; c<=lc; c++, ci++) {
omat(r,c) = this->Peek(r,c); omat(ri,ci) = this->Peek(r,c);
} }
} }
return(omat); return(omat);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment