00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00016
00017
00028 #ifndef __matfunc_h
00029 #define __matfunc_h
00030
00031 #include "vector.h"
00032 #include "matrix.h"
00033
00034
00035 namespace SPUC {
00040 template<class T>
00041 int length(const Vec<T> &v) { return v.length(); }
00042
00047 template<class T>
00048 int size(const Vec<T> &v) { return v.length(); }
00049
00054 template<class T>
00055 T sum(const Vec<T> &v);
00056
00061 template<class T>
00062 T sum_sqr(const Vec<T> &v);
00063
00068 template<class T>
00069 T max(const Vec<T> &v);
00070
00075 template<class T>
00076 T min(const Vec<T> &in);
00077
00082 template<class T>
00083 int max_index(const Vec<T> &in);
00084
00089 template<class T>
00090 int min_index(const Vec<T> &in);
00091
00096 template<class T>
00097 T product(const Vec<T> &v);
00098
00103 template<class T>
00104 Vec<T> cross(const Vec<T> &v1, const Vec<T> &v2);
00105
00110 double mean(const vec &v);
00111
00116 complex<double> mean(const cvec &v);
00117
00122 double mean(const svec &v);
00123
00128 double mean(const ivec &v);
00129
00134 template<class T>
00135 double geometric_mean(const Vec<T> &v);
00136
00141 template<class T>
00142 double median(const Vec<T> &v);
00143
00148 template<class T>
00149 double norm(const Vec<T> &v);
00150
00155 template<>
00156 double norm(const cvec &v);
00157
00162 template<class T>
00163 double norm(const Vec<T> &v, int p);
00164
00169 template<>
00170 double norm(const cvec &v, int p);
00171
00189 template<class T>
00190 double energy(const Vec<T> &v);
00191
00192
00193
00194
00195
00196
00201 template<class T>
00202 Vec<T> reverse(const Vec<T> &in);
00203
00208 template<class T>
00209 Vec<T> repeat(const Vec<T> &v, int norepeats);
00210
00215 template<class T, class fT>
00216 Vec<T> apply_function(fT (*f)(fT), const Vec<T> &data);
00217
00222 template<class T>
00223 void sort(Vec<T> &data);
00224
00229 template<class T>
00230 ivec sort_index(const Vec<T> &data);
00231
00236 template<class T>
00237 Vec<T> zero_pad(const Vec<T> &v, int n);
00238
00243 template<class T>
00244 Vec<T> zero_pad(const Vec<T> &v);
00245
00250 template<class T>
00251 Mat<T> zero_pad(const Mat<T> &v, int rows, int cols);
00252
00253
00254
00259 template<class T>
00260 T sum(const Mat<T> &m);
00261
00266 template<class T>
00267 T sum_sqr(const Mat<T> &m);
00268
00273 template<class T>
00274 T max(const Mat<T> &m);
00275
00280 template<class T>
00281 T min(const Mat<T> &m);
00282
00287 template<class T>
00288 void max_index(const Mat<T> &in, int &row, int &col);
00289
00294 template<class T>
00295 void min_index(const Mat<T> &in, int &row, int &col);
00296
00301 template<class T>
00302 T product(const Mat<T> &m);
00303
00308 double mean(const mat &m);
00309
00314 complex<double> mean(const cmat &m);
00315
00320 double mean(const smat &m);
00321
00326 double mean(const imat &m);
00327
00334 template<class T>
00335 Mat<T> diag(const Vec<T> &in);
00336
00343 template<class T>
00344 void diag(const Vec<T> &in, Mat<T> &m);
00345
00352 template<class T>
00353 Vec<T> diag(const Mat<T> &in);
00354
00355
00363 template<class T>
00364 Mat<T> bidiag(const Vec<T> &main, const Vec<T> &sup);
00365
00373 template<class T>
00374 void bidiag(const Vec<T> &main, const Vec<T> &sup, Mat<T> &m);
00375
00383 template<class T>
00384 void bidiag(const Mat<T> &in, Vec<T> &main, Vec<T> &sup);
00385
00393 template<class T>
00394 Mat<T> tridiag(const Vec<T> &main, const Vec<T> &sup, const Vec<T> &sub);
00395
00403 template<class T>
00404 void tridiag(const Vec<T> &main, const Vec<T> &sup, const Vec<T> &sub, Mat<T> &m);
00405
00413 template<class T>
00414 void tridiag(const Mat<T> &in, Vec<T> &main, Vec<T> &sup, Vec<T> &sub);
00415
00420 template<class T>
00421 T trace(const Mat<T> &in);
00422
00427 template<class T>
00428 void transpose(const Mat<T> &m, Mat<T> &out);
00429
00434 template<class T>
00435 Mat<T> transpose(const Mat<T> &m);
00436
00441 template<class T>
00442 Mat<T> repeat(const Mat<T> &m, int norepeats);
00443
00448 template<class T, class fT>
00449 Mat<T> apply_function(fT (*f)(fT), const Mat<T> &data);
00450
00451
00452
00457 template<class T>
00458 Vec<T> rvectorize(const Mat<T> &m);
00459
00464 template<class T>
00465 Vec<T> cvectorize(const Mat<T> &m);
00466
00473 template<class T>
00474 Mat<T> reshape(const Mat<T> &m, int rows, int cols);
00475
00482 template<class T>
00483 Mat<T> reshape(const Vec<T> &m, int rows, int cols);
00484
00489 template<class T>
00490 void upsample(const Vec<T> &v, int usf, Vec<T> &u);
00491
00496 template<class T>
00497 Vec<T> upsample(const Vec<T> &v, int usf);
00498
00504 template<class T>
00505 void upsample(const Mat<T> &v, int usf, Mat<T> &u);
00506
00511 template<class T>
00512 Mat<T> upsample(const Mat<T> &v, int upsamplefactor);
00513
00514
00519 template<class T>
00520 void lininterp(const Mat<T> &v, int usf, Mat<T> &u);
00521
00526 template<class T>
00527 Mat<T> lininterp(const Mat<T> &v, int usf);
00528
00533 template<class T>
00534 void lininterp(const Vec<T> &v, int usf, Vec<T> &u);
00535
00540 template<class T>
00541 Vec<T> lininterp(const Vec<T> &v, int usf);
00542 }
00543
00544 #endif // __matfunc_h