字数
200 字
阅读时间
1 分钟
维护matrix.cuh
cpp
//原来使用
T raw[4];
matrix3f
//改为使用
T raw[2][2];
matrix3x3f
这样写更加人性化一点
const关键字
cpp
__host__ __device__ inline matrix3x3<T> operator * (const matrix3x3<T>& temp) {
matrix3x3<T> ret;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
ret.raw[i][j] = this->raw[i][0] * temp.raw[0][j] +
this->raw[i][1] * temp.raw[1][j] +
this->raw[i][2] * temp.raw[2][j];
}
return ret;
}
//报错
operand types are: const matrix3x3f * const matrix3x3f
//修改为
__host__ __device__ inline matrix3x3<T> operator * const(const matrix3x3<T>& temp) {
}
在 C++ 中,成员函数后面的 const
关键字表示这个成员函数是 常量成员函数(const member function),也就是说,它不会修改调用它的对象(即 *this
)的任何成员变量。
clangd的配置
没配起来