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"
48template <
unsigned dims,
typename T,
unsigned dims2>
61template <
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; }
149 bool contains (
const T&,
unsigned long* = 0)
const;
155 double fabs ()
const;
165 {
return !((*this) >= fv); }
167 {
return !((*this) <= fv); }
185 template <
unsigned dims,
typename T,
unsigned d2>
196template <
unsigned dims,
typename T>
204template <
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
221template <
unsigned dims,
typename T>
229template <
unsigned dims,
typename T>
235template <
unsigned dims,
typename T>
241template <
unsigned dims,
typename T>
247template <
unsigned dims,
typename T>
254template <
unsigned dims,
typename T>
257 for (
unsigned long i = 0;
i <
dims; ++
i)
262template <
unsigned dims,
typename T>
269template <
unsigned dims,
typename T>
276template <
unsigned dims,
typename T>
279 return (fabsqr() <= fv.
fabssqr());
282template <
unsigned dims,
typename T>
285 return (fabsqr() >= fv.
fabssqr());
289#define FSV_ASS_FSV(op) \
290template <unsigned dims, typename T> \
291inline 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) \
302template <unsigned dims, typename T> \
303inline 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) \
315template <unsigned dims, typename T> \
316inline 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) \
329template <unsigned dims, typename T> \
330inline 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) \
343template <
unsigned dims, typename
T>
347 for (
unsigned long i = 0;
i <
dims; ++
i)
353template <
unsigned dims,
typename T>
358 for (
unsigned long i = 0;
i <
dims; ++
i)
364template <
unsigned dims,
typename T>
368 for (
unsigned long i = 0;
i <
dims; ++
i)
374template <
unsigned dims,
typename T>
384template <
unsigned dims,
typename T>
387 if (!
dims)
return os;
389 for (
unsigned long i = 1;
i <
dims; ++
i)
390 os <<
", " << fv.
x[
i];
395template <
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);
417template <
unsigned dims,
typename T>
420 STD__ cerr <<
"fs_vector: Input on pointer types not possible!" <<
STD__ endl;
427template <
unsigned dims,
typename T>
438template <
unsigned dims,
typename T>
441 if (
dims == 0)
return 0;
449template <
unsigned dims,
typename T>
452 if (
dims == 0)
return 0;
460template <
unsigned dims,
typename T>
470template <
unsigned dims,
typename T>
473 if (
dims == 0)
return 0;
480template <
unsigned dims,
typename T>
486template <
unsigned dims,
typename T>
492template <
unsigned dims,
typename T>
499template <
unsigned dims,
typename T,
unsigned long dims2>
509template <
unsigned dims,
typename T>
513 for (
unsigned long i = 0;
i <
dims; ++
i)
518template <
unsigned dims,
typename T>
522 for (
unsigned long i = 0;
i <
dims; ++
i)
527template <
unsigned dims,
typename T>
531 for (
unsigned long i = 0;
i <
dims; ++
i)
536template <
unsigned dims,
typename T>
540 for (
unsigned long i = 0;
i <
dims; ++
i)
547template <unsigned dims, typename T>
552#define FSV_MEM_FRD(nm,op) \
553template <unsigned dims, typename T> \
554INLINE 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]; \
568template <
unsigned dims, typename
T>
570{
return fv.mult (v); }
573template <unsigned dims, typename T>
575{
return fv.
plus(v); }
578template <unsigned dims, typename T>
580{
return fv.
minus(v); }
588template <unsigned dims, typename T>
593template <unsigned dims, typename T>
598template <unsigned dims, typename T>
607template <unsigned dims, typename T>
611#if (_MSC_VER) && (_MSC_VER == 1200)
615template <unsigned dims, typename T>
#define BCHK(cond, exc, txt, ind, rtval)
#define NAMESPACE_CSTD_END
#define BCHKNR(cond, exc, txt, ind)
provides basic Vector functionality but arithmetic operators (+=, - , *, /...).
T *const & vecptr() const
unsigned long size() const HOT
Implementation of fixed sized Vectors (template argument) which is favorable for small Vectors,...
FS_Vector< dims, T > minus(const T &) const
FS_Vector< dims, T > operator-() const
bool contains(const T &, unsigned long *=0) const
FS_Vector< dims, T > & init_0()
bool operator<(const FS_Vector< dims, T > &fv) const
FS_Vector< dims, T > & operator/=(const T &)
bool operator==(const FS_Vector< dims, T > &) const
T & operator()(const unsigned long i)
bool operator!=(const FS_Vector< dims, T > &fv) const
friend T dot FGD(const FS_Vector< dims, T > &, const FS_Vector< dims, T > &)
FS_Vector< dims, T > operator+(const FS_Vector< dims, T > &) const
FS_Vector< dims, T > incr(const unsigned long, const T=(T) 1) const
bool operator>=(const FS_Vector< dims, T > &fv) const
FS_Vector< dims, T > operator/(const T &) const
unsigned long size() const
FS_Vector(const FS_Vector< dims, U > &fsv)
bool operator<=(const FS_Vector< dims, T > &fv) const
FS_Vector< dims, T > mult(const T &) const
FS_Vector< dims, T > & operator*=(const T &)
T aligned_value_type TALIGN(MIN_ALIGN)
FS_Vector< dims, T > & operator+=(const FS_Vector< dims, T > &)
FS_Vector(const FS_Vector< dims, T > &pc)
bool operator>(const FS_Vector< dims, T > &fv) const
FS_Vector< dims, T > plus(const T &) const
T * get_fortran_vector() const
FS_Vector< dims, T > & fill(const T &)
FS_Vector< dims, T > & operator=(const T &a)
FS_Vector< dims, T > & clear()
T & operator[](const unsigned long i)
FS_Vector< dims, T > & operator-=(const FS_Vector< dims, T > &)
FSVecErr(const FSVecErr &fe)
FSVecErr(const char *t, const long i=0)
double fabs(const TBCI__ cplx< T > &c)
double fabssqr(const cplx< T > &c)
NAMESPACE_END NAMESPACE_CPLX TBCI__ cplx< T > conj(const TBCI__ cplx< T > &c)
NAMESPACE_END NAMESPACE_CSTD TBCI__ cplx< T > sqrt(const TBCI__ cplx< T > &z)
FS_Vector< dims, T > cediv(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)
T sum(const FS_Vector< dims, T > &fv)
STD__ ostream & operator<<(STD__ ostream &os, const FS_Vector< dims, T > &fv)
T dot(const FS_Vector< dims, T > &fv1, const FS_Vector< dims, T > &fv2)
double fabssqr(const FS_Vector< dims, T > &fv)
STD__ istream & operator>>(STD__ istream &in, FS_Vector< dims, T > &v)
FS_Vector< dims, T > ediv(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)
#define FSV_MEM_FRD(nm, op)
#define FSV_NOASS_FSV(op)
FS_Vector< dims, T > emul(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)
FS_Vector< dims, T > slice(const FS_Vector< dims, T > &fv, const unsigned long s, const unsigned long e)
FS_Vector< dims, T > cemul(const FS_Vector< dims, T > &f1, const FS_Vector< dims, T > &f2)
const unsigned TMatrix< T > const Matrix< T > * a
const unsigned TMatrix< T > * res