From 40f90655923d3f6ab288055fdb6641b45066e8c9 Mon Sep 17 00:00:00 2001 From: mcecchetti Date: Sun, 6 Jul 2008 15:36:49 +0000 Subject: [PATCH] modified is_positive and is_negative implementation for Vector and Matrix in order to make 2geom linkable with a gsl release >= 1.8 --- src/2geom/numeric/matrix.cpp | 4 ++-- src/2geom/numeric/matrix.h | 18 ++++++++++++++++-- src/2geom/numeric/vector.h | 12 ++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/2geom/numeric/matrix.cpp b/src/2geom/numeric/matrix.cpp index 30b452b37..bb2a4cefd 100644 --- a/src/2geom/numeric/matrix.cpp +++ b/src/2geom/numeric/matrix.cpp @@ -33,8 +33,8 @@ */ -#include "matrix.h" -#include "vector.h" +#include <2geom/numeric/matrix.h> +#include <2geom/numeric/vector.h> diff --git a/src/2geom/numeric/matrix.h b/src/2geom/numeric/matrix.h index 156b6e9a2..e9b6e6e9e 100644 --- a/src/2geom/numeric/matrix.h +++ b/src/2geom/numeric/matrix.h @@ -89,12 +89,26 @@ class BaseMatrixImpl bool is_positive() const { - return gsl_matrix_ispos(m_matrix); + for ( unsigned int i = 0; i < rows(); ++i ) + { + for ( unsigned int j = 0; j < columns(); ++j ) + { + if ( (*this)(i,j) <= 0 ) return false; + } + } + return true; } bool is_negative() const { - return gsl_matrix_isneg(m_matrix); + for ( unsigned int i = 0; i < rows(); ++i ) + { + for ( unsigned int j = 0; j < columns(); ++j ) + { + if ( (*this)(i,j) >= 0 ) return false; + } + } + return true; } bool is_non_negative() const diff --git a/src/2geom/numeric/vector.h b/src/2geom/numeric/vector.h index 3e53405f4..04c133372 100644 --- a/src/2geom/numeric/vector.h +++ b/src/2geom/numeric/vector.h @@ -73,12 +73,20 @@ class BaseVectorImpl bool is_positive() const { - return gsl_vector_ispos(m_vector); + for ( size_t i = 0; i < size(); ++i ) + { + if ( (*this)[i] <= 0 ) return false; + } + return true; } bool is_negative() const { - return gsl_vector_isneg(m_vector); + for ( size_t i = 0; i < size(); ++i ) + { + if ( (*this)[i] >= 0 ) return false; + } + return true; } bool is_non_negative() const -- 2.30.2