8 #error This class is not to be included by the user directly. Use VectorNf.h or VectorNd.h instead.
19 template <
class ForwardIterator>
32 VECTORN(
unsigned N,
const REAL* array);
35 VECTORN& normalize() { assert(norm() > EPS);
operator*=((REAL) 1.0/norm());
return *
this; }
36 unsigned size()
const {
return _data.size(); }
38 static REAL norm(
const VECTORN& v) {
return std::sqrt(norm_sq(v)); }
39 REAL norm_inf()
const {
return norm_inf(*
this); }
40 REAL norm1()
const {
return norm1(*
this); }
41 REAL norm()
const {
return norm(*
this); }
42 REAL norm_sq()
const {
return norm_sq(*
this); }
46 VECTORN& resize(
unsigned N,
bool preserve =
false) { _data.resize(N, preserve);
return *
this; }
60 REAL* data() {
return _data.get(); }
61 const REAL* data()
const {
return _data.get(); }
64 VECTORN& resize(
unsigned m,
unsigned n,
bool preserve =
false);
66 void free_memory() { resize(0); compress(); }
67 void compress() { _data.compress(); }
68 unsigned rows()
const {
return _data.size(); }
69 unsigned columns()
const {
return 1; }
70 unsigned leading_dim()
const {
return _data.size(); }
71 unsigned inc()
const {
return 1; }
74 #include "VectorN.inl"
77 #define XVECTORN VECTORN
78 #include "XVectorN.inl"
82 SharedResizable<REAL> _data;
85 std::ostream& operator<<(std::ostream& out,
const VECTORN& v);
86 std::istream& operator>>(std::istream& in,
VECTORN& v);
SHAREDVECTORN segment(unsigned start_idx, unsigned end_idx)
Gets a subvector of this vector as a shared vector.
Definition: VectorN.cpp:245
A two-dimensional floating point vector used for computational geometry calculations and with associa...
Definition: Vector2.h:15
static VECTORN construct_variable(unsigned N,...)
Constructs a N-dimension vector from the list of double values.
Definition: VectorN.cpp:94
VECTORN()
Default constructor - constructs an empty vector.
Definition: VectorN.cpp:10
COLUMN_ITERATOR begin()
Returns the column iterator.
Definition: VectorN.h:324
A generic, possibly non-square matrix.
Definition: MatrixN.h:18
static REAL dot(const V1 &v1, const V2 &v2)
Computes the dot-product between two vectors.
Definition: VectorN.h:606
A generic N-dimensional floating point vector.
Definition: SharedVectorN.h:77
static VECTORN zero(unsigned n)
Returns a N-dimensional zero vector.
Definition: VectorN.cpp:114
A generic, possibly non-square matrix using shared data.
Definition: SharedMatrixN.h:59
XVECTORN & operator*=(REAL scalar)
Multiplies this vector in place by a scalar.
Definition: VectorN.h:393
static VECTORN & concat(const VECTORN &v1, const VECTORN &v2, VECTORN &result)
Concatenates two vectors together and stores the result in a third.
Definition: VectorN.cpp:287
A generic N-dimensional floating point vector.
Definition: SharedVectorN.h:15
COLUMN_ITERATOR end()
Returns the column iterator.
Definition: VectorN.h:330
VECTORN & operator=(REAL r)
Assigns this vector to a scalar.
Definition: VectorN.cpp:279
A generic N-dimensional floating point vector.
Definition: VectorN.h:16
static VECTORN & parse(const std::string &s, VECTORN &v)
Parses a string for a vector value.
Definition: VectorN.cpp:296
A three-dimensional floating point vector used for representing points and vectors in 3D with associa...
Definition: Vector3.h:15
A generic, possibly non-square matrix using constant shared data.
Definition: SharedMatrixN.h:19
static VECTORN one(unsigned N)
Returns a N-dimensional one vector.
Definition: VectorN.cpp:106