casacore
MatrixMath.h
Go to the documentation of this file.
1 //# MatrixMath.h: The Casacore linear algebra functions
2 //# Copyright (C) 1994,1995,1996,1999,2000,2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_MATRIXMATH_2_H
29 #define CASA_MATRIXMATH_2_H
30 
31 #include "Vector.h"
32 #include "Matrix.h"
33 
34 namespace casacore { //# NAMESPACE CASACORE - BEGIN
35 
36 //<summary>
37 // Linear algebra functions on Vectors and Matrices.
38 // </summary>
39 //
40 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tLinAlgebra">
41 //</reviewed>
42 //
43 // <linkfrom anchor="Linear Algebra" classes="Vector Matrix">
44 // <here>Linear Algebra</here> -- Linear algebra functions
45 // on Vectors and Matrices.
46 // </linkfrom>
47 //
48 //<group name="Linear Algebra">
49 
50 //
51 // The scalar/dot/inner product of two equal length vectors.
52 //
53 //<group>
54 template <class T> T innerProduct (const Vector<T> &x, const Vector<T> &y);
55 std::complex<float> innerProduct (const Vector<std::complex<float>> &x, const Vector<std::complex<float>> &y);
56 std::complex<double> innerProduct (const Vector<std::complex<double>> &x, const Vector<std::complex<double>> &y);
57 //</group>
58 
59 //
60 // The magnitude/norm of a vector.
61 //<group>
62 int norm (const Vector<int> &x);
63 float norm (const Vector<float> &x);
64 double norm (const Vector<double> &x);
65 float norm (const Vector<std::complex<float>> &x);
66 double norm (const Vector<std::complex<double>> &x);
67 //</group>
68 
69 //
70 // The vector/cross product of two 3-space vectors.
71 //
72 template <class T>
73  Vector<T> crossProduct (const Vector<T> &x, const Vector<T> &y);
74 
75 // Magnitude of cross product of two 2-space vectors, x[0]*y[1] - x[1]*y[0].
76 template <class T> T crossProduct2D(const Vector<T> &x, const Vector<T> &y);
77 //
78 // The matrix/outer product of a vector and a transposed vector.
79 // <note> The function's second argument is actually a transposed vector
80 // stored as the only row in a 1xN matrix. </note>
81 //
82 template <class T>
83  Matrix<T> product (const Vector<T> &x, const Matrix<T> &yT);
84 
85 //
86 // The vector/outer product of an MxN matrix and an N-length vector.
87 //
88 template <class T>
89  Vector<T> product (const Matrix<T> &A, const Vector<T> &x);
90 
91 //
92 // The direct product of two vectors.
93 // The resulting vector contains for every element of x, the product of
94 // that element and Vector y. Thus the length of the output vector is
95 // the product of the input lengths.
96 //
97 template <class T>
99 
100 //
101 // The matrix multiplication or cayley product of an MxN matrix and
102 // an NxP matrix.
103 //
104 template <class T>
105  Matrix<T> product (const Matrix<T> &A, const Matrix<T> &B);
106 
107 //
108 // The infinity norm (or maximum value of the sum of the absolute values
109 // of the rows members of a matrix)
110 // <group>
111 int normI(const Matrix<int> &A);
112 float normI(const Matrix<float> &A);
113 double normI(const Matrix<double> &A);
114 float normI(const Matrix<std::complex<float>> &A);
115 double normI(const Matrix<std::complex<double>> &A);
116 // </group>
117 
118 //
119 // The one norm (or maximum value of the sum of the absolute values
120 // of the column members of a matrix)
121 //<group>
122 int norm1(const Matrix<int> &A);
123 float norm1(const Matrix<float> &A);
124 double norm1(const Matrix<double> &A);
125 float norm1(const Matrix<std::complex<float>> &A);
126 double norm1(const Matrix<std::complex<double>> &A);
127 //</group>
128 
129 //
130 // The NxM transpose of an MxN matrix.
131 //
132 template <class T> Matrix<T> transpose (const Matrix<T> &A);
133 
134 // Create a 3D rotation matrix (3x3).
135 // Axis is 0,1,2 for x,y,z; angle is in radians.
136 // <group>
137 template <class T> Matrix<T> Rot3D(int axis, T angle);
138 Matrix<double> Rot3D(int axis, double angle);
139 Matrix<float> Rot3D(int axis, float angle);
140 // </group>
141 
142 //
143 // The direct product of two matrices.
144 // The resulting matrix contains for every element of A, the product of
145 // that element and Matrix B. Thus the shape of the output matrix is
146 // the (element by element) product of the input shapes.
147 //
148 template <class T>
150 
151 //
152 // The conjugate/transpose or adjoint of the complex matrix A.
153 //
154 Matrix<std::complex<float>> adjoint (const Matrix<std::complex<float>> &A);
155 Matrix<std::complex<double>> adjoint (const Matrix<std::complex<double>> &A);
156 
157 // define the adjoint operator as a plain old transpose when the Matrix is
158 // not complex valued. (for templating purposes)
162 
163 //
164 // The product of a std::complex<float> Matrix and a Real Vector
165 //
166  Vector<std::complex<float>> product(const Matrix<std::complex<float>>&, const Vector<float>&);
167 
168 //
169 // The real part of a product of a std::complex<float> Matrix and a std::complex<float> Vector
170 //
171  Vector<float> rproduct(const Matrix<std::complex<float>>&, const Vector<std::complex<float>>&);
172 
173 //
174 // The real part of a product of a std::complex<float> Matrix and a std::complex<float> Matrix
175 //
176  Matrix<float> rproduct (const Matrix<std::complex<float>>&, const Matrix<std::complex<float>>&);
177 
178 // </group>
179 
180 
181 } //# NAMESPACE CASACORE - END
182 
183 #include "MatrixMath.tcc"
184 
185 #endif
186 
this file contains all the compiler specific defines
Definition: mainpage.dox:28
Matrix< T > product(const Vector< T > &x, const Matrix< T > &yT)
The matrix/outer product of a vector and a transposed vector.
Matrix< float > Rot3D(int axis, float angle)
Matrix< double > Rot3D(int axis, double angle)
double norm(const Vector< std::complex< double >> &x)
std::complex< double > innerProduct(const Vector< std::complex< double >> &x, const Vector< std::complex< double >> &y)
int norm(const Vector< int > &x)
The magnitude/norm of a vector.
T crossProduct2D(const Vector< T > &x, const Vector< T > &y)
Magnitude of cross product of two 2-space vectors, x[0]*y[1] - x[1]*y[0].
double norm1(const Matrix< std::complex< double >> &A)
double normI(const Matrix< std::complex< double >> &A)
std::complex< float > innerProduct(const Vector< std::complex< float >> &x, const Vector< std::complex< float >> &y)
Matrix< float > adjoint(const Matrix< float > &A)
Matrix< std::complex< double > > adjoint(const Matrix< std::complex< double >> &A)
Vector< T > directProduct(const Vector< T > &x, const Vector< T > &y)
The direct product of two vectors.
Matrix< float > rproduct(const Matrix< std::complex< float >> &, const Matrix< std::complex< float >> &)
The real part of a product of a std::complex<float> Matrix and a std::complex<float> Matrix.
float normI(const Matrix< std::complex< float >> &A)
Vector< std::complex< float > > product(const Matrix< std::complex< float >> &, const Vector< float > &)
The product of a std::complex<float> Matrix and a Real Vector.
float norm(const Vector< std::complex< float >> &x)
float norm1(const Matrix< std::complex< float >> &A)
Matrix< double > adjoint(const Matrix< double > &A)
int norm1(const Matrix< int > &A)
The one norm (or maximum value of the sum of the absolute values of the column members of a matrix)
Vector< T > crossProduct(const Vector< T > &x, const Vector< T > &y)
The vector/cross product of two 3-space vectors.
Matrix< int > adjoint(const Matrix< int > &A)
define the adjoint operator as a plain old transpose when the Matrix is not complex valued.
Vector< float > rproduct(const Matrix< std::complex< float >> &, const Vector< std::complex< float >> &)
The real part of a product of a std::complex<float> Matrix and a std::complex<float> Vector.
Matrix< T > Rot3D(int axis, T angle)
Create a 3D rotation matrix (3x3).
Matrix< T > directProduct(const Matrix< T > &A, const Matrix< T > &B)
The direct product of two matrices.
Matrix< std::complex< float > > adjoint(const Matrix< std::complex< float >> &A)
The conjugate/transpose or adjoint of the complex matrix A.
Matrix< T > product(const Matrix< T > &A, const Matrix< T > &B)
The matrix multiplication or cayley product of an MxN matrix and an NxP matrix.
T innerProduct(const Vector< T > &x, const Vector< T > &y)
The scalar/dot/inner product of two equal length vectors.
int normI(const Matrix< int > &A)
The infinity norm (or maximum value of the sum of the absolute values of the rows members of a matrix...
Vector< T > product(const Matrix< T > &A, const Vector< T > &x)
The vector/outer product of an MxN matrix and an N-length vector.
Matrix< T > transpose(const Matrix< T > &A)
The NxM transpose of an MxN matrix.