00001 //# Quantum.h: class to manipulate physical, dimensioned quantities 00002 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: Quantum.h 20993 2010-11-08 13:36:32Z gervandiepen $ 00027 00028 #ifndef CASA_QVECTOR_H 00029 #define CASA_QVECTOR_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/casa/Quanta/Quantum.h> 00034 00035 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00036 00037 template <class T> class QVector; 00038 00039 typedef QVector<Double> QVD; 00040 00041 // <summary> 00042 // Specialization for Quantum<Vector<T> > 00043 // </summary> 00044 00045 // <use visibility=export> 00046 // 00047 // <prerequisite> 00048 // <li> <linkto class=Quantum>Quantum</linkto> 00049 // </prerequisite> 00050 // 00051 // <etymology> 00052 // Vector of quantities. 00053 // </etymology> 00054 // 00055 // <synopsis> 00056 // Objects of type Quantum<Vector<Double> > are used often in our code. 00057 // We need a way to access individual elements easily 00058 // </synopsis> 00059 00060 template <class T> class QVector : public Quantum<Vector<T> > { 00061 00062 public: 00063 00064 // zero elements 00065 QVector(); 00066 00067 QVector(const Vector<T>& v, const Unit& u); 00068 00069 // convert a Vector of Quanta to a QVector. Useful 00070 // when reading a table column of Quanta. All elements in 00071 // q will be converted to units of the first element in q. 00072 // An exception will be thrown if not all elements in q conform 00073 // to the same unit. 00074 QVector(const Vector<Quantum<T> >& q); 00075 00076 // Copy constructor (deep copy) 00077 QVector(const QVector& other); 00078 00079 ~QVector(); 00080 // access single element 00081 Quantum<T> operator[](uInt index) const; 00082 00083 size_t size() const; 00084 00085 size_t nelements() const; 00086 00087 void scale(T d); 00088 00089 // add operators as needed 00090 QVector<T> operator+(const QVector<T>& d) const; 00091 QVector<T> operator-(const QVector<T>& d) const; 00092 QVector<T> operator/(T d) const; 00093 00094 00095 Quantum<T> min() const; 00096 00097 Quantum<T> max() const; 00098 00099 }; 00100 00101 } 00102 00103 #ifndef CASACORE_NO_AUTO_TEMPLATES 00104 #include <casacore/casa/Quanta/QVector.tcc> 00105 #endif 00106 00107 #endif