34template<
class T,
int _Rows,
int _Options>
43 typedef typename gsBase::Base Base;
48 typedef typename gsEigen::aligned_allocator<Self> aalloc;
54 typedef typename gsEigen::Block<Base> Block;
60 typedef memory::shared_ptr< gsVector >
Ptr;
63 typedef memory::unique_ptr< gsVector >
uPtr;
66 typedef gsEigen::PermutationMatrix<_Rows,Base::SizeAtCompileTime,index_t> Permutation;
69 typedef gsEigen::PermutationWrapper<Base> PermutationWrap;
71 typedef gsEigen::Ref<Base> Ref;
73 typedef const gsEigen::Ref<const Base> ConstRef;
82 typedef const T * const_iterator;
85 {
return this->data(); }
87 const T * begin()
const
88 {
return this->data(); }
91 {
return this->data() + this->size(); }
94 {
return this->data() + this->size(); }
100 gsVector(
const Base& a) ;
105 explicit gsVector(
index_t dimension) ;
114 inline operator Ref () {
return Ref(*
this); }
116 inline operator const ConstRef () {
return ConstRef(*
this); }
118 void clear() { this->resize(0); }
121 template<
typename OtherDerived>
122 gsVector(
const gsEigen::EigenBase<OtherDerived>& other) : gsBase(other) { }
125 template<
typename OtherDerived>
126 gsVector(
const gsEigen::MatrixBase<OtherDerived>& other) : gsBase(other) { }
129 template<
typename OtherDerived>
130 gsVector(
const gsEigen::ReturnByValue<OtherDerived>& other) : gsBase(other) { }
132 static gsVector<T,2> vec( T x, T y)
134 return typename gsVector<T,2>::Base(x, y);
137 static gsVector<T,3> vec( T x, T y, T z)
139 return typename gsVector<T,3>::Base(x, y, z);
142 template<
class iterator>
void
143 assign(iterator from, iterator to)
145 this->resize(std::distance(from,to));
146 T * a = this->data();
147 for(iterator it = from; it!=to; ++it) *(a++) = *it;
164#if !EIGEN_HAS_RVALUE_REFERENCES
165 gsVector & operator=(
typename gsEigen::internal::conditional<
166 -1==_Rows,gsVector,
const gsVector &>::type other)
171 this->Base::operator=(other);
177 inline T
at(
index_t i)
const {
return *(this->data()+i);}
183 inline T
last()
const {
return *(this->data()+this->size()-1);}
186 inline T &
last() {
return *(this->data()+this->size()-1);}
194 PermutationWrap asPermutation()
const {
return PermutationWrap(*
this);}
200 GISMO_ASSERT( i < this->size(),
"Invalid vector element." );
201 const T * ce = this->data() + this->size();
202 for ( T * c = this->data()+i+1; c!= ce; ++c ) *(c-1) = *c;
203 this->conservativeResize(this->size()-1,gsEigen::NoChange);
222 typedef gsEigen::Matrix<T,3,1> Base ;
225 typedef memory::shared_ptr< gsVector3d >
Ptr;
231 gsVector3d(scalar_t x, scalar_t y, scalar_t z = 0 );
239 template<
typename OtherDerived>
240 gsVector3d(
const gsEigen::MatrixBase<OtherDerived>& other) : Base(other) { }
244 return math::acos(this->normalized().dot(other.normalized()));
263 gsVector3d(
const gsVector3d & other) : Base(other) { }
266 gsVector3d & operator=(
const gsVector3d & other)
268 this->Base::operator=(other);
272 inline T at (
index_t i)
const {
return (*
this)(i,0); }
273 inline T & at (
index_t i) {
return (*
this)(i,0); }
274 inline T x ()
const {
return (*
this)(0); }
275 inline T & x () {
return (*
this)(0); }
276 inline T y ()
const {
return (*
this)(1); }
277 inline T & y () {
return (*
this)(1); }
278 inline T z ()
const {
return (*
this)(2); }
279 inline T & z () {
return (*
this)(2); }
284template<
class T,
int _Rows,
int _Options>
inline
285gsVector<T,_Rows,_Options>::gsVector() : gsBase() { }
287template<
class T,
int _Rows,
int _Options>
inline
288gsVector<T,_Rows,_Options>::gsVector(
const Base& a): gsBase(a) { }
290template<
class T,
int _Rows,
int _Options>
inline
291gsVector<T,_Rows,_Options>::gsVector(
index_t dimension): gsBase(dimension,1) { }
293template<
class T>
inline
294gsVector3d<T>::gsVector3d() : Base() { }
296template<
class T>
inline
297gsVector3d<T>::gsVector3d(scalar_t x, scalar_t y,scalar_t z )
304template<
class T>
inline
305gsVector3d<T>::gsVector3d(
const Base& a): Base(a) { }
325#ifdef GISMO_WITH_PYBIND11
331 void pybind11_init_gsVector(pybind11::module &m,
const std::string & typestr)
333 using Class = gsVector<T>;
334 std::string pyclass_name = std::string(
"gsVector") + typestr;
335 pybind11::class_<Class>(m, pyclass_name.c_str(), pybind11::buffer_protocol(), pybind11::dynamic_attr())
337 .def(pybind11::init<>())
338 .def(pybind11::init<index_t, index_t>())
340 .def(
"size", &Class::size)
341 .def(
"rows", &Class::rows)
Represents a block-view of the given matrix.
Definition gsMatrixBlockView.h:32
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A fixed-size, statically allocated 3D vector.
Definition gsVector.h:219
gsVector3d(const gsEigen::MatrixBase< OtherDerived > &other)
This constructor allows constructing a gsVector3d from Eigen expressions.
Definition gsVector.h:240
memory::shared_ptr< gsVector3d > Ptr
Shared pointer for gsVector3d.
Definition gsVector.h:225
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
T at(index_t i) const
Returns the i-th element of the vector.
Definition gsVector.h:177
memory::shared_ptr< gsVector > Ptr
Shared pointer for gsVector.
Definition gsVector.h:60
T & at(index_t i)
Returns the i-th element of the vector.
Definition gsVector.h:180
T last() const
Returns the last (bottom) element of the vector.
Definition gsVector.h:183
void removeElement(const index_t i)
Definition gsVector.h:198
memory::unique_ptr< gsVector > uPtr
Unique pointer for gsVector.
Definition gsVector.h:63
BlockView blockView(const gsVector< index_t > &rowSizes)
Return a row-block view of the vector with rowSizes.
Definition gsVector.h:189
T & last()
Returns the last (bottom) element of the vector.
Definition gsVector.h:186
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.