Commit 36bd2c03 authored by Antoine Lucas's avatar Antoine Lucas
Browse files

mise a jour protect / unprotect

parent 1b32fde5
......@@ -185,7 +185,7 @@ namespace bigrationalR{
bigvec_q create_bignum(SEXP param);
SEXP create_SEXP(const bigvec_q & v);
SEXP create_SEXP(const math::Matrix<bigrational> & v);
SEXP bigrational_binary_operation (SEXP a, SEXP b, bigrational_binary_fn f);
SEXP bigrational_bigz_binary_operation (SEXP a, SEXP b, bigrational_bigz_binary_fn f);
......
......@@ -24,7 +24,7 @@
* can be of different size and a nrow
* parameter (for matrix support)
*/
class bigvec : public matrix::Matrix<bigmod> {
class bigvec : public math::Matrix<bigmod> {
public:
/** \brief value */
std::vector<biginteger> value;
......@@ -48,7 +48,9 @@ class bigvec : public matrix::Matrix<bigmod> {
virtual ~bigvec();
inline bool isVector() const{
return nrow < 0 ;
}
/**
* \brief construct a bigmod at indice i
......
......@@ -22,7 +22,7 @@
* It is a class composed of a vector of bigrational
* and an nrow parameter.
*/
class bigvec_q : public matrix::Matrix<bigrational> {
class bigvec_q : public math::Matrix<bigrational> {
public:
/** \brief The real value */
......@@ -57,6 +57,10 @@ class bigvec_q : public matrix::Matrix<bigrational> {
~bigvec_q(){};
inline bool isVector() const{
return nrow < 0 ;
}
/** \brief assignemt operator */
bigvec_q & operator= (const bigvec_q& rhs);
......
......@@ -52,7 +52,7 @@ namespace solve_gmp_R
* A is of dimension nxn X nxm and B nxm (X will be return a B address)
* We use the Gauss algorithm
*/
template< class T> void solve (matrix::Matrix<T> & A , matrix::Matrix<T> & B)
template< class T> void solve (math::Matrix<T> & A , math::Matrix<T> & B)
{
// A [ i ,j] = A[ i + j * A.nrow]
......
......@@ -3,29 +3,24 @@
namespace matrix{
namespace math{
template< class T>
class Matrix{
/*
class Row{
private :
Matrix & source;
int start;
Row(Matrix & source_p, int rowIndex)
: source(source_p),
start(rowIndex*source.nCols()){};
~Row(){};
public:
T operator[] (unsigned int i) const {
return source.get(start + i);
};
template< class T>
class Vector{
};
*/
public:
Vector();
virtual unsigned int size() const = 0;
virtual const T & operator[](unsigned int i) const=0;
virtual T & operator[](unsigned int i) =0;
};
template< class T>
class Matrix : public Vector<T> {
private:
Matrix * transposate;
......@@ -35,29 +30,20 @@ namespace matrix{
virtual ~Matrix() {
if (transposate) delete transposate;
};
/*
Row get (unsigned int i) const{
Row row (*this, i);
return row;
}*/
/** i, j -> index = i + j*rows */
// virtual T operator[](unsigned int index) const=0;
/** return numRow*runCols */
virtual unsigned int size() const = 0;
virtual unsigned int nRows() const = 0;
virtual unsigned int nCols() const{
return size() / nRows();
};
virtual unsigned int nCols() const;
virtual T & get(unsigned int row, unsigned int col) = 0;
virtual void set(unsigned int row, unsigned int col, const T& val) =0;
/** return true if matrix is supposed to be a vector and not a matrix n x 1 */
virtual bool isVector() const = 0;
/**
* \brief assign a value at indice i
*/
......@@ -100,7 +86,7 @@ namespace matrix{
unsigned int nRows() const {
return source.nCols();
}
T & get(unsigned int i, unsigned int j) {
return source.get(j,i);
}
......@@ -113,7 +99,13 @@ namespace matrix{
// template code.
template<class T>
Matrix<T>::Matrix() : transposate(NULL)
Vector<T>::Vector() {
};
template<class T>
Matrix<T>::Matrix() :
Vector<T>(),
transposate(NULL)
{
}
......@@ -125,6 +117,14 @@ namespace matrix{
return *transposate;
}
template<class T>
unsigned int Matrix<T>::nCols() const{
return this->size() / nRows();
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment