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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #pragma once
00058 #ifndef MATHCORE_CORE_H
00059 #define MATHCORE_CORE_H
00060
00061
00062 #include "./cimpl.h"
00063 using namespace CIMPL;
00064
00065
00066 #include <vector>
00067 #include <cmath>
00068
00069
00070
00071 namespace MathCore
00072 {
00073
00074
00075
00076
00077
00078
00079
00080
00081 template <class T>
00082 Vector<int> Find(Vector<T>& m);
00083 template <class T>
00084 Vector<int> Find(Matrix<T>& m);
00085 template <class T>
00086 void Find(Matrix<T>& m, Vector<int>& I, Vector<int>& J);
00087
00088 void Ind2Sub(int rows, int cols, Vector<int>& ind, Vector<int>& I, Vector<int>& J);
00089
00090 Vector<int> Sub2Ind(int rows, int cols, Vector<int>& I, Vector<int>& J);
00091
00092 template <class T>
00093 Vector<T> Cross(Vector<T>& x, Vector<T>& y);
00094 template <class T>
00095 Matrix<T> Cross(Matrix<T>& x, Matrix<T>& y);
00096 template <class T>
00097 Matrix<T> Cross(Matrix<T>& x, Matrix<T>& y, int dimension);
00098
00099 template <class T>
00100 Vector<T> CumSum(Vector<T>& m);
00101 template <class T>
00102 Matrix<T> CumSum(Matrix<T>& m);
00103 template <class T>
00104 Matrix<T> CumSum(Matrix<T>& m, int dimension);
00105 template <class T>
00106 Vector<T>& CumSumI(Vector<T>& m);
00107 template <class T>
00108 Matrix<T>& CumSumI(Matrix<T>& m);
00109 template <class T>
00110 Matrix<T>& CumSumI(Matrix<T>& m, int dimension);
00111
00112 template <class T>
00113 Vector<T> CumProd(Vector<T>& m);
00114 template <class T>
00115 Matrix<T> CumProd(Matrix<T>& m);
00116 template <class T>
00117 Matrix<T> CumProd(Matrix<T>& m, int dimension);
00118 template <class T>
00119 Vector<T>& CumProdI(Vector<T>& m);
00120 template <class T>
00121 Matrix<T>& CumProdI(Matrix<T>& m);
00122 template <class T>
00123 Matrix<T>& CumProdI(Matrix<T>& m, int dimension);
00124
00125 template <class T>
00126 Matrix<T> Diag(Vector<T>& m);
00127 template <class T>
00128 Matrix<T> Diag(Vector<T>& m, int k);
00129 template <class T>
00130 Vector<T> Diag(Matrix<T>& m);
00131 template <class T>
00132 Vector<T> Diag(Matrix<T>& m, int k);
00133
00134 template <class T>
00135 Matrix<T> FlipLR(Matrix<T>& m);
00136 template <class T>
00137 Matrix<T>& FlipLRI(Matrix<T>& m);
00138
00139 template <class T>
00140 Matrix<T> FlipUD(Matrix<T>& m);
00141 template <class T>
00142 Matrix<T>& FlipUDI(Matrix<T>& m);
00143
00144 template <class T>
00145 Vector<T> Reverse(Vector<T>& m);
00146 template <class T>
00147 Vector<T>& ReverseI(Vector<T>& m);
00148
00149 template <class T>
00150 Matrix<T> Rot90(Matrix<T>& m);
00151
00152 template <class T>
00153 Matrix<T> Rot90(Matrix<T>& m, int k);
00154
00155
00156
00157 template <class T>
00158 Vector<T> Maximum(Matrix<T>& m);
00159 template <class T>
00160 T Maximum(Vector<T>& m);
00161
00162 template <class T>
00163 Vector<T> Minimum(Matrix<T>& m);
00164 template <class T>
00165 T Minimum(Vector<T>& m);
00166
00167 template <class T>
00168 Vector<double> Mean(Matrix<T>& m);
00169 template <class T>
00170 double Mean(Vector<T>& m);
00171
00172 template <class T>
00173 inline void Swap(T& a, T& b)
00174 {
00175 T temp = a;
00176 a = b;
00177 b = temp;
00178 }
00179
00180 template <class T>
00181 Vector<T> Median(Matrix<T>& m);
00182 template <class T>
00183 T Median(Vector<T>& m);
00184
00185 template <class T>
00186 Vector<double> Std(Matrix<T>& m);
00187 template <class T>
00188 double Std(Vector<T>& m);
00189
00190 template <class T>
00191 Vector<double> Var(Matrix<T>& m);
00192 template <class T>
00193 double Var(Vector<T>& m);
00194
00195
00196 template <class T>
00197 Vector<T> Sum(Matrix<T>& m);
00198 template <class T>
00199 Vector<T> Sum(Matrix<T>& m, int dimension);
00200 template <class T>
00201 T Sum(Vector<T>& m);
00202
00203
00204 template <class T>
00205 Vector<T> Prod(Matrix<T>& m);
00206 template <class T>
00207 Vector<T> Prod(Matrix<T>& m, int dimension);
00208 template <class T>
00209 T Prod(Vector<T>& m);
00210
00211 template <class T>
00212 Vector<T> Diff(Vector<T>& m);
00213 template <class T>
00214 Matrix<T> Diff(Matrix<T>& m);
00215
00216 template <class T>
00217 Matrix<T> RepMat(Matrix<T>& m, int M, int N);
00218
00219 template <class T>
00220 Matrix<T> Reshape(Matrix<T>& m, int M, int N);
00221 template <class T>
00222 Matrix<T> Reshape(Vector<T>& m, int M, int N);
00223
00224 template <class T>
00225 Vector<T>& QuickSort(Vector<T>& m);
00226
00227 template <class T>
00228 Vector<T> Sort(Vector<T>& m);
00229 template <class T>
00230 Matrix<T> Sort(Matrix<T>& m, int dimension);
00231 template <class T>
00232 Matrix<T> Sort(Matrix<T>& m);
00233 template <class T>
00234 Vector<T>& SortI(Vector<T>& m);
00235 template <class T>
00236 Matrix<T>& SortI(Matrix<T>& m, int dimension);
00237 template <class T>
00238 Matrix<T>& SortI(Matrix<T>& m);
00239
00240
00241
00242
00243 Vector<double> LinSpace(double x, double y, int N);
00244 Vector<double> LinSpace(double x, double y);
00245
00246 Vector<double> LogSpace(double x, double y, int N);
00247 Vector<double> LogSpace(double x, double y);
00248
00249 template <class T>
00250 void MeshGrid(Vector<T>& x, Vector<T>& y, Matrix<T>& X, Matrix<T>& Y);
00251
00252
00253
00254
00255
00256
00257 Matrix<ComplexFloat>& Rand(Matrix<ComplexFloat>& m, float max);
00258 Vector<ComplexFloat>& Rand(Vector<ComplexFloat>& m, float max);
00259
00260 Matrix<ComplexDouble>& Rand(Matrix<ComplexDouble>& m, double max);
00261 Vector<ComplexDouble>& Rand(Vector<ComplexDouble>& m, double max);
00262
00263
00264 Matrix<float>& RandN(Matrix<float>& m);
00265 Vector<float>& RandN(Vector<float>& m);
00266 Matrix<double>& RandN(Matrix<double>& m);
00267 Vector<double>& RandN(Vector<double>& m);
00268
00269 int NextPow2(int n);
00270
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 template <class T>
00285 Vector<int> Floor(Vector<T>& m);
00286 template <class T>
00287 Matrix<int> Floor(Matrix<T>& m);
00288
00289 template <class T>
00290 Vector<int> Ceil(Vector<T>& m);
00291 template <class T>
00292 Matrix<int> Ceil(Matrix<T>& m);
00293
00294 template <class T>
00295 Vector<int> Fix(Vector<T>& m);
00296 template <class T>
00297 Matrix<int> Fix(Matrix<T>& m);
00298
00299 template <class T>
00300 Vector<int> Round(Vector<T>& m);
00301 template <class T>
00302 Matrix<int> Round(Matrix<T>& m);
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 template <class T>
00317 Vector<int> Sign(Vector<T>& m);
00318 template <class T>
00319 Matrix<int> Sign(Matrix<T>& m);
00320
00321 template <class T>
00322 Vector<double> Gradient(Vector<T>& m);
00323 template <class T>
00324 void Gradient(Matrix<T>& m, Matrix<double>& X, Matrix<double>& Y);
00325
00326 template <class T>
00327 Vector<double> Del2(Vector<T>& m);
00328 template <class T>
00329 Matrix<double> Del2(Matrix<T>& m);
00330
00331
00332 template <class T>
00333 Vector<T> CircShift(Vector<T>& m, int shift);
00334 template <class T>
00335 Matrix<T> CircShift(Matrix<T>& m, int rshift, int cshift);
00336
00337 template <class T>
00338 Vector<T> FFTShift(Vector<T>& m);
00339 template <class T>
00340 Matrix<T> FFTShift(Matrix<T>& m);
00341
00342
00343 template <class T>
00344 Vector<T> IFFTShift(Vector<T>& m);
00345 template <class T>
00346 Matrix<T> IFFTShift(Matrix<T>& m);
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357 };
00358
00359
00360
00361
00362 #include "Core.inl"
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 #endif
00374
00375
00376