#ifndef RTS_REALFIELD_H #define RTS_REALFIELD_H #include "../visualization/colormap.h" #include "../envi/envi.h" #include "../math/rect.h" #include "../cuda/devices.h" #include "cublas_v2.h" #include ///Compute a Gaussian function in 3D (mostly for testing) /*template __global__ void gpu_gaussian(T* dest, unsigned int r0, unsigned int r1, T mean, T std, rts::rect shape) { int iu = blockIdx.x * blockDim.x + threadIdx.x; int iv = blockIdx.y * blockDim.y + threadIdx.y; //make sure that the thread indices are in-bounds if(iu >= r0 || iv >= r1) return; //compute the index into the field int i = iv*r0 + iu; T u = (T)iu / (T)r0; T v = (T)iv / (T)r1; rts::vec p = shape(u, v); T fx = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[0] - mean, 2) / (2 * std*std) ); T fy = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[1] - mean, 2) / (2 * std*std) ); T fz = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[2] - mean, 2) / (2 * std*std) ); dest[i] = fx * fy * fz; }*/ namespace rts{ template class realfield{ P* X[N]; //an array of N gpu pointers for each field component int R[2]; //resolution of the slice rect

shape; void process_filename(std::string name, std::string &prefix, std::string &postfix, std::string &ext, unsigned int &digits) { std::stringstream ss(name); std::string item; std::vector elems; while(std::getline(ss, item, '.')) //split the string at the '.' character (filename and extension) { elems.push_back(item); } prefix = elems[0]; //prefix contains the filename (with wildcard '?' characters) ext = elems[1]; //file extension (ex. .bmp, .png) ext = std::string(".") + ext; //add a period back into the extension size_t i0 = prefix.find_first_of("?"); //find the positions of the first and last wildcard ('?'') size_t i1 = prefix.find_last_of("?"); postfix = prefix.substr(i1+1); prefix = prefix.substr(0, i0); digits = i1 - i0 + 1; //compute the number of wildcards } void init() { for(unsigned int n=0; n(vec

(-1, -1, 0), vec

(-1, 1, 0), vec

(1, 1, 0)); //default geometry clear(); //zero the field std::cout<<"realfield CONSTRUCTOR"<(X[n], filename, R[0], R[1], vmin, vmax, cmap); } void toImages(std::string filename, bool global_max = true, rts::colormapType cmap = rts::cmBrewer) { std::string prefix, postfix, extension; unsigned int digits; process_filename(filename, prefix, postfix, extension, digits); //process the filename for wild cards cublasStatus_t stat; cublasHandle_t handle; //create a CUBLAS handle stat = cublasCreate(&handle); if(stat != CUBLAS_STATUS_SUCCESS) { std::cout<<"CUBLAS Error: initialization failed"< maxAll) //if maxVal is larger, update the maxAll variable maxAll = maxVal[n]; } cublasDestroy(handle); //destroy the CUBLAS handle P outputMax = abs(maxAll); //maximum value used for each output image for(int n=0; n <<>> (X[n], R[0], R[1], mean, std, shape); }*/ }; } //end namespace rts #endif