SHARE
TWEET

Untitled

a guest Apr 25th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template<typename T, unsigned long N>
  2. class CudaVec {
  3. public:
  4.     CUDA_CALLABLE CudaVec(const T& val=T());
  5.     CUDA_CALLABLE CudaVec(T array[N]);
  6.     CUDA_CALLABLE CudaVec(const T& x, const T& y, const T& z);
  7.     CUDA_CALLABLE CudaVec(const CudaVec<T,N>& other) = default;
  8.     CUDA_CALLABLE CudaVec(CudaVec<T,N>&& other) = default;
  9.     CUDA_CALLABLE virtual ~CudaVec() = default;
  10.     CUDA_CALLABLE CudaVec<T,N>& operator=(const CudaVec<T,N>& right) = default;
  11.     CUDA_CALLABLE CudaVec<T,N>& operator=(CudaVec<T,N>&& right) = default;
  12.  
  13.     CUDA_CALLABLE CudaVec<T,N> operator+(const CudaVec<T,N>& right) const;
  14.     CUDA_CALLABLE CudaVec<T,N> operator-(const CudaVec<T,N>& right) const;
  15.     CUDA_CALLABLE CudaVec<T,N> operator+(const T& right) const;
  16.     CUDA_CALLABLE CudaVec<T,N> operator-(const T& right) const;
  17.     CUDA_CALLABLE CudaVec<T,N> operator*(const T& right) const;
  18.     CUDA_CALLABLE CudaVec<T,N> operator/(const T& right) const;
  19.     CUDA_CALLABLE CudaVec<T,N> operator-() const;
  20.     CUDA_CALLABLE CudaVec<T,N>& operator+=(const CudaVec<T,N>& right);
  21.     CUDA_CALLABLE CudaVec<T,N>& operator-=(const CudaVec<T,N>& right);
  22.     CUDA_CALLABLE CudaVec<T,N>& operator+=(const T& right);
  23.     CUDA_CALLABLE CudaVec<T,N>& operator-=(const T& right);
  24.     CUDA_CALLABLE CudaVec<T,N>& operator*=(const T& right);
  25.     CUDA_CALLABLE CudaVec<T,N>& operator/=(const T& right);
  26.  
  27.     CUDA_CALLABLE CudaVec<T,3> cross(const CudaVec<T,3>& right) const;
  28.     CUDA_CALLABLE CudaVec<T,N> dot(const CudaVec<T,N>& right) const;
  29.    
  30.     CUDA_CALLABLE T norm2() const;
  31.     CUDA_CALLABLE T norm() const;
  32.     CUDA_CALLABLE T normalize();
  33.  
  34.     CUDA_CALLABLE const T& get(unsigned long index) const;
  35.     CUDA_CALLABLE const T& x() const;
  36.     CUDA_CALLABLE const T& y() const;
  37.     CUDA_CALLABLE const T& z() const;
  38.     CUDA_CALLABLE const T& operator[](unsigned long index) const;
  39.     CUDA_CALLABLE T& operator[](unsigned long index);
  40.  
  41. private:
  42.     T elems[N];
  43. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top