casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef CASA_MATRIXMATH_2_H
27#define CASA_MATRIXMATH_2_H
28
29#include "Vector.h"
30#include "Matrix.h"
31
32namespace casacore { // # NAMESPACE CASACORE - BEGIN
33
34//<summary>
35// Linear algebra functions on Vectors and Matrices.
36// </summary>
37//
38// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tLinAlgebra">
39//</reviewed>
40//
41// <linkfrom anchor="Linear Algebra" classes="Vector Matrix">
42// <here>Linear Algebra</here> -- Linear algebra functions
43// on Vectors and Matrices.
44// </linkfrom>
45//
46//<group name="Linear Algebra">
48//
49// The scalar/dot/inner product of two equal length vectors.
50//
51//<group>
52template <class T>
53T innerProduct(const Vector<T> &x, const Vector<T> &y);
54std::complex<float> innerProduct(const Vector<std::complex<float>> &x,
55 const Vector<std::complex<float>> &y);
56std::complex<double> innerProduct(const Vector<std::complex<double>> &x,
57 const Vector<std::complex<double>> &y);
58//</group>
59
60//
61// The magnitude/norm of a vector.
62//<group>
63int norm(const Vector<int> &x);
64float norm(const Vector<float> &x);
65double norm(const Vector<double> &x);
66float norm(const Vector<std::complex<float>> &x);
67double norm(const Vector<std::complex<double>> &x);
68//</group>
69
70//
71// The vector/cross product of two 3-space vectors.
72//
73template <class T>
75
76// Magnitude of cross product of two 2-space vectors, x[0]*y[1] - x[1]*y[0].
77template <class T>
78T crossProduct2D(const Vector<T> &x, const Vector<T> &y);
79//
80// The matrix/outer product of a vector and a transposed vector.
81// <note> The function's second argument is actually a transposed vector
82// stored as the only row in a 1xN matrix. </note>
83//
84template <class T>
85Matrix<T> product(const Vector<T> &x, const Matrix<T> &yT);
86
87//
88// The vector/outer product of an MxN matrix and an N-length vector.
89//
90template <class T>
92
93//
94// The direct product of two vectors.
95// The resulting vector contains for every element of x, the product of
96// that element and Vector y. Thus the length of the output vector is
97// the product of the input lengths.
98//
99template <class T>
101
102//
103// The matrix multiplication or cayley product of an MxN matrix and
104// an NxP matrix.
105//
106template <class T>
108
109//
110// The infinity norm (or maximum value of the sum of the absolute values
111// of the rows members of a matrix)
112// <group>
113int normI(const Matrix<int> &A);
114float normI(const Matrix<float> &A);
115double normI(const Matrix<double> &A);
116float normI(const Matrix<std::complex<float>> &A);
117double normI(const Matrix<std::complex<double>> &A);
118// </group>
119
120//
121// The one norm (or maximum value of the sum of the absolute values
122// of the column members of a matrix)
123//<group>
124int norm1(const Matrix<int> &A);
125float norm1(const Matrix<float> &A);
126double norm1(const Matrix<double> &A);
127float norm1(const Matrix<std::complex<float>> &A);
128double norm1(const Matrix<std::complex<double>> &A);
129//</group>
130
131//
132// The NxM transpose of an MxN matrix.
133//
134template <class T>
136
137// Create a 3D rotation matrix (3x3).
138// Axis is 0,1,2 for x,y,z; angle is in radians.
139// <group>
140template <class T>
141Matrix<T> Rot3D(int axis, T angle);
142Matrix<double> Rot3D(int axis, double angle);
143Matrix<float> Rot3D(int axis, float angle);
144// </group>
145
146//
147// The direct product of two matrices.
148// The resulting matrix contains for every element of A, the product of
149// that element and Matrix B. Thus the shape of the output matrix is
150// the (element by element) product of the input shapes.
151//
152template <class T>
154
155//
156// The conjugate/transpose or adjoint of the complex matrix A.
157//
158Matrix<std::complex<float>> adjoint(const Matrix<std::complex<float>> &A);
159Matrix<std::complex<double>> adjoint(const Matrix<std::complex<double>> &A);
160
161// define the adjoint operator as a plain old transpose when the Matrix is
162// not complex valued. (for templating purposes)
166
167//
168// The product of a std::complex<float> Matrix and a Real Vector
169//
170Vector<std::complex<float>> product(const Matrix<std::complex<float>> &, const Vector<float> &);
171
172//
173// The real part of a product of a std::complex<float> Matrix and a std::complex<float> Vector
174//
175Vector<float> rproduct(const Matrix<std::complex<float>> &, const Vector<std::complex<float>> &);
176
177//
178// The real part of a product of a std::complex<float> Matrix and a std::complex<float> Matrix
179//
180Matrix<float> rproduct(const Matrix<std::complex<float>> &, const Matrix<std::complex<float>> &);
181
182// </group>
183
184} // namespace casacore
185
186#include "MatrixMath.tcc"
187
188#endif
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
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< double > adjoint(const Matrix< double > &A)
Vector< T > product(const Matrix< T > &A, const Vector< T > &x)
The vector/outer product of an MxN matrix and an N-length vector.
int norm(const Vector< int > &x)
The magnitude/norm of a vector.
Matrix< T > Rot3D(int axis, T angle)
Create a 3D rotation matrix (3x3).
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].
float norm1(const Matrix< std::complex< float > > &A)
Matrix< T > directProduct(const Matrix< T > &A, const Matrix< T > &B)
The direct product of two matrices.
float normI(const Matrix< std::complex< float > > &A)
Matrix< int > adjoint(const Matrix< int > &A)
define the adjoint operator as a plain old transpose when the Matrix is not complex valued.
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.
Matrix< std::complex< float > > adjoint(const Matrix< std::complex< float > > &A)
The conjugate/transpose or adjoint of the complex matrix A.
double norm(const Vector< std::complex< double > > &x)
Matrix< std::complex< double > > adjoint(const Matrix< std::complex< double > > &A)
Matrix< T > product(const Vector< T > &x, const Matrix< T > &yT)
The matrix/outer product of a vector and a transposed vector.
std::complex< float > innerProduct(const Vector< std::complex< float > > &x, const Vector< std::complex< float > > &y)
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).
float norm(const Vector< std::complex< float > > &x)
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.
Matrix< float > Rot3D(int axis, float angle)
Matrix< float > adjoint(const Matrix< float > &A)
std::complex< double > innerProduct(const Vector< std::complex< double > > &x, const Vector< std::complex< double > > &y)
Vector< T > crossProduct(const Vector< T > &x, const Vector< T > &y)
The vector/cross product of two 3-space vectors.
double norm1(const Matrix< std::complex< double > > &A)
Matrix< T > transpose(const Matrix< T > &A)
The NxM transpose of an MxN matrix.
T innerProduct(const Vector< T > &x, const Vector< T > &y)
The scalar/dot/inner product of two equal length vectors.
Vector< T > directProduct(const Vector< T > &x, const Vector< T > &y)
The direct product of two vectors.
Matrix< double > Rot3D(int axis, double angle)
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.
double normI(const Matrix< std::complex< double > > &A)
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...