Commit ef70330ef266529a0aef1935f95c20feae8958d1
1 parent
edb44c25
changed rts to stim
Showing
10 changed files
with
89 additions
and
89 deletions
Show diff stats
envi/envi.h
math/complex.h
... | ... | @@ -334,37 +334,37 @@ struct complex |
334 | 334 | |
335 | 335 | //addition |
336 | 336 | template<typename T> |
337 | -CUDA_CALLABLE static rts::complex<T> operator+(const double a, const rts::complex<T> b) | |
337 | +CUDA_CALLABLE static stim::complex<T> operator+(const double a, const stim::complex<T> b) | |
338 | 338 | { |
339 | - return rts::complex<T>((T)a + b.r, b.i); | |
339 | + return stim::complex<T>((T)a + b.r, b.i); | |
340 | 340 | } |
341 | 341 | |
342 | 342 | //subtraction with a real value |
343 | 343 | template<typename T> |
344 | -CUDA_CALLABLE static rts::complex<T> operator-(const double a, const rts::complex<T> b) | |
344 | +CUDA_CALLABLE static stim::complex<T> operator-(const double a, const stim::complex<T> b) | |
345 | 345 | { |
346 | - return rts::complex<T>((T)a - b.r, -b.i); | |
346 | + return stim::complex<T>((T)a - b.r, -b.i); | |
347 | 347 | } |
348 | 348 | |
349 | 349 | //minus sign |
350 | 350 | template<typename T> |
351 | -CUDA_CALLABLE static rts::complex<T> operator-(const rts::complex<T> &rhs) | |
351 | +CUDA_CALLABLE static stim::complex<T> operator-(const stim::complex<T> &rhs) | |
352 | 352 | { |
353 | - return rts::complex<T>(-rhs.r, -rhs.i); | |
353 | + return stim::complex<T>(-rhs.r, -rhs.i); | |
354 | 354 | } |
355 | 355 | |
356 | 356 | //multiply a T value by a complex value |
357 | 357 | template<typename T> |
358 | -CUDA_CALLABLE static rts::complex<T> operator*(const double a, const rts::complex<T> b) | |
358 | +CUDA_CALLABLE static stim::complex<T> operator*(const double a, const stim::complex<T> b) | |
359 | 359 | { |
360 | - return rts::complex<T>((T)a * b.r, (T)a * b.i); | |
360 | + return stim::complex<T>((T)a * b.r, (T)a * b.i); | |
361 | 361 | } |
362 | 362 | |
363 | 363 | //divide a T value by a complex value |
364 | 364 | template<typename T> |
365 | -CUDA_CALLABLE static rts::complex<T> operator/(const double a, const rts::complex<T> b) | |
365 | +CUDA_CALLABLE static stim::complex<T> operator/(const double a, const stim::complex<T> b) | |
366 | 366 | { |
367 | - rts::complex<T> result; | |
367 | + stim::complex<T> result; | |
368 | 368 | |
369 | 369 | T denom = b.r * b.r + b.i * b.i; |
370 | 370 | |
... | ... | @@ -376,46 +376,46 @@ CUDA_CALLABLE static rts::complex<T> operator/(const double a, const rts::comple |
376 | 376 | |
377 | 377 | |
378 | 378 | template<typename T> |
379 | -CUDA_CALLABLE static rts::complex<T> pow(rts::complex<T> x, T y) | |
379 | +CUDA_CALLABLE static stim::complex<T> pow(stim::complex<T> x, T y) | |
380 | 380 | { |
381 | 381 | return x.pow(y); |
382 | 382 | } |
383 | 383 | template<typename T> |
384 | -CUDA_CALLABLE static rts::complex<T> pow(rts::complex<T> x, int y) | |
384 | +CUDA_CALLABLE static stim::complex<T> pow(stim::complex<T> x, int y) | |
385 | 385 | { |
386 | 386 | return x.pow(y); |
387 | 387 | } |
388 | 388 | |
389 | 389 | //log function |
390 | 390 | template<typename T> |
391 | -CUDA_CALLABLE static rts::complex<T> log(rts::complex<T> x) | |
391 | +CUDA_CALLABLE static stim::complex<T> log(stim::complex<T> x) | |
392 | 392 | { |
393 | 393 | return x.log(); |
394 | 394 | } |
395 | 395 | |
396 | 396 | //exp function |
397 | 397 | template<typename T> |
398 | -CUDA_CALLABLE static rts::complex<T> exp(rts::complex<T> x) | |
398 | +CUDA_CALLABLE static stim::complex<T> exp(stim::complex<T> x) | |
399 | 399 | { |
400 | 400 | return x.exp(); |
401 | 401 | } |
402 | 402 | |
403 | 403 | //sqrt function |
404 | 404 | template<typename T> |
405 | -CUDA_CALLABLE static rts::complex<T> sqrt(rts::complex<T> x) | |
405 | +CUDA_CALLABLE static stim::complex<T> sqrt(stim::complex<T> x) | |
406 | 406 | { |
407 | 407 | return x.sqrt(); |
408 | 408 | } |
409 | 409 | |
410 | 410 | |
411 | 411 | template <typename T> |
412 | -CUDA_CALLABLE static T abs(rts::complex<T> a) | |
412 | +CUDA_CALLABLE static T abs(stim::complex<T> a) | |
413 | 413 | { |
414 | 414 | return a.abs(); |
415 | 415 | } |
416 | 416 | |
417 | 417 | template <typename T> |
418 | -CUDA_CALLABLE static T real(rts::complex<T> a) | |
418 | +CUDA_CALLABLE static T real(stim::complex<T> a) | |
419 | 419 | { |
420 | 420 | return a.r; |
421 | 421 | } |
... | ... | @@ -427,16 +427,16 @@ CUDA_CALLABLE static float real(float a) |
427 | 427 | } |
428 | 428 | |
429 | 429 | template <typename T> |
430 | -CUDA_CALLABLE static T imag(rts::complex<T> a) | |
430 | +CUDA_CALLABLE static T imag(stim::complex<T> a) | |
431 | 431 | { |
432 | 432 | return a.i; |
433 | 433 | } |
434 | 434 | |
435 | 435 | //trigonometric functions |
436 | 436 | //template<class A> |
437 | -/*CUDA_CALLABLE static rts::complex<float> sinf(const rts::complex<float> x) | |
437 | +/*CUDA_CALLABLE static stim::complex<float> sinf(const stim::complex<float> x) | |
438 | 438 | { |
439 | - rts::complex<float> result; | |
439 | + stim::complex<float> result; | |
440 | 440 | result.r = sinf(x.r) * coshf(x.i); |
441 | 441 | result.i = cosf(x.r) * sinhf(x.i); |
442 | 442 | |
... | ... | @@ -444,9 +444,9 @@ CUDA_CALLABLE static T imag(rts::complex<T> a) |
444 | 444 | }*/ |
445 | 445 | |
446 | 446 | template<class A> |
447 | -CUDA_CALLABLE rts::complex<A> sin(const rts::complex<A> x) | |
447 | +CUDA_CALLABLE stim::complex<A> sin(const stim::complex<A> x) | |
448 | 448 | { |
449 | - rts::complex<A> result; | |
449 | + stim::complex<A> result; | |
450 | 450 | result.r = (A)std::sin(x.r) * (A)std::cosh(x.i); |
451 | 451 | result.i = (A)std::cos(x.r) * (A)std::sinh(x.i); |
452 | 452 | |
... | ... | @@ -455,9 +455,9 @@ CUDA_CALLABLE rts::complex<A> sin(const rts::complex<A> x) |
455 | 455 | |
456 | 456 | //floating point template |
457 | 457 | //template<class A> |
458 | -/*CUDA_CALLABLE static rts::complex<float> cosf(const rts::complex<float> x) | |
458 | +/*CUDA_CALLABLE static stim::complex<float> cosf(const stim::complex<float> x) | |
459 | 459 | { |
460 | - rts::complex<float> result; | |
460 | + stim::complex<float> result; | |
461 | 461 | result.r = cosf(x.r) * coshf(x.i); |
462 | 462 | result.i = -(sinf(x.r) * sinhf(x.i)); |
463 | 463 | |
... | ... | @@ -465,9 +465,9 @@ CUDA_CALLABLE rts::complex<A> sin(const rts::complex<A> x) |
465 | 465 | }*/ |
466 | 466 | |
467 | 467 | template<class A> |
468 | -CUDA_CALLABLE rts::complex<A> cos(const rts::complex<A> x) | |
468 | +CUDA_CALLABLE stim::complex<A> cos(const stim::complex<A> x) | |
469 | 469 | { |
470 | - rts::complex<A> result; | |
470 | + stim::complex<A> result; | |
471 | 471 | result.r = (A)std::cos(x.r) * (A)std::cosh(x.i); |
472 | 472 | result.i = -((A)std::sin(x.r) * (A)std::sinh(x.i)); |
473 | 473 | |
... | ... | @@ -476,14 +476,14 @@ CUDA_CALLABLE rts::complex<A> cos(const rts::complex<A> x) |
476 | 476 | |
477 | 477 | |
478 | 478 | template<class A> |
479 | -std::ostream& operator<<(std::ostream& os, rts::complex<A> x) | |
479 | +std::ostream& operator<<(std::ostream& os, stim::complex<A> x) | |
480 | 480 | { |
481 | 481 | os<<x.str(); |
482 | 482 | return os; |
483 | 483 | } |
484 | 484 | |
485 | 485 | template<class A> |
486 | -std::istream& operator>>(std::istream& is, rts::complex<A>& x) | |
486 | +std::istream& operator>>(std::istream& is, stim::complex<A>& x) | |
487 | 487 | { |
488 | 488 | A r, i; |
489 | 489 | r = i = 0; //initialize the real and imaginary parts to zero |
... | ... | @@ -497,7 +497,7 @@ std::istream& operator>>(std::istream& is, rts::complex<A>& x) |
497 | 497 | } |
498 | 498 | |
499 | 499 | //#if __GNUC__ > 3 && __GNUC_MINOR__ > 7 |
500 | -//template<class T> using rtsComplex = rts::complex<T>; | |
500 | +//template<class T> using rtsComplex = stim::complex<T>; | |
501 | 501 | //#endif |
502 | 502 | |
503 | 503 | ... | ... |
math/complexfield.cuh
... | ... | @@ -29,18 +29,18 @@ __global__ void gpu_complexfield_mag(T* dest, complex<T>* source, unsigned int r |
29 | 29 | /*This class stores functions for saving images of complex fields |
30 | 30 | */ |
31 | 31 | template<typename T, unsigned int D = 1> |
32 | -class complexfield : public field< rts::complex<T>, D >{ | |
33 | - using field< rts::complex<T>, D >::R; | |
34 | - using field< rts::complex<T>, D >::X; | |
35 | - using field< rts::complex<T>, D >::shape; | |
36 | - using field< rts::complex<T>, D >::cuda_params; | |
32 | +class complexfield : public field< stim::complex<T>, D >{ | |
33 | + using field< stim::complex<T>, D >::R; | |
34 | + using field< stim::complex<T>, D >::X; | |
35 | + using field< stim::complex<T>, D >::shape; | |
36 | + using field< stim::complex<T>, D >::cuda_params; | |
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | 40 | public: |
41 | 41 | |
42 | 42 | //find the maximum value of component n |
43 | - rts::complex<T> find_max(unsigned int n){ | |
43 | + stim::complex<T> find_max(unsigned int n){ | |
44 | 44 | cublasStatus_t stat; |
45 | 45 | cublasHandle_t handle; |
46 | 46 | |
... | ... | @@ -53,7 +53,7 @@ public: |
53 | 53 | |
54 | 54 | int L = R[0] * R[1]; //compute the number of discrete points in a slice |
55 | 55 | int index; //result of the max operation |
56 | - rts::complex<T> result; | |
56 | + stim::complex<T> result; | |
57 | 57 | |
58 | 58 | if(sizeof(T) == 8) |
59 | 59 | stat = cublasIcamax(handle, L, (const cuComplex*)X[n], 1, &index); |
... | ... | @@ -70,7 +70,7 @@ public: |
70 | 70 | |
71 | 71 | //retrieve the maximum value for this slice and store it in the maxVal array |
72 | 72 | std::cout<<X[n]<<std::endl; |
73 | - HANDLE_ERROR(cudaMemcpy(&result, X[n] + index, sizeof(rts::complex<T>), cudaMemcpyDeviceToHost)); | |
73 | + HANDLE_ERROR(cudaMemcpy(&result, X[n] + index, sizeof(stim::complex<T>), cudaMemcpyDeviceToHost)); | |
74 | 74 | return result; |
75 | 75 | } |
76 | 76 | |
... | ... | @@ -79,13 +79,13 @@ public: |
79 | 79 | enum attribute {magnitude, real, imaginary}; |
80 | 80 | |
81 | 81 | //constructor (no parameters) |
82 | - complexfield() : field<rts::complex<T>, D>(){}; | |
82 | + complexfield() : field<stim::complex<T>, D>(){}; | |
83 | 83 | |
84 | 84 | //constructor (resolution specified) |
85 | - complexfield(unsigned int r0, unsigned int r1) : field<rts::complex<T>, D>(r0, r1){}; | |
85 | + complexfield(unsigned int r0, unsigned int r1) : field<stim::complex<T>, D>(r0, r1){}; | |
86 | 86 | |
87 | 87 | //assignment from a field of complex values |
88 | - complexfield & operator=(const field< rts::complex<T>, D > rhs){ | |
88 | + complexfield & operator=(const field< stim::complex<T>, D > rhs){ | |
89 | 89 | field< complex<T>, D >::operator=(rhs); |
90 | 90 | return *this; |
91 | 91 | } | ... | ... |
math/field.cuh
... | ... | @@ -78,11 +78,11 @@ protected: |
78 | 78 | |
79 | 79 | T* X[D]; //pointer to the field data |
80 | 80 | unsigned int R[2]; //field resolution |
81 | - rts::rect<T> shape; //position and shape of the field slice | |
81 | + stim::rect<T> shape; //position and shape of the field slice | |
82 | 82 | |
83 | 83 | //calculates the optimal block and grid sizes using information from the GPU |
84 | 84 | void cuda_params(dim3& grids, dim3& blocks){ |
85 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
85 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
86 | 86 | int SQRT_BLOCK = (int)std::sqrt((float)maxThreads); |
87 | 87 | |
88 | 88 | //create one thread for each detector pixel |
... | ... | @@ -233,7 +233,7 @@ public: |
233 | 233 | |
234 | 234 | field & operator= (const T rhs){ |
235 | 235 | |
236 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
236 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
237 | 237 | int SQRT_BLOCK = (int)std::sqrt((float)maxThreads); |
238 | 238 | |
239 | 239 | //create one thread for each detector pixel |
... | ... | @@ -242,7 +242,7 @@ public: |
242 | 242 | |
243 | 243 | //assign the constant value to all positions and dimensions |
244 | 244 | for(int n=0; n<D; n++) |
245 | - rts::gpu_field_assign <<<dimGrid, dimBlock>>> (X[n], rhs, R[0], R[1]); | |
245 | + stim::gpu_field_assign <<<dimGrid, dimBlock>>> (X[n], rhs, R[0], R[1]); | |
246 | 246 | |
247 | 247 | return *this; |
248 | 248 | } |
... | ... | @@ -250,7 +250,7 @@ public: |
250 | 250 | //assignment of vector component |
251 | 251 | field & operator= (const vec<T, D> rhs){ |
252 | 252 | |
253 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
253 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
254 | 254 | int SQRT_BLOCK = (int)std::sqrt((float)maxThreads); |
255 | 255 | |
256 | 256 | //create one thread for each detector pixel |
... | ... | @@ -259,7 +259,7 @@ public: |
259 | 259 | |
260 | 260 | //assign the constant value to all positions and dimensions |
261 | 261 | for(unsigned int n=0; n<D; n++) |
262 | - rts::gpu_field_assign <<<dimGrid, dimBlock>>> (X[n], rhs.v[n], R[0], R[1]); | |
262 | + stim::gpu_field_assign <<<dimGrid, dimBlock>>> (X[n], rhs.v[n], R[0], R[1]); | |
263 | 263 | |
264 | 264 | return *this; |
265 | 265 | |
... | ... | @@ -268,7 +268,7 @@ public: |
268 | 268 | //multiply two fields (element-wise multiplication) |
269 | 269 | field<T, D> operator* (const field & rhs){ |
270 | 270 | |
271 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
271 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
272 | 272 | int SQRT_BLOCK = (int)std::sqrt((float)maxThreads); |
273 | 273 | |
274 | 274 | //create one thread for each detector pixel |
... | ... | @@ -279,7 +279,7 @@ public: |
279 | 279 | field<T, D> result(R[0], R[1]); |
280 | 280 | |
281 | 281 | for(int n=0; n<D; n++) |
282 | - rts::gpu_field_multiply <<<dimGrid, dimBlock>>> (result.X[n], X[n], rhs.X[n], R[0], R[1]); | |
282 | + stim::gpu_field_multiply <<<dimGrid, dimBlock>>> (result.X[n], X[n], rhs.X[n], R[0], R[1]); | |
283 | 283 | |
284 | 284 | return result; |
285 | 285 | } |
... | ... | @@ -310,7 +310,7 @@ public: |
310 | 310 | |
311 | 311 | //crop the field |
312 | 312 | field<T, D> crop(unsigned int width, unsigned int height){ |
313 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
313 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
314 | 314 | int SQRT_BLOCK = (int)std::sqrt((float)maxThreads); |
315 | 315 | |
316 | 316 | //create one thread for each detector pixel |
... | ... | @@ -321,20 +321,20 @@ public: |
321 | 321 | field<T, D> result(width, height); |
322 | 322 | |
323 | 323 | for(int n=0; n<D; n++) |
324 | - rts::gpu_field_crop <<<dimGrid, dimBlock>>> (result.X[n], X[n], R[0], R[1], width, height); | |
324 | + stim::gpu_field_crop <<<dimGrid, dimBlock>>> (result.X[n], X[n], R[0], R[1], width, height); | |
325 | 325 | |
326 | 326 | return result; |
327 | 327 | } |
328 | 328 | |
329 | 329 | //save an image representing component n |
330 | 330 | void toImage(std::string filename, unsigned int n = 0, |
331 | - bool positive = false, rts::colormapType cmap = rts::cmBrewer){ | |
331 | + bool positive = false, stim::colormapType cmap = stim::cmBrewer){ | |
332 | 332 | T max_val = find_max(n); //find the maximum value |
333 | 333 | |
334 | 334 | if(positive) //if the field is positive, use the range [0 max_val] |
335 | - rts::gpu2image<T>(X[n], filename, R[0], R[1], 0, max_val, cmap); | |
335 | + stim::gpu2image<T>(X[n], filename, R[0], R[1], 0, max_val, cmap); | |
336 | 336 | else |
337 | - rts::gpu2image<T>(X[n], filename, R[0], R[1], -max_val, max_val, cmap); | |
337 | + stim::gpu2image<T>(X[n], filename, R[0], R[1], -max_val, max_val, cmap); | |
338 | 338 | } |
339 | 339 | |
340 | 340 | }; | ... | ... |
math/matrix.h
math/realfield.cuh
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | |
11 | 11 | ///Compute a Gaussian function in 3D (mostly for testing) |
12 | 12 | /*template<typename T> |
13 | -__global__ void gpu_gaussian(T* dest, unsigned int r0, unsigned int r1, T mean, T std, rts::rect<T> shape) | |
13 | +__global__ void gpu_gaussian(T* dest, unsigned int r0, unsigned int r1, T mean, T std, stim::rect<T> shape) | |
14 | 14 | { |
15 | 15 | int iu = blockIdx.x * blockDim.x + threadIdx.x; |
16 | 16 | int iv = blockIdx.y * blockDim.y + threadIdx.y; |
... | ... | @@ -24,7 +24,7 @@ __global__ void gpu_gaussian(T* dest, unsigned int r0, unsigned int r1, T mean, |
24 | 24 | T u = (T)iu / (T)r0; |
25 | 25 | T v = (T)iv / (T)r1; |
26 | 26 | |
27 | - rts::vec<T> p = shape(u, v); | |
27 | + stim::vec<T> p = shape(u, v); | |
28 | 28 | |
29 | 29 | T fx = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[0] - mean, 2) / (2 * std*std) ); |
30 | 30 | T fy = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[1] - mean, 2) / (2 * std*std) ); |
... | ... | @@ -140,12 +140,12 @@ public: |
140 | 140 | HANDLE_ERROR(cudaMemset(X[n], 0, sizeof(P) * R[0] * R[1])); |
141 | 141 | } |
142 | 142 | |
143 | - void toImage(std::string filename, unsigned int n, P vmin, P vmax, rts::colormapType cmap = rts::cmBrewer) | |
143 | + void toImage(std::string filename, unsigned int n, P vmin, P vmax, stim::colormapType cmap = stim::cmBrewer) | |
144 | 144 | { |
145 | - rts::gpu2image<P>(X[n], filename, R[0], R[1], vmin, vmax, cmap); | |
145 | + stim::gpu2image<P>(X[n], filename, R[0], R[1], vmin, vmax, cmap); | |
146 | 146 | } |
147 | 147 | |
148 | - void toImages(std::string filename, bool global_max = true, rts::colormapType cmap = rts::cmBrewer) | |
148 | + void toImages(std::string filename, bool global_max = true, stim::colormapType cmap = stim::cmBrewer) | |
149 | 149 | { |
150 | 150 | std::string prefix, postfix, extension; |
151 | 151 | unsigned int digits; |
... | ... | @@ -233,7 +233,7 @@ public: |
233 | 233 | //multiply two fields (element-wise multiplication) |
234 | 234 | realfield<P, N, positive> operator* (const realfield & rhs){ |
235 | 235 | |
236 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
236 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
237 | 237 | int SQRT_BLOCK = (int)std::sqrt((float)maxThreads); |
238 | 238 | |
239 | 239 | //create one thread for each detector pixel |
... | ... | @@ -244,7 +244,7 @@ public: |
244 | 244 | realfield<P, N, positive> result(R[0], R[1]); |
245 | 245 | |
246 | 246 | for(int n=0; n<N; n++) |
247 | - rts::gpu_realfield_multiply <<<dimGrid, dimBlock>>> (result.X[n], X[n], rhs.X[n], R[0], R[1]); | |
247 | + stim::gpu_realfield_multiply <<<dimGrid, dimBlock>>> (result.X[n], X[n], rhs.X[n], R[0], R[1]); | |
248 | 248 | |
249 | 249 | return result; |
250 | 250 | } |
... | ... | @@ -276,7 +276,7 @@ public: |
276 | 276 | |
277 | 277 | /*void gaussian(P mean, P std, unsigned int n=0) //creates a 3D gaussian using component n |
278 | 278 | { |
279 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
279 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
280 | 280 | int SQRT_BLOCK = (int)sqrt((float)maxThreads); |
281 | 281 | //create one thread for each detector pixel |
282 | 282 | dim3 dimBlock(SQRT_BLOCK, SQRT_BLOCK); | ... | ... |
math/rect.h
... | ... | @@ -28,9 +28,9 @@ struct rect |
28 | 28 | |
29 | 29 | private: |
30 | 30 | |
31 | - rts::vec<T, N> C; | |
32 | - rts::vec<T, N> X; | |
33 | - rts::vec<T, N> Y; | |
31 | + stim::vec<T, N> C; | |
32 | + stim::vec<T, N> X; | |
33 | + stim::vec<T, N> Y; | |
34 | 34 | |
35 | 35 | CUDA_CALLABLE void scale(T factor){ |
36 | 36 | X *= factor; |
... | ... | @@ -86,20 +86,20 @@ public: |
86 | 86 | /******************************************************************* |
87 | 87 | Constructor - create a rect from a position, normal, and rotation |
88 | 88 | *******************************************************************/ |
89 | - /*CUDA_CALLABLE rect(rts::vec<T, N> c, rts::vec<T, N> normal, T width, T height, T theta) | |
89 | + /*CUDA_CALLABLE rect(stim::vec<T, N> c, stim::vec<T, N> normal, T width, T height, T theta) | |
90 | 90 | { |
91 | 91 | |
92 | 92 | //compute the X direction - start along world-space X |
93 | - Y = rts::vec<T, N>(0, 1, 0); | |
93 | + Y = stim::vec<T, N>(0, 1, 0); | |
94 | 94 | if(Y == normal) |
95 | - Y = rts::vec<T, N>(0, 0, 1); | |
95 | + Y = stim::vec<T, N>(0, 0, 1); | |
96 | 96 | |
97 | 97 | X = Y.cross(normal).norm(); |
98 | 98 | |
99 | 99 | std::cout<<X<<std::endl; |
100 | 100 | |
101 | 101 | //rotate the X axis by theta radians |
102 | - rts::quaternion<T> q; | |
102 | + stim::quaternion<T> q; | |
103 | 103 | q.CreateRotation(theta, normal); |
104 | 104 | X = q.toMatrix3() * X; |
105 | 105 | Y = normal.cross(X); |
... | ... | @@ -130,14 +130,14 @@ public: |
130 | 130 | /******************************************* |
131 | 131 | Return the normal for the rect |
132 | 132 | *******************************************/ |
133 | - CUDA_CALLABLE rts::vec<T, N> n() | |
133 | + CUDA_CALLABLE stim::vec<T, N> n() | |
134 | 134 | { |
135 | 135 | return (X.cross(Y)).norm(); |
136 | 136 | } |
137 | 137 | |
138 | - CUDA_CALLABLE rts::vec<T, N> p(T a, T b) | |
138 | + CUDA_CALLABLE stim::vec<T, N> p(T a, T b) | |
139 | 139 | { |
140 | - rts::vec<T, N> result; | |
140 | + stim::vec<T, N> result; | |
141 | 141 | //given the two parameters a, b = [0 1], returns the position in world space |
142 | 142 | vec<T, N> A = C - X * (T)0.5 - Y * (T)0.5; |
143 | 143 | result = A + X * a + Y * b; |
... | ... | @@ -145,7 +145,7 @@ public: |
145 | 145 | return result; |
146 | 146 | } |
147 | 147 | |
148 | - CUDA_CALLABLE rts::vec<T, N> operator()(T a, T b) | |
148 | + CUDA_CALLABLE stim::vec<T, N> operator()(T a, T b) | |
149 | 149 | { |
150 | 150 | return p(a, b); |
151 | 151 | } |
... | ... | @@ -209,7 +209,7 @@ public: |
209 | 209 | } //end namespace rts |
210 | 210 | |
211 | 211 | template <typename T, int N> |
212 | -std::ostream& operator<<(std::ostream& os, rts::rect<T, N> R) | |
212 | +std::ostream& operator<<(std::ostream& os, stim::rect<T, N> R) | |
213 | 213 | { |
214 | 214 | os<<R.str(); |
215 | 215 | return os; | ... | ... |
math/triangle.h
optics/material.h
... | ... | @@ -60,7 +60,7 @@ private: |
60 | 60 | std::getline(ss, line); //get the next line |
61 | 61 | } |
62 | 62 | |
63 | - function< T, rts::complex<T> >::process_string(str); | |
63 | + function< T, stim::complex<T> >::process_string(str); | |
64 | 64 | } |
65 | 65 | |
66 | 66 | void from_inverse_cm(){ |
... | ... | @@ -75,7 +75,7 @@ private: |
75 | 75 | } |
76 | 76 | |
77 | 77 | void init(){ |
78 | - bounding[0] = bounding[1] = rts::complex<T>(1, 0); | |
78 | + bounding[0] = bounding[1] = stim::complex<T>(1, 0); | |
79 | 79 | } |
80 | 80 | |
81 | 81 | ... | ... |
optics/mirst-1d.cuh
... | ... | @@ -53,7 +53,7 @@ __global__ void gpu_mirst1d_layer_fft(complex<T>* dest, complex<T>* ri, |
53 | 53 | |
54 | 54 | //T l = w * ri[inu].real(); |
55 | 55 | //complex<T> e(0.0, -2 * PI * fz * (zf[inu] + zR/2 - l/2.0)); |
56 | - complex<T> e(0, -2 * rtsPI * fz * (zf[inu] + opl/2)); | |
56 | + complex<T> e(0, -2 * stimPI * fz * (zf[inu] + opl/2)); | |
57 | 57 | |
58 | 58 | complex<T> eta = ri[inu] * ri[inu] - 1; |
59 | 59 | |
... | ... | @@ -61,7 +61,7 @@ __global__ void gpu_mirst1d_layer_fft(complex<T>* dest, complex<T>* ri, |
61 | 61 | if(ifz == 0) |
62 | 62 | dest[i] += opl * exp(e) * eta * src[inu]; |
63 | 63 | else |
64 | - dest[i] += opl * exp(e) * eta * src[inu] * sin(rtsPI * fz * opl) / (rtsPI * fz * opl); | |
64 | + dest[i] += opl * exp(e) * eta * src[inu] * sin(stimPI * fz * opl) / (stimPI * fz * opl); | |
65 | 65 | } |
66 | 66 | |
67 | 67 | template<typename T> |
... | ... | @@ -141,7 +141,7 @@ __global__ void gpu_mirst1d_apply_filter(complex<T>* sampleFFT, T* lambda, |
141 | 141 | //compute the final filter |
142 | 142 | T mirst = 0; |
143 | 143 | if(fz != 0) |
144 | - mirst = 2 * rtsPI * r * s * Q * (1/fz); | |
144 | + mirst = 2 * stimPI * r * s * Q * (1/fz); | |
145 | 145 | |
146 | 146 | sampleFFT[i] *= mirst; |
147 | 147 | |
... | ... | @@ -223,7 +223,7 @@ private: |
223 | 223 | |
224 | 224 | //calculates the optimal block and grid sizes using information from the GPU |
225 | 225 | void cuda_params(dim3& grids, dim3& blocks){ |
226 | - int maxThreads = rts::maxThreadsPerBlock(); //compute the optimal block size | |
226 | + int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
227 | 227 | int SQRT_BLOCK = (int)std::sqrt((float)maxThreads); |
228 | 228 | |
229 | 229 | //create one thread for each detector pixel |
... | ... | @@ -262,11 +262,11 @@ private: |
262 | 262 | //create one thread for each pixel of the field slice |
263 | 263 | dim3 gridDim, blockDim; |
264 | 264 | cuda_params(gridDim, blockDim); |
265 | - rts::gpu_mirst1d_layer_fft<<<gridDim, blockDim>>>(scratch.ptr(), gpuRi, gpuSrc, zf, wpx, paddedZ, S); | |
265 | + stim::gpu_mirst1d_layer_fft<<<gridDim, blockDim>>>(scratch.ptr(), gpuRi, gpuSrc, zf, wpx, paddedZ, S); | |
266 | 266 | |
267 | - int linBlock = rts::maxThreadsPerBlock(); //compute the optimal block size | |
267 | + int linBlock = stim::maxThreadsPerBlock(); //compute the optimal block size | |
268 | 268 | int linGrid = S / linBlock + 1; |
269 | - rts::gpu_mirst1d_increment_z <<<linGrid, linBlock>>>(zf, gpuRi, wpx, S); | |
269 | + stim::gpu_mirst1d_increment_z <<<linGrid, linBlock>>>(zf, gpuRi, wpx, S); | |
270 | 270 | |
271 | 271 | //free memory |
272 | 272 | HANDLE_ERROR(cudaFree(gpuRi)); |
... | ... | @@ -302,7 +302,7 @@ private: |
302 | 302 | T* gpuLambdas; |
303 | 303 | HANDLE_ERROR(cudaMalloc(&gpuLambdas, sizeof(T) * Zpad)); |
304 | 304 | HANDLE_ERROR(cudaMemcpy(gpuLambdas, &lambdas[0], sizeof(T) * Zpad, cudaMemcpyHostToDevice)); |
305 | - rts::gpu_mirst1d_apply_filter <<<gridDim, blockDim>>>(scratch.ptr(), gpuLambdas, | |
305 | + stim::gpu_mirst1d_apply_filter <<<gridDim, blockDim>>>(scratch.ptr(), gpuLambdas, | |
306 | 306 | dFz, |
307 | 307 | NA[0], NA[1], |
308 | 308 | S, Zpad); |
... | ... | @@ -382,7 +382,7 @@ public: |
382 | 382 | na(0, out); |
383 | 383 | } |
384 | 384 | |
385 | - rts::function<T, T> get_source(){ | |
385 | + stim::function<T, T> get_source(){ | |
386 | 386 | return source_profile; |
387 | 387 | } |
388 | 388 | |
... | ... | @@ -390,7 +390,7 @@ public: |
390 | 390 | //create a sample and save the magnitude as an image |
391 | 391 | build_sample(); |
392 | 392 | fft(CUFFT_INVERSE); |
393 | - scratch.toImage(filename, rts::complexfield<T, 1>::magnitude); | |
393 | + scratch.toImage(filename, stim::complexfield<T, 1>::magnitude); | |
394 | 394 | } |
395 | 395 | |
396 | 396 | void save_mirst(std::string filename, bool binary = true){ |
... | ... | @@ -411,7 +411,7 @@ public: |
411 | 411 | if(binary) |
412 | 412 | to_binary(filename); |
413 | 413 | else |
414 | - scratch.toImage(filename, rts::complexfield<T, 1>::magnitude); | |
414 | + scratch.toImage(filename, stim::complexfield<T, 1>::magnitude); | |
415 | 415 | } |
416 | 416 | |
417 | 417 | ... | ... |