41 template <
typename T2>
FVector(
const T2 t[dim]) : Base(t) {}
84 memset(Z.
_data,0,dim*
sizeof(T));
96 template <
typename T2>
104 const T&
x()
const { assert(dim>=1);
return (*
this)[0]; }
111 T&
x() { assert(dim>=1);
return (*
this)[0]; }
118 const T&
y()
const { assert(dim>=2);
return (*
this)[1]; }
125 T&
y() { assert(dim>=2);
return (*
this)[1]; }
132 const T&
z()
const { assert(dim>=3);
return (*
this)[2]; }
139 T&
z() { assert(dim>=3);
return (*
this)[2]; }
149 for (
int i=0;i<dim;i++)
150 w[i]=(*
this)[i]+v[i];
162 for (
int i=0;i<dim;i++)
163 w[i]=(*
this)[i]-v[i];
174 for (
int i=0;i<dim;i++)
186 for (
int i=0;i<dim;i++)
199 for (
int i=0;i<dim;i++)
212 for (
int i=0;i<dim;i++)
224 for (
int i=0;i<dim;i++)
236 for (
int i=0;i<dim;i++)
248 for (
int i=0;i<dim;i++)
261 for (
int i=0;i<dim;i++)
274 return (*
this)[0]*v[1]-(*this)[1]*v[0];
286 w[0]=(*this)[1]*v[2]-(*this)[2]*v[1];
287 w[1]=(*this)[2]*v[0]-(*this)[0]*v[2];
288 w[2]=(*this)[0]*v[1]-(*this)[1]*v[0];
300 for (
int i=0;i<dim;i++)
313 for (
int i=0;i<dim;i++)
325 for (
int i=0;i<dim;i++)
337 for (
int i=0;i<dim;i++)
383 for (
int i=0;i<dim;i++)
395 assert( !std::numeric_limits<T>::is_integer );
396 return ::sqrt(
norm2(v));
429 T mx = std::abs(v[0]);
430 for (
int i=0;i<dim;i++){
431 T a = std::abs(v[i]);
445 assert( std::numeric_limits<T>::is_integer );
447 for(
int i=0; i < dim; ++i)
459 assert( std::numeric_limits<T>::is_integer );
461 for (
int i=0;i<dim;i++)
462 n+=
int(v[i])*int(v[i]);
474 for (
int i=0;i<dim;++i)
475 d+=fabs(
double(v[i]));
487 for (
int i=0;i<dim;i++)
488 n+=
double(v[i])*double(v[i]);
510 for (
int i=0;i<dim;i++)
523 for (
int i=0;i<dim;i++)
536 for (
int i=0;i<dim;i++)
548 assert( !std::numeric_limits<T>::is_integer );
550 for (
int i=0;i<dim;i++)
562 assert( !std::numeric_limits<T>::is_integer );
564 for (
int i=0;i<dim;i++)
576 assert( !std::numeric_limits<T>::is_integer );
578 for (
int i=0;i<dim;i++)
591 for (
int i=0;i<dim;++i)
592 m[i]=std::min(a[i],b[i]);
604 for (
int i=0;i<dim;++i)
605 m[i]=std::max(a[i],b[i]);
616 assert( std::numeric_limits<T>::is_integer );
618 for (
int i = 0; i<dim; ++i)
619 n += abs(
int(a[i])-
int(b[i]));
631 for (
int i = 0; i < dim; ++i)
632 d += fabs(
double(a[i])-
double(b[i]));
644 for (
int i=0;i<dim;i++) {
645 double e=double(a[i])-double(b[i]);
static FVector Zero()
Zero vector Vector with constant 0 value.
Definition: FVector.h:82
friend FVector operator-(T s, const FVector &v)
Scalar substraction.
Definition: FVector.h:371
FVector(const FArray< T2, dim > &a)
Copy constructor.
Definition: FVector.h:50
Vector of fixed size.
Definition: FVector.h:17
FVector & operator*=(T s)
Scalar in place multiplication.
Definition: FVector.h:324
FVector & operator+=(const FVector &v)
In place Addition.
Definition: FVector.h:173
friend double L1Dist(const FVector &a, const FVector &b)
Double L1-distance.
Definition: FVector.h:629
FVector & fill(const T &v)
Filling.
Definition: FVector.h:75
T _data[S]
internal storage.
Definition: FArray.h:21
const T & z() const
Read alias.
Definition: FVector.h:132
friend FVector mult(const FVector &v, const FVector &w)
Pointwise multiplication.
Definition: FVector.h:521
T operator*(const FVector &v) const
Scalar product.
Definition: FVector.h:259
friend double doubleNorm(const FVector &v)
Double Euclidean norm.
Definition: FVector.h:498
FVector(const T2 t[dim])
Constructor from C array.
Definition: FVector.h:41
FVector & normalize()
Euclidean in-place normalization.
Definition: FVector.h:404
friend FVector div(const FVector &v, const FVector &w)
Pointwise division.
Definition: FVector.h:534
FVector(T x, T y)
2D alias.
Definition: FVector.h:58
FVector operator+(const FVector &v) const
Addition.
Definition: FVector.h:147
T & x()
Write alias.
Definition: FVector.h:111
const T & x() const
Read alias.
Definition: FVector.h:104
friend double doubleNorm1(const FVector &v)
Double L1-norm.
Definition: FVector.h:472
friend FVector exp(const FVector &a)
Pointwise exp exps of each coordinate.
Definition: FVector.h:575
friend int intL1Dist(const FVector &a, const FVector &b)
Integer L1-distance.
Definition: FVector.h:615
T & z()
Write alias.
Definition: FVector.h:139
FVector(const T &v)
Constructor with constant value.
Definition: FVector.h:32
FVector operator/(T s) const
Scalar division.
Definition: FVector.h:311
FArray & operator=(const FArray< T2, S > &b)
Assignment.
Definition: FArray.h:146
Array of fixed size.
Definition: FArray.h:17
FVector & operator=(const FArray< T2, dim > &b)
Assignment.
Definition: FVector.h:97
FVector(T x, T y, T z)
3D alias.
Definition: FVector.h:67
friend FVector pmax(const FVector &a, const FVector &b)
Pointwise max.
Definition: FVector.h:602
T & y()
Write alias.
Definition: FVector.h:125
friend FVector operator+(T s, const FVector &v)
Scalar addition.
Definition: FVector.h:360
FVector operator-() const
Opposite.
Definition: FVector.h:246
friend T sum(const FVector &v)
Sum of coordinates.
Definition: FVector.h:508
friend double squaredDist(const FVector &a, const FVector &b)
Squared distance.
Definition: FVector.h:642
friend FVector operator*(T s, const FVector &v)
Scalar multiplication.
Definition: FVector.h:349
FVector & operator/=(T s)
Scalar in place division.
Definition: FVector.h:336
friend int intNorm1(const FVector &v)
Integer L1-norm.
Definition: FVector.h:443
friend FVector pmin(const FVector &a, const FVector &b)
Pointwise min.
Definition: FVector.h:589
friend T norm2(const FVector &v)
Squared Euclidean norm.
Definition: FVector.h:381
friend FVector normalized(const FVector &v)
Euclidean normalization.
Definition: FVector.h:416
friend T maxNorm(const FVector &v)
Maximum norm.
Definition: FVector.h:428
friend double dist(const FVector &a, const FVector &b)
Distance.
Definition: FVector.h:657
FVector()
Empty constructor.
Definition: FVector.h:25
friend FVector log(const FVector &a)
Pointwise log logs of each coordinate.
Definition: FVector.h:561
friend double doubleNorm2(const FVector &v)
Double squared Euclidean norm.
Definition: FVector.h:485
friend int intNorm2(const FVector &v)
Integer squared Euclidean norm.
Definition: FVector.h:458
FVector operator*(T s) const
Scalar multiplication.
Definition: FVector.h:298
const T & y() const
Read alias.
Definition: FVector.h:118
Imagine++ namespace.
Definition: Array.h:7
FVector & operator-=(const FVector &v)
In place Substraction.
Definition: FVector.h:185
friend FVector sqrt(const FVector &a)
Pointwise square root Square roots of each coordinate.
Definition: FVector.h:547
FArray & fill(const T &v)
Filling.
Definition: FArray.h:109
friend T norm(const FVector &v)
Euclidean norm.
Definition: FVector.h:394
T operator^(const FVector< T, 2 > &v) const
2D cross product.
Definition: FVector.h:272