00001 // SuperMix version 1.0 C++ source file 00002 // 00003 // Copyright (c) 1999 California Institute of Technology. 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms for noncommercial 00007 // purposes are permitted provided that the above copyright notice and 00008 // this paragraph are duplicated in all such forms and that any 00009 // documentation and other materials related to such distribution and 00010 // use acknowledge that the software was developed by California 00011 // Institute of Technology. Redistribution and/or use in source or 00012 // binary forms is not permitted for any commercial purpose. Use of 00013 // this software does not include a permitted use of the Institute's 00014 // name or trademark for any purpose. 00015 // 00016 // DISCLAIMER: 00017 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT 00018 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR 00019 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET 00020 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 00021 // LICENSED PRODUCT, HOWEVER USED. IN NO EVENT SHALL CALTECH/JPL BE 00022 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO 00023 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC 00024 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF 00025 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN 00026 // FACT SHALL KNOW OF THE POSSIBILITY. THE USER BEARS ALL RISK 00027 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED 00028 // MATERIALS. 00029 // 00030 // ************************************************************************ 00031 // matmath.h 00032 // math routines and the numeric vector and table classes 00033 // 00034 // Defines the following macros: 00035 // DEFAULT_VECTOR_SIZE 0 00036 // DEFAULT_TABLE_SIZE 0 00037 // 00038 // Defines the following typedefs: 00039 // 00040 // Matrix same as complex_table 00041 // Vector same as complex_vector 00042 // 00043 // F. Rice 11/8/97 00044 // 00045 // 10/22/99: Added additional identity_matrix() forms 00046 // 7/30/99: Added scalemult() and scalediv() 00047 // 7/6/99: changed "table" to "matrix" 00048 // 6/28/99: Added norm() and max_norm() for vectors and tables 00049 // 11/2/98: Added scalerow() 00050 // 10/7/98: Added fast square matrix routines 00051 // 7/10/98: Added a new linterp(). 00052 // 2/6/98: Added lookup(), linterp(). 00053 // 12/18/97: Fixed a bug: ambiguities with overloaded operators 00054 // 12/17/97: Added identity_matrix(); simplified several definitions. 00055 // 12/12/97: "fully" tested with calc 00056 // 11/24/97: Added mixed vector-table operations and functions, etc. 00057 // 11/18/97: added vector unary +, -; most table functions. tests o.k. 00058 // so far with tcalc, both real_ and complex_ stuff 00059 // 11/11/97: real_vector and complex_vector test o.k. with vcalc. 00060 // 11/8/97: First version. 00061 // 00062 // ************************************************************************ 00063 // 00064 // The mathmath Routines 00065 // 00066 // This header file defines many math routines for the vector and matrix 00067 // classes which make these classes truly useful for the SuperMix program. 00068 // 00069 // In addition, the default matrix and vector sizes are set to 0, and there 00070 // are typedefs which alias the complex_matrix and complex_vector types to 00071 // Matrix and Vector, respectively. Because the default index mode was 00072 // changed to Index_1 with the versions of these classes later than 00073 // 11/8/97, declaring objects like: 00074 // 00075 // Matrix A; Matrix B(n); 00076 // Vector v; Vector y(n); 00077 // 00078 // will provide objects similar to John Ward's matrix and complexArray 00079 // types, i.e. with initial size 0 or n and indexing starting at 1. 00080 // 00081 // ************************************************************************ 00082 // 00083 // Routine Quick Reference 00084 // 00085 // Vector operations: 00086 // ----------------- 00087 // (x, y: real_vectors; u, v: complex_vectors; s: double; z: complex) 00088 // (a, b: either real_vectors or complex_vectors) 00089 // (the return type is denoted like: <type> at the end of each line) 00090 // 00091 // The following return Rvalue vector objects: 00092 // 00093 // conj(u); <complex_vector> 00094 // conj(x); <real_vector> 00095 // real(u); imaginary(u); <real_vector> 00096 // 00097 // -x; +x; -u; +u; 00098 // 00099 // x + y; x - y; <real_vector> 00100 // a + u; a - u; u + a; u - a; <complex_vector> 00101 // 00102 // x + s; x - s; x * s; x / s; s + x; s * x; <real_vector> 00103 // a + z; a - z; a * z; a / z; z + a; z * a; <complex_vector> 00104 // 00105 // scalemult(x,y); scalediv(x,y); <real_vector> 00106 // scalemult(u,a); scalemult(a,u); <complex_vector> 00107 // scalediv(u,a); scalediv(a,u); <complex_vector> 00108 // 00109 // scalemult() and scalediv() return a vector whose elements are the products 00110 // or ratios, respectively, of the corresponding elements of the argument 00111 // vectors. These functions can be used to simutaneously apply custom scaling 00112 // to indiviual elements of a vector and return the result. 00113 // 00114 // 00115 // The following return Rvalue scalar objects: 00116 // 00117 // x * y; <double> 00118 // x * u; u * x; u * v; <Complex> 00119 // 00120 // dot(x,y); <double> (this is equivalent to: x * y) 00121 // dot(x,v); <Complex> (this is equivalent to: x * v) 00122 // dot(u,v); <Complex> (this is equivalent to: conj(u)*v) 00123 // dot(u,x); <Complex> (this is equivalent to: conj(u)*x) 00124 // 00125 // norm(x); norm(u); <double> returns dot(x,x) or dot(u,u) 00126 // max_norm(x); max_norm(u); <double> examines the magnitude 00127 // squared of each element and returns the largest found 00128 // 00129 // 00130 // Matrix operations: 00131 // ---------------- 00132 // (X, Y: real_matrices; U, V: complex_matrices; s: double; z: complex) 00133 // (the return type is denoted like: <type> at the end of each line) 00134 // 00135 // The following return Rvalue matrix objects: 00136 // 00137 // identity_matrix(n); identity_matrix(n,mode); <real_matrix> 00138 // (square identity matrix) 00139 // (n is an int size, mode is a v_index_mode value; default is Index_1) 00140 // identity_matrix(X); identity_matrix(U); <real_matrix> 00141 // (return identity matrix with same size and mode as argument) 00142 // 00143 // conj(U); transpose(U); dagger(U); <complex_matrix> 00144 // conj(X); transpose(X); dagger(X); <real_matrix> 00145 // real(U); imaginary(U); <real_matrix> 00146 // 00147 // -X; +X; -U; +U; 00148 // 00149 // X + Y; X - Y; X * Y; <real_matrix> 00150 // X + U; X - U; U + X; U - X; U + V; U - V; <complex_matrix> 00151 // X * U; U * X; U * V; <complex_matrix> 00152 // 00153 // X + s; X - s; X * s; X / s; s + X; s * X; <real_matrix> 00154 // X + z; X - z; X * z; X / z; z + X; z * X; <complex_matrix> 00155 // U + z; U - z; U * z; U / z; z + U; z * U; <complex_matrix> 00156 // 00157 // solve(X,Y); inverse(X); <real_matrix> 00158 // solve(U,V); inverse(U); <complex_matrix> 00159 // ( solve(A,B) returns the solution X to: A*X == B ) 00160 // ( the returned matrix will have 0 size if a solution is impossible ) 00161 // ( inverse() uses solve() to invert the argument matrix ) 00162 // 00163 // The following return a scalar (double) Rvalue: 00164 // 00165 // norm(X); norm(U); <double> 00166 // returns the sum of the magnitude squared's of all elements in the valid 00167 // index range of the matrix argument. 00168 // 00169 // max_norm(X); max_norm(U); <double> 00170 // calculates the magnitude squared for each element in the matrix and 00171 // returns the largest one. 00172 // 00173 // The following returns a scalar index: 00174 // 00175 // lookup(s,X,n); lookup(s,U,n); <int> 00176 // returns the index for the largest element in row n of X or U whose 00177 // real part is less than or equal to s. Returns Rminindex() if all 00178 // elements have real parts larger than s or if the matrix is empty. 00179 // Row n must be sorted from smallest to largest real part, or returns 00180 // garbage. Ignores the imaginary part of row n if using a 00181 // complex_matrix. s is double. If row n doesn't exist for the matrix, 00182 // lookup treats it as a row full of zeroes. 00183 // 00184 // The following returns a single interpolated value (scalar): 00185 // 00186 // linterp(s,X,nx,ny) <double>; linterp(s,U,nx,ny) <complex>; 00187 // returns y(s), where y is calculated by linear interpolation into matrix 00188 // X or U, where sorted s values are in row nx, with their corresponding 00189 // y values in row ny. Performs linear extrapolation if s is beyond the 00190 // value limits in row nx. Uses lookup(). Only considers the real part of 00191 // row nx when doing the lookup. s is double. Returns garbage if the 00192 // matrix is empty, not sorted, or doesn't contain row nx or ny. 00193 // 00194 // The following returns a vector of interpolated values: 00195 // 00196 // linterp(s,X,n) <real_vector>; linterp(s,U,n) <complex_vector>; 00197 // returns y(s), where y is a vector calculated by linear interpolation 00198 // in matrix X or U, where sorted s values are in row n, with their 00199 // corresponding y values in the other rows. Performs linear extrapolation 00200 // if s is beyond the matrix limits. Uses lookup(). Only considers the 00201 // real part of row n when doing the lookup. s is double. The returned 00202 // vector will have size and index mode determined by the left index of the 00203 // matrix; it will contain s in element n, and interpolated values in all 00204 // other elements from the corresponding rows of the matrix. Returns 00205 // garbage if the matrix is empty, not sorted, or doesn't contain row n. 00206 // 00207 // The following changes the matrix argument: 00208 // 00209 // scalerow(n,X,y) <real_matrix>; scalerow(n,U,v) <complex_matrix>; 00210 // multiply each element of row n of the matrix (X or U) by the scalar 00211 // value (y or v). The source matrix is actually modified; returns a 00212 // reference to the matrix. 00213 // 00214 // 00215 // Mixed Vector and Matrix operations: 00216 // --------------------------------- 00217 // (x, y: real_vectors; u, v: complex_vectors; X, Y: real_matrices; 00218 // U, V: complex_matrices; s: double; z: complex; n: int) 00219 // (the return type is denoted like: <type> at the end of each line) 00220 // 00221 // row(n,X); col(n,X); <real_vector> 00222 // row(n,U); col(n,U); <real_vector> 00223 // (note: for the above, the index mode of the resulting vector will be 00224 // the same as that of the matrix argument in the direction selected, ie: 00225 // row: Rmode, col: Lmode) 00226 // 00227 // rowmatrix(x); columnmatrix(x); <real_matrix> 00228 // rowmatrix(u); columnmatrix(u); <complex_matrix> 00229 // (note: for the above, the index mode of the resulting matrix will be 00230 // the same as that of the vector argument in its direction, and Index_1 00231 // in the other direction, with size 1 in that direction.) 00232 // 00233 // X * y; <real_vector> ( equivalent to: col(1, X * columnmatrix(y)) ) 00234 // y * X; <real_vector> ( equivalent to: row(1, rowmatrix(y) * X) ) 00235 // 00236 // U * y; X * v; U * v; y * U; v * X; v * U; <complex_vector> 00237 // 00238 // solve(X,y); <real_vector> ( equiv: col(1, solve(X, columnmatrix(y))) ) 00239 // solve(U,v); <complex_matrix> 00240 // 00241 // 00242 // Special Fast Square Matrix Operations: 00243 // ------------------------------------- 00244 // These routines assume that all argument matrices are square and are 00245 // already allocated to have the same index ranges and index modes. 00246 // If these requirements are not met, the results are undefined (and 00247 // probably catastrophic). 00248 // 00249 // IplusM(U, s, V); U = s*I + V after the call. I is the identity. 00250 // IminusM(U, s, V); U = s*I - V after the call. I is the identity. 00251 // 00252 // MMdagger(U, V); U = V * dagger(V) after the call. 00253 // MAMdagger(U, V, W); U = V * W * dagger(V) 00254 // 00255 // ************************************************************************ 00256 00257 #ifndef MATMATH_H 00258 #define MATMATH_H 00259 00260 #ifndef DEFAULT_VECTOR_SIZE 00261 #define DEFAULT_VECTOR_SIZE 0 00262 #endif /* DEFAULT_VECTOR_SIZE */ 00263 00264 #ifndef DEFAULT_MATRIX_SIZE 00265 #define DEFAULT_MATRIX_SIZE 0 00266 #endif /* DEFAULT_MATRIX_SIZE */ 00267 00268 #include "vector.h" 00269 #include "table.h" 00270 00271 00272 typedef complex_vector Vector; 00273 typedef complex_matrix Matrix; 00274 00275 // ************************************************************************ 00276 // Vector Routines: 00277 00278 // Complex conjugation: 00279 inline complex_vector conj(const complex_vector &u) 00280 { return complex_vector(u).apply(conj); } 00281 inline real_vector conj(const real_vector &x) 00282 { return x; } 00283 00284 // Real or complex part: 00285 inline real_vector real(const complex_vector &u) 00286 { return real_vector().real(u); } 00287 inline real_vector imaginary(const complex_vector &u) 00288 { return real_vector().imaginary(u); } 00289 00290 // Unary +,-: 00291 inline complex_vector operator +(const complex_vector & u) { return u; } 00292 inline real_vector operator +(const real_vector & x) { return x; } 00293 inline complex_vector operator -(const complex_vector & u) 00294 { return complex_vector(u) *= -1; } 00295 inline real_vector operator -(const real_vector & x) 00296 { return real_vector(x) *= -1; } 00297 00298 // Vector addition, subtraction: 00299 complex_vector operator +(const complex_vector &, const complex_vector &); 00300 complex_vector operator +(const real_vector &, const complex_vector &); 00301 real_vector operator +(const real_vector &, const real_vector &); 00302 inline complex_vector operator +(const complex_vector &u, const real_vector &x) 00303 { return x + u; } 00304 00305 complex_vector operator -(const complex_vector &, const complex_vector &); 00306 complex_vector operator -(const real_vector &, const complex_vector &); 00307 complex_vector operator -(const complex_vector &, const real_vector &); 00308 real_vector operator -(const real_vector &, const real_vector &); 00309 00310 // scalemult(), scalediv(): 00311 complex_vector scalemult(const complex_vector &, const complex_vector &); 00312 complex_vector scalemult(const real_vector &, const complex_vector &); 00313 real_vector scalemult(const real_vector &, const real_vector &); 00314 inline complex_vector scalemult(const complex_vector &u, const real_vector &x) 00315 { return scalemult(x,u); } 00316 00317 complex_vector scalediv(const complex_vector &, const complex_vector &); 00318 complex_vector scalediv(const real_vector &, const complex_vector &); 00319 complex_vector scalediv(const complex_vector &, const real_vector &); 00320 real_vector scalediv(const real_vector &, const real_vector &); 00321 00322 // Inner Product, Dot Product: 00323 Complex operator *(const complex_vector &, const complex_vector &); 00324 Complex operator *(const real_vector &, const complex_vector &); 00325 double operator *(const real_vector &, const real_vector &); 00326 inline Complex operator *(const complex_vector &u, const real_vector &x) 00327 { return x * u; } 00328 inline Complex dot(const complex_vector &u, const complex_vector &v) 00329 { return conj(u) * v; } 00330 inline Complex dot(const complex_vector &u, const real_vector &x) 00331 { return x * conj(u); } 00332 inline Complex dot(const real_vector &x, const complex_vector &v) 00333 { return x * v; } 00334 inline double dot(const real_vector &x, const real_vector &y) 00335 { return x * y; } 00336 00337 // Operate a Vector with a Scalar: 00338 complex_vector operator +(const complex_vector &, const Complex); 00339 complex_vector operator +(const real_vector &, const Complex); 00340 real_vector operator +(const real_vector &, const double); 00341 inline complex_vector operator +(const complex_vector & u, const double s) 00342 { return u + Complex(s); } 00343 inline complex_vector operator +(const Complex s, const complex_vector &v) 00344 { return v + s; } 00345 inline complex_vector operator +(const double s, const complex_vector &v) 00346 { return v + Complex(s); } 00347 inline complex_vector operator +(const Complex s, const real_vector &v) 00348 { return v + s; } 00349 inline real_vector operator +(const double s, const real_vector &v) 00350 { return v + s; } 00351 00352 complex_vector operator -(const complex_vector &, const Complex); 00353 complex_vector operator -(const real_vector &, const Complex); 00354 real_vector operator -(const real_vector &, const double); 00355 inline complex_vector operator -(const complex_vector & u, const double s) 00356 { return u - Complex(s); } 00357 00358 complex_vector operator *(const complex_vector &, const Complex); 00359 complex_vector operator *(const real_vector &, const Complex); 00360 real_vector operator *(const real_vector &, const double); 00361 inline complex_vector operator *(const complex_vector & u, const double s) 00362 { return u * Complex(s); } 00363 inline complex_vector operator *(const Complex s, const complex_vector &v) 00364 { return v * s; } 00365 inline complex_vector operator *(const double s, const complex_vector &v) 00366 { return v * Complex(s); } 00367 inline complex_vector operator *(const Complex s, const real_vector &v) 00368 { return v * s; } 00369 inline real_vector operator *(const double s, const real_vector &v) 00370 { return v * s; } 00371 00372 complex_vector operator /(const complex_vector &, const Complex); 00373 complex_vector operator /(const real_vector &, const Complex); 00374 real_vector operator /(const real_vector &, const double); 00375 inline complex_vector operator /(const complex_vector & u, const double s) 00376 { return u / Complex(s); } 00377 00378 // norms: 00379 inline double norm(const real_vector & x) 00380 { return x*x; } 00381 inline double norm(const complex_vector & u) 00382 { return dot(u,u).real; } 00383 double max_norm(const real_vector &); 00384 double max_norm(const complex_vector &); 00385 00386 00387 // ************************************************************************ 00388 // Matrix Routines: 00389 00390 // Identity matrix: 00391 inline real_matrix identity_matrix(const int n, const v_index_mode t = Index_1) 00392 { return real_matrix(n,t).diagonal(1.0); } 00393 inline real_matrix identity_matrix(const real_matrix & M) 00394 { return real_matrix(0).resize(M).diagonal(1.0); } 00395 inline real_matrix identity_matrix(const complex_matrix & M) 00396 { return real_matrix(0).resize(M).diagonal(1.0); } 00397 00398 // Transpose and Complex Conjugation: 00399 inline complex_matrix conj(const complex_matrix &U) 00400 { return complex_matrix(U).apply(conj); } 00401 inline real_matrix conj(const real_matrix &X) 00402 { return X; } 00403 complex_matrix transpose(const complex_matrix &U); 00404 real_matrix transpose(const real_matrix &X); 00405 inline complex_matrix dagger(const complex_matrix &U) 00406 { return transpose(conj(U)); } 00407 inline real_matrix dagger(const real_matrix &X) 00408 { return transpose(X); } 00409 00410 // Real or complex part: 00411 inline real_matrix real(const complex_matrix &U) 00412 { return real_matrix().real(U); } 00413 inline real_matrix imaginary(const complex_matrix &U) 00414 { return real_matrix().imaginary(U); } 00415 00416 // Unary +,-: 00417 inline complex_matrix operator +(const complex_matrix & U) { return U; } 00418 inline real_matrix operator +(const real_matrix & X) { return X; } 00419 inline complex_matrix operator -(const complex_matrix & U) 00420 { return complex_matrix(U) *= -1; } 00421 inline real_matrix operator -(const real_matrix & X) 00422 { return real_matrix(X) *= -1; } 00423 00424 // Matrix Addition, Subtraction, Multiplication: 00425 complex_matrix operator +(const complex_matrix &, const complex_matrix &); 00426 complex_matrix operator +(const real_matrix &, const complex_matrix &); 00427 complex_matrix operator +(const complex_matrix &, const real_matrix &); 00428 real_matrix operator +(const real_matrix &, const real_matrix &); 00429 complex_matrix operator -(const complex_matrix &, const complex_matrix &); 00430 complex_matrix operator -(const real_matrix &, const complex_matrix &); 00431 complex_matrix operator -(const complex_matrix &, const real_matrix &); 00432 real_matrix operator -(const real_matrix &, const real_matrix &); 00433 complex_matrix operator *(const complex_matrix &, const complex_matrix &); 00434 complex_matrix operator *(const real_matrix &, const complex_matrix &); 00435 complex_matrix operator *(const complex_matrix &, const real_matrix &); 00436 real_matrix operator *(const real_matrix &, const real_matrix &); 00437 00438 // Operate a Matrix with a Scalar: 00439 complex_matrix operator +(const complex_matrix &, const Complex); 00440 complex_matrix operator +(const real_matrix &, const Complex); 00441 real_matrix operator +(const real_matrix &, const double); 00442 inline complex_matrix operator +(const complex_matrix & A, const double s) 00443 { return A + Complex(s); } 00444 inline complex_matrix operator +(const Complex s, const complex_matrix &A) 00445 { return A + s; } 00446 inline complex_matrix operator +(const double s, const complex_matrix &A) 00447 { return A + Complex(s); } 00448 inline complex_matrix operator +(const Complex s, const real_matrix &A) 00449 { return A + s; } 00450 inline real_matrix operator +(const double s, const real_matrix &A) 00451 { return A + s; } 00452 00453 complex_matrix operator -(const complex_matrix &, const Complex); 00454 complex_matrix operator -(const real_matrix &, const Complex); 00455 real_matrix operator -(const real_matrix &, const double); 00456 inline complex_matrix operator -(const complex_matrix & A, const double s) 00457 { return A - Complex(s); } 00458 00459 complex_matrix operator *(const complex_matrix &, const Complex); 00460 complex_matrix operator *(const real_matrix &, const Complex); 00461 real_matrix operator *(const real_matrix &, const double); 00462 inline complex_matrix operator *(const complex_matrix & A, const double s) 00463 { return A * Complex(s); } 00464 inline complex_matrix operator *(const Complex s, const complex_matrix &A) 00465 { return A * s; } 00466 inline complex_matrix operator *(const double s, const complex_matrix &A) 00467 { return A * Complex(s); } 00468 inline complex_matrix operator *(const Complex s, const real_matrix &A) 00469 { return A * s; } 00470 inline real_matrix operator *(const double s, const real_matrix &A) 00471 { return A * s; } 00472 00473 complex_matrix operator /(const complex_matrix &, const Complex); 00474 complex_matrix operator /(const real_matrix &, const Complex); 00475 real_matrix operator /(const real_matrix &, const double); 00476 inline complex_matrix operator /(const complex_matrix & A, const double s) 00477 { return A / Complex(s); } 00478 00479 // Lookup and interpolation: 00480 int lookup(const double, const real_matrix &, const int); 00481 int lookup(const double, const complex_matrix &, const int, const int); 00482 double linterp(const double, const real_matrix &, const int, const int); 00483 complex linterp(const double, const complex_matrix &, const int, const int); 00484 real_vector linterp(const double, const real_matrix &, const int); 00485 complex_vector linterp(const double, const complex_matrix &, const int); 00486 00487 // norms: 00488 double norm(const real_matrix &); 00489 double norm(const complex_matrix &); 00490 double max_norm(const real_matrix &); 00491 double max_norm(const complex_matrix &); 00492 00493 // scalerow: 00494 real_matrix & scalerow(const int, real_matrix &, const double); 00495 complex_matrix & scalerow(const int, complex_matrix &, const Complex); 00496 00497 // ************************************************************************ 00498 // Matrix Solvers: 00499 00500 // Solves AX == B and returns X. If it's unable to solve the system, 00501 // then X will be empty. 00502 00503 real_matrix solve(const real_matrix & A, const real_matrix & B); 00504 complex_matrix solve(const complex_matrix & A, const complex_matrix & B); 00505 00506 00507 // Uses solve() to find the inverse of a matrix. If the inverse doesn't 00508 // exist, then the returned matrix will be empty. Note: the index modes and 00509 // valid index ranges of A must be the same in both dimensions for an 00510 // inverse to exist (A is square). 00511 00512 real_matrix inverse(const real_matrix & A); 00513 complex_matrix inverse(const complex_matrix & A); 00514 00515 00516 // Solvers with a vector RHS: 00517 00518 real_vector solve(const real_matrix & A, const real_vector & b); 00519 complex_vector solve(const complex_matrix & A, const complex_vector & b); 00520 00521 // ************************************************************************ 00522 // Mixed Vector and Matrix Routines: 00523 00524 00525 real_vector row(const int n, const real_matrix & X); 00526 real_vector col(const int n, const real_matrix & X); 00527 complex_vector row(const int n, const complex_matrix & U); 00528 complex_vector col(const int n, const complex_matrix & U); 00529 00530 inline real_matrix columnmatrix(const real_vector & x) 00531 { return real_matrix(x); } 00532 inline real_matrix rowmatrix(const real_vector & x) 00533 { return transpose(real_matrix(x)); } 00534 inline complex_matrix columnmatrix(const complex_vector & x) 00535 { return complex_matrix(x); } 00536 inline complex_matrix rowmatrix(const complex_vector & x) 00537 { return transpose(complex_matrix(x)); } 00538 00539 real_vector operator *(const real_matrix &, const real_vector &); 00540 inline real_vector operator *(const real_vector & x, const real_matrix & Y) 00541 { return transpose(Y) * x; } 00542 00543 complex_vector operator *(const complex_matrix &, const complex_vector &); 00544 complex_vector operator *(const complex_matrix &, const real_vector &); 00545 complex_vector operator *(const real_matrix &, const complex_vector &); 00546 inline complex_vector operator * 00547 (const complex_vector & u, const complex_matrix & V) 00548 { return transpose(V) * u; } 00549 inline complex_vector operator * 00550 (const real_vector & x, const complex_matrix & V) 00551 { return transpose(V) * x; } 00552 inline complex_vector operator * 00553 (const complex_vector & u, const real_matrix & Y) 00554 { return transpose(Y) * u; } 00555 00556 // ************************************************************************ 00557 // Special Fast Square Matrix Operations: 00558 00559 void IplusM(Matrix & U, double s, const Matrix & V); 00560 void IminusM(Matrix & U, double s, const Matrix & V); 00561 void MMdagger(Matrix & U, const Matrix & V); 00562 void MAMdagger(Matrix & U, const Matrix & V, const Matrix & W); 00563 00564 // ************************************************************************ 00565 #endif /* MATMATH_H */
Please direct comments and corrections to
supermix@submm.caltech.edu
Go to the supermix home page
Generated by
1.2.7