33 #ifdef __NOW_DEBUGGIBNG_OPERATOR
34 template<
class T>
friend GWO operator+(
GWO&
const lhs, T&
const rhs){ printf(
"ope1 + \n");
GWO nrv = lhs; nrv += rhs;
return nrv; };
35 template<
class T>
friend GWO&& operator+(
GWO&& lhs, T&
const rhs){ printf(
"ope2 + \n"); lhs += rhs;
return std::move(lhs); };
36 template<
class T>
friend GWO&& operator+(
const GWO& lhs, T&& rhs){ printf(
"ope3 + \n"); rhs += lhs;
return std::move(rhs); };
37 template<
class T>
friend GWO&& operator+(
GWO&& lhs, T&& rhs){ printf(
"ope4 + \n"); lhs += std::move(rhs);
return std::move(lhs); };
39 template<
class T>
friend GWO operator-(
GWO&
const lhs, T&
const rhs){ printf(
"ope1 - \n");
GWO nrv = lhs; nrv -= rhs;
return nrv; };
40 template<
class T>
friend GWO&& operator-(
GWO&& lhs, T&
const rhs){ printf(
"ope2 - \n"); lhs -= rhs;
return std::move(lhs); };
41 template<
class T>
friend GWO&& operator-(
const T& lhs,
GWO&& rhs){ printf(
"ope3 - \n"); rhs -= lhs;
return std::move(rhs); };
42 template<
class T>
friend GWO&& operator-(
GWO&& lhs, T&& rhs){ printf(
"ope4 - \n"); lhs -= std::move(rhs);
return std::move(lhs); };
44 template<
class T>
friend GWO operator*(
GWO&
const lhs, T&
const rhs){ printf(
"ope1 * \n");
GWO nrv = lhs; nrv *= rhs;
return nrv; };
45 template<
class T>
friend GWO&& operator*(
GWO&& lhs, T&
const rhs){ printf(
"ope2 * \n"); lhs *= rhs;
return std::move(lhs); };
46 template<
class T>
friend GWO&& operator*(
const T& lhs,
GWO&& rhs){ printf(
"ope3 * \n"); rhs *= lhs;
return std::move(rhs); };
47 template<
class T>
friend GWO&& operator*(
GWO&& lhs, T&& rhs){ printf(
"ope4 * \n"); lhs *= std::move(rhs);
return std::move(lhs); };
49 template<
class T>
friend GWO operator/(
GWO&
const lhs, T&
const rhs){ printf(
"ope1 / \n");
GWO nrv = lhs; nrv /= rhs;
return nrv; };
50 template<
class T>
friend GWO&& operator/(
GWO&& lhs, T&
const rhs){ printf(
"ope2 / \n"); lhs /= rhs;
return std::move(lhs); };
51 template<
class T>
friend GWO&& operator/(
const T& lhs,
GWO&& rhs){ printf(
"ope3 / \n"); rhs /= lhs;
return std::move(rhs); };
52 template<
class T>
friend GWO&& operator/(
GWO&& lhs, T&& rhs){ printf(
"ope4 / \n"); lhs /= std::move(rhs);
return std::move(lhs); };
63 __Free((
void**)&p_field);
65 assert(p_field !=
nullptr);
77 GWO& operator=(
float a)
92 template<
class T = GWO> T operator+(T &a) {
95 assert(tmp.GetBuffer() !=
nullptr);
97 __Add(
GetBuffer(), a.GetBuffer(), tmp.GetBuffer());
100 template<
class T = GWO> T operator+(
float a) {
103 assert(tmp.GetBuffer() !=
nullptr);
106 CWO_RE(cplx) = a; CWO_IM(cplx) = 0.0f;
107 __Add(
GetBuffer(), cplx, tmp.GetBuffer());
110 template<
class T = GWO> T operator+(
const cwoComplex &a) {
113 assert(tmp.GetBuffer() !=
nullptr);
118 template<
class T>
friend GWO operator+(
const T &a,
GWO& c) {
GWO tmp = c; tmp += a;
return tmp; };
120 template<
class T = GWO> T operator-(T &a) {
123 assert(tmp.GetBuffer() !=
nullptr);
125 __Sub(
GetBuffer(), a.GetBuffer(), tmp.GetBuffer());
128 template<
class T = GWO> T operator-(
float a) {
131 assert(tmp.GetBuffer() !=
nullptr);
134 CWO_RE(cplx) = a; CWO_IM(cplx) = 0.0f;
135 __Sub(
GetBuffer(), cplx, tmp.GetBuffer());
138 template<
class T = GWO> T operator-(
const cwoComplex &a) {
141 assert(tmp.GetBuffer() !=
nullptr);
146 template<
class T>
friend GWO operator-(
const T &a,
GWO& c) {
GWO tmp(c.
GetNx(), c.
GetNy()); tmp = a; tmp -= c;
return tmp; };
148 template<
class T = GWO> T operator*(T &a) {
151 assert(tmp.GetBuffer() !=
nullptr);
153 __Mul(
GetBuffer(), a.GetBuffer(), tmp.GetBuffer());
156 template<
class T = GWO> T operator*(
float a) {
159 assert(tmp.GetBuffer() !=
nullptr);
162 CWO_RE(cplx) = a; CWO_IM(cplx) = 0.0f;
163 __Mul(
GetBuffer(), cplx, tmp.GetBuffer());
166 template<
class T = GWO> T operator*(
const cwoComplex &a) {
169 assert(tmp.GetBuffer() !=
nullptr);
174 template<
class T>
friend GWO operator*(
const T &a,
GWO& c) {
GWO tmp = c; tmp *= a;
return tmp; };
176 template<
class T = GWO> T operator/(T &a) {
179 assert(tmp.GetBuffer() !=
nullptr);
181 __Div(
GetBuffer(), a.GetBuffer(), tmp.GetBuffer());
184 template<
class T = GWO> T operator/(
float a) {
187 assert(tmp.GetBuffer() !=
nullptr);
190 CWO_RE(cplx) = a; CWO_IM(cplx) = 0.0f;
191 __Div(
GetBuffer(), cplx, tmp.GetBuffer());
194 template<
class T = GWO> T operator/(
const cwoComplex &a) {
197 assert(tmp.GetBuffer() !=
nullptr);
202 template<
class T>
friend GWO operator/(
const T &a,
GWO& c) {
288 void SetDev(
int dev);
301 cwoStream GetStream();
302 void DestroyStream();
309 void SetStreamMode(
int mode);
313 int Load(
const std::string& fname_amp,
const std::string& fname_pha,
int c =
CWO_GREY);
314 int Save(
const std::string& fname,
int bmp_8_24 = 24);
315 int Save(
const std::string& fname,
CWO *r,
CWO *g =
nullptr,
CWO *b =
nullptr);
317 int SaveAsImage(
const std::string& fname,
float i1,
float i2,
float o1,
float o2,
int flag =
CWO_SAVE_AS_RE);
318 int SaveAsImage(
const std::string& fname,
int flag =
CWO_SAVE_AS_RE,
CWO *r =
nullptr,
CWO *g =
nullptr,
CWO *b =
nullptr);
319 int SaveAsImage(
cwoComplex *p,
int Nx,
int Ny,
const std::string& fname,
int flag =
CWO_SAVE_AS_RE,
int bmp_8_24 = 24);
323 void __Free(
void **a);
324 void __Memcpy(
void *dst,
void *src,
size_t size);
325 void __Memset(
void *p,
int c,
size_t size);
332 void *src,
int sx,
int sy,
int srcNx,
int srcNy,
333 void *dst,
int dx,
int dy,
int dstNx,
int dstNy,
346 void __FresnelConvCoeff(
cwoComplex *a,
float const_val=1.0f);
357 void __FresnelDblAperture(
cwoComplex *a,
float z1);
359 void __FresnelDblCoeff(
cwoComplex *a,
float z1,
float z2);
361 void __FFT(
void *src,
void *dst,
int type);
362 void __IFFT(
void *src,
void *dst);
363 void __FFTShift(
void *src);
380 void __AddSphericalWave(
cwoComplex *p,
float x,
float y,
float z,
float px,
float py,
float a);
381 void __MulSphericalWave(
cwoComplex *p,
float x,
float y,
float z,
float px,
float py,
float a);
391 void __Real2Complex(
float *src,
cwoComplex *dst);
392 void __Phase2Complex(
float *src,
cwoComplex *dst);
394 void __Polar(
float *amp,
float *ph,
cwoComplex *c);
403 void __FloatToChar(
char *dst,
float *src,
int N);
404 void __CharToFloat(
float *dst,
char *src,
int N);
407 cwoComplex *src,
int x1,
int y1,
int sNx,
int sNy,
408 cwoComplex *dst,
int x2,
int y2,
int dNx,
int dNy,
416 void Log(
float base = 10.0f,
float eps = 1.0f);
418 void Threshold(
float max,
float min=0.0);
419 void __PickupFloat(
float *src,
float *pix_p,
float pix);
421 void Binary(
float th = 0.0,
float max = 1.0,
float min = 0.0);
428 void SetRandSeed(
long long s);
429 void RandReal(
float max = 1.0f,
float min = 0.0f);
430 void __RandPhase(
cwoComplex *a,
float max,
float min);
431 void __MulRandPhase(
cwoComplex *a,
float max,
float min);
437 void __MaxMin(
cwoComplex *a,
float *max,
float *min,
int *max_x =
nullptr,
int *max_y =
nullptr,
int *min_x =
nullptr,
int *min_y =
nullptr);
443 int __ScaleReal(
float i1,
float i2,
float o1,
float o2);
444 int __ScaleCplx(
float i1,
float i2,
float o1,
float o2);
447 void __ResizeNearest(
453 void __ResizeLanczos(
463 void AffineAngularSpectrum(
float *mat_affine,
float px,
float py,
int flag);
467 void ErrorDiffusion(
CWO *a =
nullptr,
int flag =
CWO_ED_FS);
468 void ErrorDiffusionSegmented(
CWO *a =
nullptr,
int flag =
CWO_ED_FS);
476 virtual void __ArbitFresnelDirect(
479 float *p_d1,
float *p_d2);
481 virtual void __ArbitFresnelCoeff(