matrix.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#ifndef _Matrix_matrix_h_
00028
#define _Matrix_matrix_h_
00029
00030
#include <iostream>
00031
#include "matrix_global.h"
00032
#include "barray2d.h"
00033
#include "vector.h"
00034
00035
00036
00037
00038
00041
namespace PLib {
00042
template <
class T>
class Matrix ;
00043
00044
template <
class T>
PLib::Matrix<T> operator+(
const PLib::Matrix<T>&,
const PLib::Matrix<T>&);
00045
template <
class T>
PLib::Matrix<T> operator-(
const PLib::Matrix<T>&,
const PLib::Matrix<T>&);
00046
template <
class T>
PLib::Matrix<T> operator*(
const PLib::Matrix<T>&,
const PLib::Matrix<T>&);
00047
template <
class T>
PLib::Matrix<T> operator*(
const double,
const PLib::Matrix<T>&);
00048
template <
class T>
PLib::Matrix<T> operator*(
const Complex&,
const PLib::Matrix<T>&);
00049
template <
class T>
PLib::Vector<T> operator*(
const PLib::Matrix<T>&,
const PLib::Vector<T>&);
00050
template <
class T>
int operator==(
const PLib::Matrix<T>&,
const PLib::Matrix<T>&);
00051
template <
class T>
int operator!=(
const PLib::Matrix<T>& a,
const PLib::Matrix<T>& b) ;
00052
00053
template <>
PLib::Matrix<Complex> operator*(
const double d,
const PLib::Matrix<Complex> &a);
00054
template <>
PLib::Matrix<Complex> operator*(
const Complex &d,
const PLib::Matrix<Complex> &a);
00055
00056
00066
template<
class T>
00067 class Matrix :
public Basic2DArray<T>
00068 {
00069
public:
00070
Matrix(
const int r,
const int c) :
Basic2DArray<T>(r,c) {}
00071
Matrix() :
Basic2DArray<T>() {}
00072
Matrix(
const Matrix<T>& M) :
Basic2DArray<T>(M) {}
00073
Matrix(T* p,
const int r,
const int c) :
Basic2DArray<T>(p,r,c) {}
00074
00075
00076
Matrix<T>&
operator=(
const Matrix<T>&);
00077 T operator=(
const T v)
00078 { reset((T)0);
00079
diag(v);
00080
return v; }
00081
void submatrix(
int i,
int j,
Matrix<T>&);
00082
void as(
int rw,
int cl,
Matrix<T>&) ;
00083
Matrix<T> get(
int rw,
int cl,
int nr,
int nc)
const ;
00084
00085
00086
Matrix<T>&
operator+=(
const Matrix<T>&);
00087
Matrix<T>&
operator-=(
const Matrix<T>&);
00088
Matrix<T>& operator+=(
double d) ;
00089
Matrix<T>& operator-=(
double d) ;
00090
Matrix<T>& operator*=(
double d) ;
00091
Matrix<T>&
operator/=(
double d) ;
00092
00093
#ifdef HAVE_ISO_FRIEND_DECL
00094
friend Matrix<T> operator+ <>(
const Matrix<T>&,
00095
const Matrix<T>&);
00096
friend Matrix<T> operator- <>(
const Matrix<T>&,
00097
const Matrix<T>&);
00098
friend Matrix<T> operator* <>(
const Matrix<T>&,
00099
const Matrix<T>&);
00100
friend Matrix<T> operator* <>(
const double,
00101
const Matrix<T>&);
00102
friend Matrix<T> operator* <>(
const Complex&,
00103
const Matrix<T>&);
00104
friend Vector<T> operator* <>(
const Matrix<T>&,
00105
const Vector<T>&);
00106
friend int operator== <>(
const Matrix<T>&,
00107
const Matrix<T>&);
00108
friend int operator!= <>(
const Matrix<T>& a,
00109
const Matrix<T>& b) ;
00110
00111
#else
00112
friend Matrix<T> operator+ (
const Matrix<T>&,
00113
const Matrix<T>&);
00114
friend Matrix<T> operator- (
const Matrix<T>&,
00115
const Matrix<T>&);
00116
friend Matrix<T> operator* (
const Matrix<T>&,
00117
const Matrix<T>&);
00118
friend Matrix<T> operator* (
const double,
00119
const Matrix<T>&);
00120
friend Matrix<T> operator* (
const Complex&,
00121
const Matrix<T>&);
00122
friend Vector<T> operator* (
const Matrix<T>&,
00123
const Vector<T>&);
00124
friend int operator== (
const Matrix<T>&,
00125
const Matrix<T>&);
00126
friend int operator!= (
const Matrix<T>& a,
00127
const Matrix<T>& b) ;
00128
#endif
00129
00130
Matrix<T> herm()
const ;
00131
Matrix<T> transpose()
const ;
00132
Matrix<T> flop()
const ;
00133 T
trace()
const ;
00134
00135
double norm(
void) ;
00136
void diag(
const T fv);
00137
Vector<T> getDiag();
00138
00139
void qSort() ;
00140
00141
00142
00143
int read(
char* filename) ;
00144
int read(
char* filename,
int rows,
int cols) ;
00145
int write(
char* filename) ;
00146
int writeRaw(
char* filename) ;
00147
00148
00149
friend class LAPACK ;
00150 };
00151
00152 }
00153
00154
00155
template <
class T>
00156
PLib::Matrix<T> comm(
const PLib::Matrix<T>& a,
const PLib::Matrix<T>& b);
00157
00158
template <
class T>
00159
inline PLib::Matrix<T> herm(
const PLib::Matrix<T>& a) {
00160
return a.
herm() ;
00161 }
00162
00163
template <
class T>
00164
inline PLib::Matrix<T> transpose(
const PLib::Matrix<T>& a) {
00165
return a.
transpose() ;
00166 }
00167
00168
template <
class T>
00169
inline T trace(
const PLib::Matrix<T>& a) {
00170
return a.
trace() ;
00171 }
00172
00173
template <
class T>
00174
inline int operator!=(
const PLib::Matrix<T>& a,
const PLib::Matrix<T>& b) {
00175
return a==b?0:1 ;
00176 }
00177
00178
00179
typedef PLib::Matrix<int> Matrix_INT ;
00180
typedef PLib::Matrix<char> Matrix_BYTE ;
00181
typedef PLib::Matrix<float> Matrix_FLOAT ;
00182
typedef PLib::Matrix<double> Matrix_DOUBLE ;
00183
typedef PLib::Matrix<Complex> Matrix_COMPLEX ;
00184
typedef PLib::Matrix<unsigned char> Matrix_UBYTE ;
00185
typedef PLib::Matrix<PLib::Point3Df> Matrix_Point3Df ;
00186
typedef PLib::Matrix<PLib::HPoint3Df> Matrix_HPoint3Df ;
00187
typedef PLib::Matrix<PLib::Point3Dd> Matrix_Point3Dd ;
00188
typedef PLib::Matrix<PLib::HPoint3Dd> Matrix_HPoint3Dd ;
00189
typedef PLib::Matrix<PLib::Point2Df> Matrix_Point2Df ;
00190
typedef PLib::Matrix<PLib::HPoint2Df> Matrix_HPoint2Df ;
00191
typedef PLib::Matrix<PLib::Point2Dd> Matrix_Point2Dd ;
00192
typedef PLib::Matrix<PLib::HPoint2Dd> Matrix_HPoint2Dd ;
00193
00194
typedef PLib::Matrix<int> PlMatrix_int ;
00195
typedef PLib::Matrix<char> PlMatrix_byte ;
00196
typedef PLib::Matrix<float> PlMatrix_float ;
00197
typedef PLib::Matrix<double> PlMatrix_double ;
00198
typedef PLib::Matrix<Complex> PlMatrix_complex ;
00199
typedef PLib::Matrix<unsigned char> PlMatrix_ubyte ;
00200
typedef PLib::Matrix<PLib::Point3Df> PlMatrix_Point3Df ;
00201
typedef PLib::Matrix<PLib::HPoint3Df> PlMatrix_HPoint3Df ;
00202
typedef PLib::Matrix<PLib::Point3Dd> PlMatrix_Point3Dd ;
00203
typedef PLib::Matrix<PLib::HPoint3Dd> PlMatrix_HPoint3Dd ;
00204
typedef PLib::Matrix<PLib::Point3Df> PlMatrix_Point2Df ;
00205
typedef PLib::Matrix<PLib::HPoint3Df> PlMatrix_HPoint2Df ;
00206
typedef PLib::Matrix<PLib::Point3Dd> PlMatrix_Point2Dd ;
00207
typedef PLib::Matrix<PLib::HPoint3Dd> PlMatrix_HPoint2Dd ;
00208
00209
#ifdef INCLUDE_TEMPLATE_SOURCE
00210
#include "matrix.cpp"
00211
#endif
00212
00213
#endif
Generated on Wed Aug 18 07:07:37 2004 for NURBS++ by
1.3.7