//# TVecMath.h: Global helper functions for table vector mathematics //# Copyright (C) 1994,1995,1999 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id$ #ifndef TABLES_TVECMATH_H #define TABLES_TVECMATH_H //# Includes #include namespace casacore { //# NAMESPACE CASACORE - BEGIN //# Forward Declarations template class TabVecRep; // // Basic math for table vectors. // // // // // // These global functions do the basic math for table vectors. // This means addition, subtraction, multiplication, division // and negation. // In case two table vectors are used, the left and right operand // must be conformant (i.e. have equal length). // // // Add 2 table vectors storing result in first one. template void tabVecReptvassadd (TabVecRep&, const TabVecRep&); // Subtract 2 table vectors storing result in first one. template void tabVecReptvasssub (TabVecRep&, const TabVecRep&); // Multiple 2 table vectors storing result in first one. template void tabVecReptvasstim (TabVecRep&, const TabVecRep&); // Divide 2 table vectors storing result in first one. template void tabVecReptvassdiv (TabVecRep&, const TabVecRep&); // Add a scalar to each element in the table vector. template void tabVecRepvalassadd (TabVecRep&, const T&); // Subtract a scalar from each element in the table vector. template void tabVecRepvalasssub (TabVecRep&, const T&); // Multiple each element in the table vector with a scalar. template void tabVecRepvalasstim (TabVecRep&, const T&); // Divide each element in the table vector by a scalar. template void tabVecRepvalassdiv (TabVecRep&, const T&); // Unary minus - store result in a new vector. // // (unary plus is already handled in TabVecMath). // // template TabVecRep& tabVecRepnegate (const TabVecRep&); // Add 2 table vectors storing result in a new one. template TabVecRep& tabVecReptvadd (const TabVecRep&, const TabVecRep&); // Subtract 2 table vectors storing result in a new one. template TabVecRep& tabVecReptvsub (const TabVecRep&, const TabVecRep&); // Multiple 2 table vectors storing result in a new one. template TabVecRep& tabVecReptvtim (const TabVecRep&, const TabVecRep&); // Divide 2 table vectors storing result in a new one. template TabVecRep& tabVecReptvdiv (const TabVecRep&, const TabVecRep&); // Add a scalar to each element in the table vector storing result // in a new table vector. template TabVecRep& tabVecRepvalradd (const TabVecRep&, const T&); // Subtract a scalar from each element in the table vector storing result // in a new table vector. template TabVecRep& tabVecRepvalrsub (const TabVecRep&, const T&); // Multiple each element in the table vector with a scalar storing result // in a new table vector. template TabVecRep& tabVecRepvalrtim (const TabVecRep&, const T&); // Divide each element in the table vector by a scalar storing result // in a new table vector. template TabVecRep& tabVecRepvalrdiv (const TabVecRep&, const T&); // Add a scalar to each element in the table vector storing result // in a new table vector. template TabVecRep& tabVecRepvalladd (const T&, const TabVecRep&); // Subtract a scalar from each element in the table vector storing result // in a new table vector. template TabVecRep& tabVecRepvallsub (const T&, const TabVecRep&); // Multiple each element in the table vector with a scalar storing result // in a new table vector. template TabVecRep& tabVecRepvalltim (const T&, const TabVecRep&); // Divide each element in the table vector by a scalar storing result // in a new table vector. template TabVecRep& tabVecRepvalldiv (const T&, const TabVecRep&); // // // Transcendental math for table vectors. // // // // // // These global functions do the transcendental math for table vectors // for essentially all numeric types. // The functions are sin, sinh, exp, log, pow, etc.. // In case two table vectors are used, the left and right operand // must be conformant (i.e. have equal length). // // template TabVecRep& tabVecRepcos (const TabVecRep&); template TabVecRep& tabVecRepcosh (const TabVecRep&); template TabVecRep& tabVecRepexp (const TabVecRep&); template TabVecRep& tabVecReplog (const TabVecRep&); template TabVecRep& tabVecReplog10(const TabVecRep&); template TabVecRep& tabVecReppow (const TabVecRep&, const TabVecRep&); template TabVecRep& tabVecRepsin (const TabVecRep&); template TabVecRep& tabVecRepsinh (const TabVecRep&); template TabVecRep& tabVecRepsqrt (const TabVecRep&); // // // Further transcendental math for table vectors. // // // // // // These global functions do the transcendental math for table vectors // for a limited set of numeric types. // The functions are asin, ceil, etc.. // In case two table vectors are used, the left and right operand // must be conformant (i.e. have equal length). // // template TabVecRep& tabVecRepacos (const TabVecRep&); template TabVecRep& tabVecRepasin (const TabVecRep&); template TabVecRep& tabVecRepatan (const TabVecRep&); template TabVecRep& tabVecRepatan2(const TabVecRep&, const TabVecRep&); template TabVecRep& tabVecRepceil (const TabVecRep&); template TabVecRep& tabVecRepfabs (const TabVecRep&); template TabVecRep& tabVecRepfloor(const TabVecRep&); template TabVecRep& tabVecRepfmod (const TabVecRep&, const TabVecRep&); template TabVecRep& tabVecReppow (const TabVecRep&, const double&); template TabVecRep& tabVecReptan (const TabVecRep&); template TabVecRep& tabVecReptanh (const TabVecRep&); // // // Miscellaneous table vector operations. // // // // // // Fill a table vector or calculate the sum, product, minimum or // maximum of its elements. // // // Determine minimum and maximum value in a table vector. // Requires that the type "T" has comparison operators. template void tabVecRepminmax (T& min, T& max, const TabVecRep&); // Fills all elements of the table vector with a sequence starting with // "start" and incrementing by "inc" for each element. template void tabVecRepindgen (TabVecRep&, T start, T inc); // Sum of all the elements of a table vector. template T tabVecRepsum (const TabVecRep&); // Product of all the elements of a table vector. // // product can easily overflow. // template T tabVecRepproduct (const TabVecRep&); // // // Vector operations on a table vector. // // // // // // Do vector operations on a table vector (like inner product). // // // The inner product of 2 table vectors. template T tabVecRepinnerproduct (const TabVecRep&, const TabVecRep&); // The norm of a table vector. template T tabVecRepnorm (const TabVecRep&); // The cross product of 2 table vectors containing 3 elements. template TabVecRep& tabVecRepcrossproduct (const TabVecRep&, const TabVecRep&); // } //# NAMESPACE CASACORE - END #ifndef CASACORE_NO_AUTO_TEMPLATES #include #endif //# CASACORE_NO_AUTO_TEMPLATES #endif