#ifndef RTS_COMPLEXFIELD_H #define RTS_COMPLEXFIELD_H #include "cublas_v2.h" #include #include "../math/field.cuh" #include "../math/complex.h" namespace rts{ /*This class stores functions for saving images of complex fields */ template class complexfield : public field< rts::complex, D >{ using field< rts::complex, D >::R; using field< rts::complex, D >::X; using field< rts::complex, D >::shape; public: //find the maximum value of component n rts::complex find_max(unsigned int n){ cublasStatus_t stat; cublasHandle_t handle; //create a CUBLAS handle stat = cublasCreate(&handle); if(stat != CUBLAS_STATUS_SUCCESS){ std::cout<<"CUBLAS Error: initialization failed"< result; if(sizeof(T) == 4) stat = cublasIcamax(handle, L, (const cuComplex*)X[n], 1, &index); else stat = cublasIzamax(handle, L, (const cuDoubleComplex*)X[n], 1, &index); index -= 1; //adjust for 1-based indexing //if there was a GPU error, terminate if(stat != CUBLAS_STATUS_SUCCESS){ std::cout<<"CUBLAS Error: failure finding maximum value."<), cudaMemcpyDeviceToHost)); return result; } public: //constructor (no parameters) complexfield() : field, D>(){}; //constructor (resolution specified) complexfield(unsigned int r0, unsigned int r1) : field, D>(r0, r1){}; //assignment operator (scalar value) complexfield & operator= (const complex rhs){ field< complex, D >::operator=(rhs); return *this; } //assignment operator (vector value) complexfield & operator= (const vec< complex, D > rhs){ field< complex, D >::operator=(rhs); return *this; } void toImage(std::string filename, unsigned int n){ } }; } //end namespace rts #endif