FirstIndexNext

[bug-gsl] Possible bug(s) in rowcol_source.c (gsl_matrix_subrow and gsl_matrix_subcolumn) (2008-04-11)

From: Thord Andersson <thord@......>
Subject: Possible bug(s) in rowcol_source.c (gsl_matrix_subrow and gsl_matrix_subcolumn)
Date: Fri, 11 Apr 2008 11:46:57 +0200
To: "bug-gsl@gnu.org" <bug-gsl@gnu.org>

Hi,

In rowcol_source.c , functions gsl_matrix_subrow() and gsl_matrix_subcolumn() , there are overflow checks which I think compare with the wrong matrix dimension.
Possible fixes are indicated in inline comments. My applications works now....

Thank you for GSL! It's great!
/Thord Andersson

QUALIFIED_VIEW(_gsl_vector,view)
FUNCTION (gsl_matrix, subrow) (QUALIFIED_TYPE(gsl_matrix) * m, const size_t i, const size_t offset, const size_t n)
..
..
else if (offset + n > m->size1) // Should be: (offset + n > m->size2) (compare with length of row -->number of columns)
{
GSL_ERROR_VAL ("dimension n overflows matrix", GSL_EINVAL, view);
}
..
..

and

QUALIFIED_VIEW(_gsl_vector,view)
FUNCTION (gsl_matrix, subcolumn) (QUALIFIED_TYPE(gsl_matrix) * m, const size_t j, const size_t offset, const size_t n)
..
..
else if (offset + n > m->size2) // Should be: (offset + n > m->size1) (compare with length of column -->number of rows)
{
GSL_ERROR_VAL ("dimension n overflows matrix", GSL_EINVAL, view);
}
..