Open main menu

CDOT Wiki β

Changes

UnknownX

774 bytes added, 15:11, 11 April 2017
V4 -- Double -> float
=== V4 -- Double -> float ===
struct Vec3 {
double x, y, z;
__host__ __device__ Vec3(double x, double y, double z) : x(x), y(y), z(z) {}
__host__ __device__ Vec3 operator + (const Vec3& v) const { return Vec3(x + v.x, y + v.y, z + v.z); }
__host__ __device__ Vec3 operator - (const Vec3& v) const { return Vec3(x - v.x, y - v.y, z - v.z); }
__host__ __device__ Vec3 operator * (double d) const { return Vec3(x*d, y*d, z*d); }
__host__ __device__ Vec3 operator / (double d) const { return Vec3(x / d, y / d, z / d); }
__host__ __device__
Vec3 normalize() const {
double mg = sqrt(x*x + y*y + z*z);
return Vec3(x / mg, y / mg, z / mg);
}
};
 
What problems does it solve?
1. Using too much register
 
 
[[File:Pyoccu2.PNG]]
 
2. Calculating in double slowly on Geforce device.
[[File:pyfloat.PNG]]
122
edits