/*************************************************************************** vect.hh - Small inline vectors ------------------- begin : Sun Jun 11 2000 copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.6 2001/12/14 16:39:43 schnetter Exp $ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef VECT_HH #define VECT_HH #include #include #include using namespace std; // Forward definition template class vect; // Output template ostream& operator<< (ostream& os, const vect& a); // Vect class template class vect { // Fields T elt[D]; public: // Constructors explicit vect () { } vect (const vect& a) { for (int d=0; d explicit vect (const vect& a) { for (int d=0; d=0 && d=0 && d vect operator[] (const vect& a) const { vect r; for (int d=0; d operator! () const { vect r; for (int d=0; d operator&& (const T x) const { vect r; for (int d=0; d operator|| (const T x) const { vect r; for (int d=0; d operator&& (const vect& a) const { vect r; for (int d=0; d operator|| (const vect& a) const { vect r; for (int d=0; d operator== (const vect& a) const { vect r; for (int d=0; d operator!= (const vect& a) const { vect r; for (int d=0; d operator< (const vect& a) const { vect r; for (int d=0; d operator<= (const vect& a) const { vect r; for (int d=0; d operator> (const vect& a) const { vect r; for (int d=0; da[d]; return r; } vect operator>= (const vect& a) const { vect r; for (int d=0; d=a[d]; return r; } #if 0 vect operator?: (const vect& a, const vect& b) const { vect r(*this); for (int d=0; d inline vect abs (const vect& a) { vect r; for (int d=0; d inline vect max (const vect& a, const vect& b) { vect r; for (int d=0; d inline vect min (const vect& a, const vect& b) { vect r; for (int d=0; d inline bool any (const vect& a) { bool r(false); for (int d=0; d inline bool all (const vect& a) { bool r(true); for (int d=0; d inline int count (const vect& a) { return D; } template inline T dot (const vect& a, const vect& b) { T r(0); for (int d=0; d inline T hypot (const vect& a) { return sqrt(dot(a,a)); } template inline T maxval (const vect& a) { assert (D>0); T r(a[0]); for (int d=1; d inline T minval (const vect& a) { assert (D>0); T r(a[0]); for (int d=1; d inline int maxloc (const vect& a) { assert (D>0); int r(0); for (int d=1; da[r]) r=d; return r; } template inline int minloc (const vect& a) { assert (D>0); int r(0); for (int d=1; d inline T prod (const vect& a) { T r(1); for (int d=0; d inline int size (const vect& a) { return D; } template inline T sum (const vect& a) { T r(0); for (int d=0; d inline vect map (TT (* const func)(T x), const vect& a) { vect r; for (int d=0; d inline vect fold (TT (* const func)(TT val, T x), TT val, const vect& a) { for (int d=0; d inline vect scan0 (TT (* const func)(TT val, T x), TT val, const vect& a) { vect r; for (int d=0; d inline vect scan1 (TT (* const func)(TT val, T x), TT val, const vect& a) { vect r; for (int d=0; d inline ostream& operator<< (ostream& os, const vect& a) { a.output(os); return os; } #if defined(TMPL_IMPLICIT) # include "vect.cc" #endif #endif // VECT_HH