34 template<
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)
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 & operator=(
const gsVector3d & other)
265 this->Base::operator=(other);
269 inline T at (
index_t i)
const {
return (*
this)(i,0); }
270 inline T & at (
index_t i) {
return (*
this)(i,0); }
271 inline T x ()
const {
return (*
this)(0); }
272 inline T & x () {
return (*
this)(0); }
273 inline T y ()
const {
return (*
this)(1); }
274 inline T & y () {
return (*
this)(1); }
275 inline T z ()
const {
return (*
this)(2); }
276 inline T & z () {
return (*
this)(2); }
281 template<
class T,
int _Rows,
int _Options>
inline
282 gsVector<T,_Rows,_Options>::gsVector() : gsBase() { }
284 template<
class T,
int _Rows,
int _Options>
inline
285 gsVector<T,_Rows,_Options>::gsVector(
const Base& a): gsBase(a) { }
287 template<
class T,
int _Rows,
int _Options>
inline
288 gsVector<T,_Rows,_Options>::gsVector(
index_t dimension): gsBase(dimension,1) { }
290 template<
class T>
inline
291 gsVector3d<T>::gsVector3d() : Base() { }
293 template<
class T>
inline
294 gsVector3d<T>::gsVector3d(scalar_t x, scalar_t y,scalar_t z )
301 template<
class T>
inline
302 gsVector3d<T>::gsVector3d(
const Base& a): Base(a) { }
322 #ifdef GISMO_WITH_PYBIND11
327 namespace py = pybind11;
330 void pybind11_init_gsVector(pybind11::module &m,
const std::string & typestr)
332 using Class = gsVector<T>;
333 std::string pyclass_name = std::string(
"gsVector") + typestr;
334 py::class_<Class>(m, pyclass_name.c_str(), py::buffer_protocol(), py::dynamic_attr())
337 .def(py::init<index_t, index_t>())
339 .def(
"size", &Class::size)
340 .def(
"rows", &Class::rows)
345 #endif // GISMO_WITH_PYBIND11
A fixed-size, statically allocated 3D vector.
Definition: gsVector.h:218
T distance(gsMatrix< T > const &A, gsMatrix< T > const &B, index_t i=0, index_t j=0, bool cols=false)
compute a distance between the point number in the set and the point number <j> in the set ; by def...
T & last()
Returns the last (bottom) element of the vector.
Definition: gsVector.h:186
#define index_t
Definition: gsConfig.h:32
void removeElement(const index_t i)
Definition: gsVector.h:198
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
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
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
memory::unique_ptr< gsVector > uPtr
Unique pointer for gsVector.
Definition: gsVector.h:63
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition: gsVector.h:35
gsVector3d(const gsEigen::MatrixBase< OtherDerived > &other)
This constructor allows constructing a gsVector3d from Eigen expressions.
Definition: gsVector.h:240
T at(index_t i) const
Returns the i-th element of the vector.
Definition: gsVector.h:177
memory::shared_ptr< gsVector3d > Ptr
Shared pointer for gsVector3d.
Definition: gsVector.h:225
Represents a block-view of the given matrix.
Definition: gsMatrixBlockView.h:31
T last() const
Returns the last (bottom) element of the vector.
Definition: gsVector.h:183
BlockView blockView(const gsVector< index_t > &rowSizes)
Return a row-block view of the vector with rowSizes.
Definition: gsVector.h:189