Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:33

0001 #pragma once
0002 
0003 
0004 #if defined(__CUDACC__) || defined(__CUDABE__)
0005 #    define SCUDA_HOSTDEVICE __host__ __device__
0006 #    define SCUDA_INLINE __forceinline__
0007 #else
0008 #    define SCUDA_HOSTDEVICE
0009 #    define SCUDA_INLINE inline
0010 #endif
0011 
0012 
0013 
0014 SCUDA_INLINE SCUDA_HOSTDEVICE double dot(const double2& a, const double2& b)
0015 {
0016     return a.x * b.x + a.y * b.y;
0017 }
0018 
0019 SCUDA_INLINE SCUDA_HOSTDEVICE double dot(const double3& a, const double3& b)
0020 {
0021     return a.x * b.x + a.y * b.y + a.z * b.z ;
0022 }
0023 
0024 
0025 SCUDA_INLINE SCUDA_HOSTDEVICE double length(const double2& v)
0026 {
0027     return sqrtf(dot(v, v));
0028 }
0029 
0030 SCUDA_INLINE SCUDA_HOSTDEVICE double length(const double3& v)
0031 {
0032     return sqrtf(dot(v, v));
0033 }
0034 
0035 
0036 
0037 
0038 
0039 
0040 #if defined(__CUDACC__) || defined(__CUDABE__)
0041 #else
0042 
0043 #include <iostream>
0044 #include <iomanip>
0045 #include <sstream>
0046 #include <vector>
0047 
0048 inline std::ostream& operator<<(std::ostream& os, const double4& v)
0049 {
0050     int w = 8 ; 
0051     os 
0052        << "(" 
0053        << std::setw(w) << std::fixed << std::setprecision(4) << v.x 
0054        << "," 
0055        << std::setw(w) << std::fixed << std::setprecision(4) << v.y
0056        << "," 
0057        << std::setw(w) << std::fixed << std::setprecision(4) << v.z 
0058        << "," 
0059        << std::setw(w) << std::fixed << std::setprecision(4) << v.w 
0060        << ") "  
0061        ;
0062     return os; 
0063 }
0064 
0065 inline std::ostream& operator<<(std::ostream& os, const double3& v)
0066 {
0067     int w = 8 ; 
0068     os 
0069        << "(" 
0070        << std::setw(w) << std::fixed << std::setprecision(4) << v.x 
0071        << "," 
0072        << std::setw(w) << std::fixed << std::setprecision(4) << v.y
0073        << "," 
0074        << std::setw(w) << std::fixed << std::setprecision(4) << v.z 
0075        << ") "  
0076        ;
0077     return os; 
0078 }
0079 
0080 inline std::ostream& operator<<(std::ostream& os, const double2& v)
0081 {
0082     int w = 8 ; 
0083     os 
0084        << "(" 
0085        << std::setw(w) << std::fixed << std::setprecision(4) << v.x 
0086        << "," 
0087        << std::setw(w) << std::fixed << std::setprecision(4) << v.y
0088        << ") "  
0089        ;
0090     return os; 
0091 }
0092 
0093 
0094 
0095 
0096 
0097 
0098 #endif