10 #ifndef TBCI_FS_VECTOR_H
11 #define TBCI_FS_VECTOR_H
13 #include "tbci/basics.h"
14 #include "tbci/bvector.h"
17 #if !defined(NO_GD) && !defined(AUTO_DECL)
18 # include "fs_vector_gd.h"
23 #ifndef TBCI_DISABLE_EXCEPT
31 :
NumErr(
"Error in FS_Vector library") {}
41 # pragma interface "fs_vector.h"
48 template <
unsigned dims,
typename T,
unsigned dims2>
61 template <
unsigned dims,
typename T>
92 #ifndef HAVE_PROMOTION_BUG
93 # ifndef HAVE_GCC295_TMPLFRNDCLS_BUG
94 template <
unsigned dm,
typename U>
friend class FS_Vector;
97 {
for (
unsigned i = 0;
i <
dims; ++
i) *(
this)(
i) = fsv(
i); }
106 inline unsigned long size ()
const {
return dims; }
146 friend STD__ ostream& operator << FGD (STD__ ostream&, const FS_Vector<dims,T>&);
149 bool contains (
const T&,
unsigned long* = 0)
const;
155 double fabs ()
const;
160 bool operator <= (const FS_Vector<dims,T>& fv)
const
161 {
return fabssqr() <= fv.fabssqr(); }
164 bool operator < (const FS_Vector<dims,T>& fv)
const
165 {
return !((*this) >= fv); }
167 {
return !((*this) <= fv); }
185 template <
unsigned dims,
typename T,
unsigned d2>
196 template <
unsigned dims,
typename T>
204 template <
unsigned dims,
typename T>
209 va_list vl; va_start (vl, va);
210 #if !defined(__clang__) || !defined(CPLX)
211 for (
unsigned long i = 0;
i <
MIN ((
unsigned)va,
dims); ++
i)
212 x[
i] = va_arg (vl,
T);
214 throw FSVecErr(
"vararg not supported for cplx in clang");
215 #warning no vararg support with cplx numbers and clang
221 template <
unsigned dims,
typename T>
229 template <
unsigned dims,
typename T>
235 template <
unsigned dims,
typename T>
241 template <
unsigned dims,
typename T>
247 template <
unsigned dims,
typename T>
254 template <
unsigned dims,
typename T>
257 for (
unsigned long i = 0;
i <
dims; ++
i)
262 template <
unsigned dims,
typename T>
269 template <
unsigned dims,
typename T>
276 template <
unsigned dims,
typename T>
279 return (fabsqr() <= fv.
fabssqr());
282 template <
unsigned dims,
typename T>
285 return (fabsqr() >= fv.
fabssqr());
289 #define FSV_ASS_FSV(op) \
290 template <unsigned dims, typename T> \
291 inline FS_Vector<dims,T>& FS_Vector<dims,T>::operator op (const FS_Vector <dims,T>& fv) \
293 for (unsigned long i = 0; i < dims; ++i) \
301 #define FSV_NOASS_FSV(op) \
302 template <unsigned dims, typename T> \
303 inline FS_Vector<dims,T> FS_Vector<dims,T>::operator op (const FS_Vector <dims,T>& fv) const \
305 FS_Vector <dims,T> rv; \
306 for (unsigned long i = 0; i < dims; ++i) \
307 rv[i] = x[i] op fv[i]; \
314 #define FSV_ASS_T(op) \
315 template <unsigned dims, typename T> \
316 inline FS_Vector<dims,T>& FS_Vector<dims,T>::operator op (const T& v) \
318 for (unsigned long i = 0; i < dims; ++i) \
328 #define FSV_NOASS_T(op) \
329 template <unsigned dims, typename T> \
330 inline FS_Vector<dims,T> FS_Vector<dims,T>::operator op (const T& v) const \
332 FS_Vector<dims,T> rv; \
333 for (unsigned long i = 0; i < dims; ++i) \
343 template <
unsigned dims, typename
T>
347 for (
unsigned long i = 0;
i <
dims; ++
i)
353 template <
unsigned dims,
typename T>
358 for (
unsigned long i = 0;
i <
dims; ++
i)
364 template <
unsigned dims,
typename T>
368 for (
unsigned long i = 0;
i <
dims; ++
i)
374 template <
unsigned dims,
typename T>
384 template <
unsigned dims,
typename T>
385 STD__ ostream& operator << (STD__ ostream& os, const FS_Vector<dims,T>& fv)
387 if (!
dims)
return os;
389 for (
unsigned long i = 1;
i <
dims; ++
i)
390 os <<
", " << fv.
x[
i];
395 template <
unsigned dims,
typename T>
403 if (s !=
'(') in.putback(s);
407 for (
unsigned long i = 1;
i <
dims; ++
i) {
409 if (s !=
',') in.putback(s);
417 template <
unsigned dims,
typename T>
420 STD__ cerr <<
"fs_vector: Input on pointer types not possible!" <<
STD__ endl;
427 template <
unsigned dims,
typename T>
438 template <
unsigned dims,
typename T>
441 if (
dims == 0)
return 0;
449 template <
unsigned dims,
typename T>
452 if (
dims == 0)
return 0;
460 template <
unsigned dims,
typename T>
470 template <
unsigned dims,
typename T>
473 if (
dims == 0)
return 0;
480 template <
unsigned dims,
typename T>
486 template <
unsigned dims,
typename T>
492 template <
unsigned dims,
typename T>
499 template <
unsigned dims,
typename T,
unsigned long dims2>
509 template <
unsigned dims,
typename T>
513 for (
unsigned long i = 0;
i <
dims; ++
i)
518 template <
unsigned dims,
typename T>
522 for (
unsigned long i = 0;
i <
dims; ++
i)
527 template <
unsigned dims,
typename T>
531 for (
unsigned long i = 0;
i <
dims; ++
i)
536 template <
unsigned dims,
typename T>
540 for (
unsigned long i = 0;
i <
dims; ++
i)
547 template <unsigned dims, typename T>
552 #define FSV_MEM_FRD(nm,op) \
553 template <unsigned dims, typename T> \
554 INLINE FS_Vector<dims,T> FS_Vector<dims,T>:: nm (const T& v) const \
556 FS_Vector<dims,T> res; \
557 for (unsigned long i = 0; i < dims; ++i) \
558 res.x[i] = v op x[i]; \
568 template <
unsigned dims, typename T>
570 {
return fv.
mult (v); }
573 template <unsigned dims, typename T>
575 {
return fv.
plus(v); }
578 template <unsigned dims, typename T>
580 {
return fv.
minus(v); }
588 template <unsigned dims, typename T>
593 template <unsigned dims, typename T>
598 template <unsigned dims, typename T>
607 template <unsigned dims, typename T>
609 {
return fv.fabs(); }
611 #if (_MSC_VER) && (_MSC_VER == 1200)
615 template <unsigned dims, typename T>
T sum(const FS_Vector< dims, T > &fv)
#define BCHKNR(cond, exc, txt, ind)
const Vector< T > const Vector< T > & x
abstract base class (signature) for Vectors with arithmetics
friend T dot FGD(const FS_Vector< dims, T > &, const FS_Vector< dims, T > &)
FS_Vector< dims, T > & clear()
bool operator>=(const FS_Vector< dims, T > &fv) const
provides basic Vector functionality but arithmetic operators (+=, - , *, /...).
STD__ istream & operator>>(STD__ istream &istr, BdMatrix< T > &mat)
FS_Vector< dims, T > & operator/=(const T &)
#define FSV_NOASS_FSV(op)
FS_Vector< dims, T > & operator+=(const FS_Vector< dims, T > &)
T & operator()(const unsigned long i)
unsigned long size() const HOT
exception base class for the TBCI NumLib
FS_Vector< dims, T > slice(const FS_Vector< dims, T > &fv, const unsigned long s, const unsigned long e)
T *const & vecptr() const
FS_Vector< dims, T > cediv(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)
#define BCHK(cond, exc, txt, ind, rtval)
#define NAMESPACE_CSTD_END
T max(const FS_Vector< dims, T > &fv)
T aligned_value_type TALIGN(MIN_ALIGN)
#define FSV_MEM_FRD(nm, op)
FS_Vector< dims, T > operator/(const T &) const
bool operator>(const FS_Vector< dims, T > &fv) const
FS_Vector< dims, T > & operator*=(const T &)
FSVecErr(const FSVecErr &fe)
FS_Vector< dims, T > operator-() const
FS_Vector< dims, T > minus(const T &) const
FS_Vector< dims, T > ediv(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)
FSVecErr(const char *t, const long i=0)
FS_Vector< dims, T > & operator-=(const FS_Vector< dims, T > &)
FS_Vector< dims, T > incr(const unsigned long, const T=(T) 1) const
int conj(const int arg)
conj for elementary types
const Vector< T > Vector< T > & param
bool operator!=(const FS_Vector< dims, T > &fv) const
FS_Vector< dims, T > & init_0()
FS_Vector< dims, T > operator+(const FS_Vector< dims, T > &) const
T dot(const T &a1, const T &a2)
bool operator<=(const FS_Vector< dims, T > &fv) const
FS_Vector(const FS_Vector< dims, T > &pc)
FS_Vector< dims, T > mult(const T &) const
FS_Vector< dims, T > & operator=(const T &a)
bool operator==(const FS_Vector< dims, T > &) const
FS_Vector< dims, T > & fill(const T &)
Implementation of fixed sized Vectors (template argument) which is favorable for small Vectors...
const Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > long int res
double fabssqr(const double a)
FS_Vector< dims, T > cemul(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)
bool contains(const T &, unsigned long *=0) const
FS_Vector< dims, T > plus(const T &) const
T & operator[](const unsigned long i)
T * get_fortran_vector() const
const unsigned TMatrix< T > const Matrix< T > * a
unsigned long size() const
const Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > long int int char v
< find minimun of func on grid with resolution res
FS_Vector(const FS_Vector< dims, U > &fsv)
FS_Vector< dims, T > emul(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)