casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MatrixMath.h
Go to the documentation of this file.
00001 //# MatrixMath.h: The AIPS++ linear algebra functions
00002 //# Copyright (C) 1994,1995,1996,1999,2000,2002
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: MatrixMath.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_MATRIXMATH_H
00029 #define CASA_MATRIXMATH_H
00030 
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <casa/BasicSL/Complex.h>
00036 
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //<summary>
00041 //    Linear algebra functions on Vectors and Matrices.
00042 // </summary>
00043 //
00044 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tLinAlgebra">
00045 //</reviewed>
00046 //
00047 // <linkfrom anchor="Linear Algebra" classes="Vector Matrix">
00048 //    <here>Linear Algebra</here> -- Linear algebra functions
00049 //     on Vectors and Matrices.
00050 // </linkfrom>
00051 //
00052 //<group name="Linear Algebra">
00053 
00054 //
00055 // The scalar/dot/inner product of two equal length vectors.
00056 //
00057 //<group>
00058 template <class T> T innerProduct (const Vector<T> &x, const Vector<T> &y);
00059 Complex innerProduct (const Vector<Complex> &x, const Vector<Complex> &y);
00060 DComplex innerProduct (const Vector<DComplex> &x, const Vector<DComplex> &y);
00061 //</group>
00062 
00063 //
00064 // The magnitude/norm of a vector.
00065 //<group>
00066 Int norm (const Vector<Int> &x);
00067 Float norm (const Vector<Float> &x);
00068 Double norm (const Vector<Double> &x);
00069 Float norm (const Vector<Complex> &x);
00070 Double norm (const Vector<DComplex> &x);
00071 //</group>
00072 
00073 //
00074 // The vector/cross product of two 3-space vectors.
00075 //
00076 template <class T> 
00077    Vector<T> crossProduct (const Vector<T> &x, const Vector<T> &y);
00078 
00079 //
00080 // The matrix/outer product of a vector and a transposed vector. 
00081 // <note> The function's second argument is actually a transposed vector
00082 // stored as the only row in a 1xN matrix. </note>
00083 //
00084 template <class T>
00085    Matrix<T> product (const Vector<T> &x, const Matrix<T> &yT);
00086 
00087 //
00088 // The vector/outer product of an MxN matrix and an N-length vector.
00089 //
00090 template <class T>
00091    Vector<T> product (const Matrix<T> &A, const Vector<T> &x);
00092 
00093 // 
00094 // The direct product of two vectors.
00095 // The resulting vector contains for every element of x, the product of
00096 // that element and Vector y. Thus the length of the output vector is
00097 // the product of the input lengths.
00098 //
00099 template <class T> 
00100    Vector<T> directProduct(const Vector<T>& x, const Vector<T>& y);
00101 
00102 //
00103 // The matrix multiplication or cayley product of an MxN matrix and
00104 // an NxP matrix.
00105 //
00106 template <class T> 
00107    Matrix<T> product (const Matrix<T> &A, const Matrix<T> &B);
00108 
00109 //
00110 // The infinity norm (or maximum value of the sum of the absolute values 
00111 // of the rows members of a matrix)
00112 // <group>
00113 Int normI(const Matrix<Int> &A);
00114 Float normI(const Matrix<Float> &A);
00115 Double normI(const Matrix<Double> &A);
00116 Float normI(const Matrix<Complex> &A);
00117 Double normI(const Matrix<DComplex> &A);
00118 // </group>
00119 
00120 //
00121 // The one norm (or maximum value of the sum of the absolute values 
00122 // of the column members of a matrix)
00123 //<group>
00124 Int norm1(const Matrix<Int> &A);
00125 Float norm1(const Matrix<Float> &A);
00126 Double norm1(const Matrix<Double> &A);
00127 Float norm1(const Matrix<Complex> &A);
00128 Double norm1(const Matrix<DComplex> &A);
00129 //</group>
00130 
00131 //
00132 // The NxM transpose of an MxN matrix.
00133 //
00134 template <class T> Matrix<T> transpose (const Matrix<T> &A);
00135 
00136 // Create a 3D rotation matrix (3x3).
00137 // Axis is 0,1,2 for x,y,z; angle is in radians.
00138 // <group>
00139 template <class T> Matrix<T> Rot3D(Int axis, T angle);
00140 Matrix<Double> Rot3D(Int axis, Double angle);
00141 Matrix<Float> Rot3D(Int axis, Float angle);
00142 // </group>
00143 
00144 // 
00145 // The direct product of two matrices.
00146 // The resulting matrix contains for every element of A, the product of
00147 // that element and Matrix B. Thus the shape of the output matrix is
00148 // the (element by element) product of the input shapes.
00149 //
00150 template <class T> 
00151    Matrix<T> directProduct(const Matrix<T>& A, const Matrix<T>& B);
00152 
00153 //
00154 // The complex conjugate of the complex matrix A.
00155 //
00156 Matrix<Complex> conjugate (const Matrix<Complex> &A);
00157 
00158 //
00159 // The complex conjugate of the double precision complex matrix A.
00160 //
00161 Matrix<DComplex> conjugate (const Matrix<DComplex> &A);
00162 
00163 //
00164 // The conjugate/transpose or adjoint of the complex matrix A.
00165 //
00166 Matrix<Complex> adjoint (const Matrix<Complex> &A);
00167 Matrix<DComplex> adjoint (const Matrix<DComplex> &A);
00168 
00169 // define the adjoint operator as a plain old transpose when the Matrix is 
00170 // not complex valued. (for templating purposes)
00171 Matrix<Int> adjoint (const Matrix<Int> &A);
00172 Matrix<Float> adjoint (const Matrix<Float> &A);
00173 Matrix<Double> adjoint (const Matrix<Double> &A);
00174 
00175 //
00176 // The product of a Complex Matrix and a Real Vector
00177 //
00178   Vector<Complex> product(const Matrix<Complex>&, const Vector<Float>&);
00179 
00180 //
00181 // The real part of a product of a Complex Matrix and a Complex Vector
00182 //
00183   Vector<Float> rproduct(const Matrix<Complex>&, const Vector<Complex>&);
00184 
00185 //
00186 // The real part of a product of a Complex Matrix and a Complex Matrix
00187 //
00188   Matrix<Float> rproduct (const Matrix<Complex>&, const Matrix<Complex>&);
00189 
00190 // </group>
00191 
00192 
00193 } //# NAMESPACE CASA - END
00194 
00195 #ifndef CASACORE_NO_AUTO_TEMPLATES
00196 #include <casa/Arrays/MatrixMath.tcc>
00197 #endif //# CASACORE_NO_AUTO_TEMPLATES
00198 #endif
00199