-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* linbox/matrix/blas-vector.h | ||
* Copyright (C) 2013 the LinBox group | ||
* 2019 Pascal Giorgi | ||
* 2019 Pascal Giorgi | ||
* | ||
* Written by : | ||
* Pascal Giorgi [email protected] | ||
|
@@ -45,7 +45,7 @@ namespace LinBox { | |
// forward declaration | ||
template <class Field, class Storage> | ||
class BlasVector; | ||
|
||
|
||
template <typename _Vector> | ||
class VectorEltPointer { | ||
|
@@ -61,7 +61,7 @@ namespace LinBox { | |
typedef typename _Vector::Storage::const_reference reference; | ||
using Element=const typename _Vector::Field::Element; | ||
}; | ||
|
||
template<class _Vector> | ||
class BlasSubvector { | ||
|
||
|
@@ -88,7 +88,7 @@ namespace LinBox { | |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | ||
|
||
protected: | ||
pointer _ptr; | ||
pointer _ptr; | ||
size_t _size; | ||
size_t _inc; | ||
Field const*_field; | ||
|
@@ -101,7 +101,7 @@ namespace LinBox { | |
////////////////// | ||
|
||
BlasSubvector(){} | ||
|
||
/** Constructor from an existing @ref BlasVector and dimensions. | ||
* \param V Pointer to @ref BlasVector of which to construct subvector | ||
* \param beg Starting idx | ||
|
@@ -110,17 +110,17 @@ namespace LinBox { | |
*/ | ||
BlasSubvector (vectorType &V, size_t beg, size_t inc, size_t dim) : | ||
_ptr(V.getPointer()+beg), _size(dim), _inc(inc), _field(&V.field()) {} | ||
|
||
/** Constructor from an existing @ref BlasSubvector and dimensions. | ||
* \param V Pointer to @ref DenseSubector of which to construct subvector | ||
* \param beg Starting idx | ||
* \param dim dimension | ||
* \param inc distance between two element | ||
*/ | ||
BlasSubvector (Self_t &V, size_t beg, size_t inc, size_t dim) : | ||
_ptr(V.data()+beg), _size(dim), _inc(inc), _field(&V.field()) {} | ||
_ptr(V.getPointer()+beg), _size(dim), _inc(inc), _field(&V.field()) {} | ||
|
||
|
||
|
||
/** Constructor from an existing @ref BlasVector | ||
* \param V Pointer to @ref BlasVector of which to construct submatrix | ||
*/ | ||
|
@@ -132,17 +132,17 @@ namespace LinBox { | |
*/ | ||
BlasSubvector (const Field& F, pointer ptr, size_t inc, size_t dim) : | ||
_ptr(ptr), _size(dim), _inc(inc), _field(&F) {} | ||
|
||
|
||
|
||
BlasSubvector (const Field& F, std::vector<Element>& v) : | ||
_ptr(v.data()), _size(v.size()), _inc(1), _field(&F) | ||
_ptr(v.data()), _size(v.size()), _inc(1), _field(&F) | ||
{ | ||
std::cerr<<"WARNING "<<__LINE__<<" ("<<__FILE__<<") : creating a BlasSubvector from a std::vector -> MUST BE DEPRECATED"<<std::endl; | ||
throw LinBoxError("Deprecated Subvector cstor from std::vector"); | ||
} | ||
|
||
|
||
|
||
/** Copy operator */ | ||
BlasSubvector& operator= (const BlasSubvector& V){ | ||
|
@@ -157,18 +157,18 @@ namespace LinBox { | |
|
||
template<class Vect> | ||
Self_t& copy(const Vect& A){ | ||
assert(_size == A.size()); | ||
assert(_size == A.size()); | ||
auto it=A.begin(); auto jt=begin(); | ||
for( ; it!=A.end();++it,++jt) | ||
field().assign(*jt,*it); | ||
return *this; | ||
} | ||
|
||
//! Rebind operator | ||
template<typename _Tp1, typename _Rep2 = typename Rebind<Storage, _Tp1>::other> | ||
struct rebind { | ||
typedef BlasVector<_Tp1, _Rep2> other; | ||
|
||
void operator() (other & Ap, const Self_t& A) { | ||
typedef typename Self_t::const_iterator ConstSelfIterator ; | ||
typedef typename other::iterator OtherIterator ; | ||
|
@@ -180,14 +180,14 @@ namespace LinBox { | |
} | ||
}; | ||
|
||
|
||
|
||
///////////////// | ||
// ACCESSORS // | ||
///////////////// | ||
|
||
const Field& field() const { return *_field;} | ||
|
||
// dimension of the vector | ||
size_t size() const{ return _size; } | ||
size_t max_size() const{ return _size; } | ||
|
@@ -203,14 +203,14 @@ namespace LinBox { | |
* @return the inc value of the subvector | ||
*/ | ||
size_t getInc() const {return _inc;} | ||
|
||
|
||
void setEntry (size_t i, const Element &a_i){ field().assign(_ptr[i],a_i); } | ||
|
||
reference refEntry (size_t i){ return _ptr[i]; } | ||
|
||
const_reference getEntry (size_t i) const { return _ptr[i]; } | ||
|
||
Element& getEntry (Element &x, size_t i) const{ return field().assign(x,_ptr[i]); } | ||
|
||
// write | ||
|
@@ -226,7 +226,7 @@ namespace LinBox { | |
case (Tag::FileFormat::Maple) : | ||
{ | ||
os << '<' ; | ||
for(size_t i=0; i<_size; i++){ | ||
for(size_t i=0; i<_size; i++){ | ||
field().write(os, *(_ptr+_inc*i)); | ||
if (i != _size-1) | ||
os << ',' ; | ||
|
@@ -237,7 +237,7 @@ namespace LinBox { | |
return os << "not implemented" ; | ||
} | ||
} | ||
|
||
//read | ||
std::istream &read ( std::istream &is, Tag::FileFormat fmt = Tag::FileFormat::Pretty ) { | ||
return is; | ||
|
@@ -275,10 +275,10 @@ namespace LinBox { | |
const_reference front (void) const { return _ptr[0];} | ||
reference back (void) { return _ptr[(_size-1)*_inc];} | ||
const_reference back (void) const { return _ptr[(_size-1)*_inc];} | ||
|
||
bool empty() const {return (_size==0);} | ||
}; | ||
|
||
template <class Vector> | ||
std::ostream& operator<< (std::ostream & os, const BlasSubvector<Vector> & V) { | ||
return V.write(os); | ||
|
@@ -296,7 +296,7 @@ namespace LinBox { | |
|
||
|
||
|
||
|
||
} // LinBox | ||
#endif | ||
// Local Variables: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters