casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MatrixMath.h
Go to the documentation of this file.
1 //# MatrixMath.h: The AIPS++ Linear Algebra Functions
2 //# Copyright (C) 1994,1995,1999,2000
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 //# Includes
29 
30 #include <casa/aips.h>
31 #include <casa/BasicSL/Complex.h>
32 
33 #define AIPS_ARRAY_INDEX_CHECK
34 
35 //# Forward Declarations
36 template <class T> class LUdecomp;
37 
38 // <thrown>
39 // <item> ArrayError
40 // <item> BlasError
41 // </thrown>
42 
43 //<div><title> The AIPS++ Linear Algebra Functions </title>
44 
45 //
46 // The scalar/dot/inner product of two equal length vectors.
47 //
48 template <class T> T innerProduct (const casacore::Vector<T> &x, const casacore::Vector<T> &y);
49 
50 //
51 // The magnitude/norm of a vector.
52 //
53 template <class T> T norm (const casacore::Vector<T> &x);
54 
55 //
56 // Create a 3D rotation matrix (3x3).
57 // Axis is 0,1,2 for x,y,z; angle is in radians.
58 //
59 template <class T> casacore::Matrix<T> Rot3D(casacore::Int axis, T angle);
60 
61 //
62 // The vector/cross product of two 3-space vectors.
63 //
64 template <class T>
66 
67 //
68 // The matrix/outer product of a vector and a transposed vector.
69 // <note> The function's second argument is actually a transposed vector
70 // stored as the only row in a 1xN matrix.
71 // </note>
72 //
73 template <class T>
75 template <class T>
77 
78 //
79 // The vector/outer product of an MxN matrix and an N-length vector.
80 //
81 template <class T>
83 template <class T>
85 
86 //
87 // The matrix multiplication or cayley product of an MxN matrix and
88 // an NxP matrix.
89 //
90 template <class T>
92 template <class T>
94 
95 //
96 // The NxM transpose of an MxN matrix.
97 //
98 template <class T> casacore::Matrix<T> transpose (const casacore::Matrix<T> &A);
99 
100 //
101 //<div> complex space function specifications
102 //
103 
104 //
105 // The complex conjugate of the complex matrix A.
106 //
107 Matrix<casacore::Complex> conjugate (const casacore::Matrix<casacore::Complex> &A);
108 
109 //
110 // The complex conjugate of the double precision complex matrix A.
111 //
112 Matrix<casacore::DComplex> conjugate (const casacore::Matrix<casacore::DComplex> &A);
113 
114 //
115 // The conjugate/transpose or adjoint of the complex matrix A.
116 //
117 Matrix<casacore::Complex> adjoint (const casacore::Matrix<casacore::Complex> &A);
118 
119 //
120 // The conjugate/transpose or adjoint of the double precision complex matrix A.
121 //
122 Matrix<casacore::DComplex> adjoint (const casacore::Matrix<casacore::DComplex> &A);
123 
124 //</div>
125 
126 // Requires linking of the LAPACK libraries. The LAPACK libraries
127 // can be attained by FTPing to the netlib directory at
128 // Research.ATT.com or by contacting the Numerical Algorithms Group.
129 // +grp
130 //
131 // The inverse of a matrix. <note>The LU decomposition of the matrix
132 // is a hidden calculation. </note>
133 //
134 template <class T> casacore::Matrix<T> inverse (const casacore::Matrix<T> &A);
135 
136 //
137 // The inverse of an LUdecomp which is the Lower/upper
138 // decomposition of a matrix A.
139 //
140 template <class T> casacore::Matrix<T> inverse (const LUdecomp<T> &LU);
141 
142 //
143 // The determinant of a matrix. <note>The LU decomposition of the matrix
144 // is a hidden calculation. </note>
145 //
146 template <class T> T determinant (const casacore::Matrix<T> &A);
147 
148 //
149 // the determinant (A) of an LUdecomp which is the lower/upper
150 // decomposition of a matrix A.
151 //
152 template <class T> T determinant (const LUdecomp<T> &LU);
153 
154 
155 //
156 // Given a matrix "A", and given some vector "y" which is the right hand
157 // side of the equation "Ax=y", then "solve(A, y, error1, error2)"
158 // returns the computed vector "x". (for further details, see the LAPACK
159 // man page for "sgesvx".)
160 //
161 // solve(LUdecomp<T>, casacore::Vector<T>, ...) arguments are (in order):
162 // 1) casacore::Matrix<T> - (input) the matrix "A" that is being modeled by the
163 // equation "Ax=y".
164 // 2) casacore::Vector<T> - (input) the vector "y" that is being modeled by the
165 // equation "Ax=y".
166 // 3) double - (output) the error bound "forwardError" on the returned
167 // vector x, i.e
168 // |max(x - xtrue)|
169 // forwardError > ----------------
170 // |max(x)|
171 //
172 // 4) double - (output) the error bound "backwardError" on the input
173 // vector "y". i.e.
174 // backwardError > |Ax-y|
175 //
176 //<note>The LU decomposition of the matrix is a hidden calculation. </note>
177 //
178 template <class T>
179  casacore::Vector<T> solve (const casacore::Matrix<T> &A, const casacore::Vector<T> &y, double &ferr,
180  double &berr);
181 
182 //
183 // Given an LUdecomp "myLU" which is the LU decomposition of some
184 // matrix "A", and given some vector "y" which is the right hand side of
185 // the equation "Ax=y", then "solve(myLU, y, error1, error2)" returns the
186 // computed vector "x". (for further details, see the LAPACK man page for
187 // "sgesvx".)
188 //
189 // solve(LUdecomp<T>, casacore::Vector<T>, ...) arguments are (in order):
190 // 1) LUdecomp<T> - (input) the LU decomposition of the matrix "A" that
191 // is being modeled by the equation "Ax=y".
192 // 2) casacore::Vector<T> - (input) the vector "y" that is being modeled by the
193 // equation "Ax=y".
194 // 3) double - (output) the error bound "forwardError" on the returned
195 // vector x, i.e
196 // |max(x - xtrue)|
197 // forwardError > ----------------
198 // |max(x)|
199 //
200 // 4) double - (output) the error bound "backwardError" on the input
201 // vector "y". i.e.
202 // backwardError > |Ax-y|
203 //
204 template <class T>
205  casacore::Vector<T> solve (const LUdecomp<T> &myLU, const casacore::Vector<T> &y, double &ferr,
206  double &berr);
207 
208 //
209 // Given a matrix "A", and given a matrix "B" whose columns are the stored
210 // set of vectors "y1", "y2", ..."yN" which are independent right hand sides
211 // to the equation "Ax", e.g. "Ax=y", then "solve(A, B, Error1, Error2)"
212 // returns the computed matrix "X", whose columns are the stored set of
213 // vectors "x1", "x2", ..."xN" which satisfy the equation "Ax=y" for each
214 // respective "y". (for further details, see the LAPACK man page for
215 // "sgesvx".)
216 //
217 // solve(LUdecomp<T>, casacore::Matrix<T>,...) arguments are (in order):
218 // 1) casacore::Matrix<T> - (input) the matrix "A" that is being modeled by the
219 // equation "Ax=y".
220 // 2) casacore::Matrix<T> - (input) MxN matrix "B" of N possible M-length
221 // vectors "y1", "y2",..."yN" stored as columns in a single matrix "B"
222 // where "A*x1=y1, A*x2=y2,..."A*xN=yN" => "AX=B".
223 // 3) casacore::Vector<double> - (output) an N-length vector "Ferr" with error bounds
224 // for returned matrix X, i.e.
225 // max(X.column(i)-Xtrue.column(i))
226 // Ferr(i) > --------------------------------
227 // max(X.column(i))
228 //
229 // 4) casacore::Vector<double> - (output) an N-length vector "Berr" with error bounds
230 // for input matrix "B", i.e
231 // Berr(i) > |max(A*X.column(i)-B.column(i))|
232 //
233 //<note>The LU decomposition of the matrix is a hidden calculation. </note>
234 //
235 template <class T>
238 
239 //
240 // Given an LUdecomp "myLU" which is the LU decomposition of some
241 // matrix "A", and given a matrix "B" whose columns are the stored set of
242 // vectors "y1", "y2", ..."yN" which are independent right hand sides to
243 // the equation "Ax", e.g. "Ax=y", then "solve(myLU, B, Error1, Error2)"
244 // returns the computed matrix "X", whose columns are the stored set of
245 // vectors "x1", "x2", ..."xN" which satisfy the equation "Ax=y" for each
246 // respective "y". (for further details, see the LAPACK man page for
247 // "sgesvx".)
248 //
249 // solve(LUdecomp<T>, casacore::Matrix<T>,...) arguments are (in order):
250 // 1) LUdecomp<T> - (input) the LU decomposition of the matrix "A" that
251 // is being modeled by the equation "Ax=y".
252 // 2) casacore::Matrix<T> - (input) MxN matrix "B" of N possible M-length
253 // vectors "y1", "y2",..."yN" stored as columns in a single matrix "B"
254 // where "A*x1=y1, A*x2=y2,..."A*xN=yN" => "AX=B".
255 // 3) casacore::Vector<double> - (output) an N-length vector "Ferr" with error bounds
256 // for returned matrix X, i.e.
257 // max(X.column(i)-Xtrue.column(i))
258 // Ferr(i) > --------------------------------
259 // max(X.column(i))
260 //
261 // 4) casacore::Vector<double> - (output) an N-length vector "Berr" with error bounds
262 // for input matrix "B", i.e
263 // Berr(i) > |max(A*X.column(i)-B.column(i))|
264 //
265 template <class T>
268 
269 // -grp
270 // </div>
271 
272 #endif
On suns, at least, this needs to link with: lapack.a blas.a Since this links fortran libraries...
Definition: MatrixMath.h:36
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
casacore::Vector< T > crossProduct(const casacore::Vector< T > &x, const casacore::Vector< T > &y)
The vector/cross product of two 3-space vectors.
casacore::Matrix< T > transpose(const casacore::Matrix< T > &A)
The NxM transpose of an MxN matrix.
A 2-D Specialization of the Array class.
T norm(const casacore::Vector< T > &x)
The magnitude/norm of a vector.
Matrix< casacore::Complex > adjoint(const casacore::Matrix< casacore::Complex > &A)
The conjugate/transpose or adjoint of the complex matrix A.
casacore::Matrix< T > Rot3D(casacore::Int axis, T angle)
Create a 3D rotation matrix (3x3).
casacore::Matrix< T > cayleyProduct(const casacore::Matrix< T > &A, const casacore::Matrix< T > &B)
casacore::Matrix< T > inverse(const casacore::Matrix< T > &A)
T determinant(const casacore::Matrix< T > &A)
The determinant of a matrix; Note: The LU decomposition of the matrix is a hidden calculation; ...
T innerProduct(const casacore::Vector< T > &x, const casacore::Vector< T > &y)
casacore::Matrix< T > product(const casacore::Vector< T > &x, const casacore::Matrix< T > &yT)
The matrix/outer product of a vector and a transposed vector.
casacore::Matrix< T > outerProduct(const casacore::Vector< T > &x, const casacore::Matrix< T > &yT)
casacore::Vector< T > solve(const casacore::Matrix< T > &A, const casacore::Vector< T > &y, double &ferr, double &berr)
Given a matrix &quot;A&quot;, and given some vector &quot;y&quot; which is the right hand side of the equation &quot;Ax=y&quot;...
casacore::Matrix< T > LU
Definition: LUdecomp.h:69
Matrix< casacore::Complex > conjugate(const casacore::Matrix< casacore::Complex > &A)
complex space function specifications