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> T innerProduct (const Vector<T> &x, const Vector<T> &y);
53std::complex<float> innerProduct (const Vector<std::complex<float>> &x, const Vector<std::complex<float>> &y);
54std::complex<double> innerProduct (const Vector<std::complex<double>> &x, const Vector<std::complex<double>> &y);
55//</group>
56
57//
58// The magnitude/norm of a vector.
59//<group>
60int norm (const Vector<int> &x);
61float norm (const Vector<float> &x);
62double norm (const Vector<double> &x);
63float norm (const Vector<std::complex<float>> &x);
64double norm (const Vector<std::complex<double>> &x);
65//</group>
66
67//
68// The vector/cross product of two 3-space vectors.
69//
70template <class T>
72
73// Magnitude of cross product of two 2-space vectors, x[0]*y[1] - x[1]*y[0].
74template <class T> T crossProduct2D(const Vector<T> &x, const Vector<T> &y);
75//
76// The matrix/outer product of a vector and a transposed vector.
77// <note> The function's second argument is actually a transposed vector
78// stored as the only row in a 1xN matrix. </note>
79//
80template <class T>
81 Matrix<T> product (const Vector<T> &x, const Matrix<T> &yT);
82
83//
84// The vector/outer product of an MxN matrix and an N-length vector.
85//
86template <class T>
87 Vector<T> product (const Matrix<T> &A, const Vector<T> &x);
88
89//
90// The direct product of two vectors.
91// The resulting vector contains for every element of x, the product of
92// that element and Vector y. Thus the length of the output vector is
93// the product of the input lengths.
94//
95template <class T>
97
98//
99// The matrix multiplication or cayley product of an MxN matrix and
100// an NxP matrix.
101//
102template <class T>
103 Matrix<T> product (const Matrix<T> &A, const Matrix<T> &B);
104
105//
106// The infinity norm (or maximum value of the sum of the absolute values
107// of the rows members of a matrix)
108// <group>
109int normI(const Matrix<int> &A);
110float normI(const Matrix<float> &A);
111double normI(const Matrix<double> &A);
112float normI(const Matrix<std::complex<float>> &A);
113double normI(const Matrix<std::complex<double>> &A);
114// </group>
115
116//
117// The one norm (or maximum value of the sum of the absolute values
118// of the column members of a matrix)
119//<group>
120int norm1(const Matrix<int> &A);
121float norm1(const Matrix<float> &A);
122double norm1(const Matrix<double> &A);
123float norm1(const Matrix<std::complex<float>> &A);
124double norm1(const Matrix<std::complex<double>> &A);
125//</group>
126
127//
128// The NxM transpose of an MxN matrix.
129//
130template <class T> Matrix<T> transpose (const Matrix<T> &A);
131
132// Create a 3D rotation matrix (3x3).
133// Axis is 0,1,2 for x,y,z; angle is in radians.
134// <group>
135template <class T> Matrix<T> Rot3D(int axis, T angle);
136Matrix<double> Rot3D(int axis, double angle);
137Matrix<float> Rot3D(int axis, float angle);
138// </group>
139
140//
141// The direct product of two matrices.
142// The resulting matrix contains for every element of A, the product of
143// that element and Matrix B. Thus the shape of the output matrix is
144// the (element by element) product of the input shapes.
145//
146template <class T>
148
149//
150// The conjugate/transpose or adjoint of the complex matrix A.
151//
152Matrix<std::complex<float>> adjoint (const Matrix<std::complex<float>> &A);
153Matrix<std::complex<double>> adjoint (const Matrix<std::complex<double>> &A);
154
155// define the adjoint operator as a plain old transpose when the Matrix is
156// not complex valued. (for templating purposes)
160
161//
162// The product of a std::complex<float> Matrix and a Real Vector
163//
164 Vector<std::complex<float>> product(const Matrix<std::complex<float>>&, const Vector<float>&);
165
166//
167// The real part of a product of a std::complex<float> Matrix and a std::complex<float> Vector
168//
169 Vector<float> rproduct(const Matrix<std::complex<float>>&, const Vector<std::complex<float>>&);
170
171//
172// The real part of a product of a std::complex<float> Matrix and a std::complex<float> Matrix
173//
174 Matrix<float> rproduct (const Matrix<std::complex<float>>&, const Matrix<std::complex<float>>&);
175
176// </group>
177
178
179} //# NAMESPACE CASACORE - END
180
181#include "MatrixMath.tcc"
182
183#endif
184
this file contains all the compiler specific defines
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...