3D 算子实现
想实现一下3d操作,还没有完成。
#pragma once
class Mat3d
{
public:
Mat3d();
~Mat3d();
int w;
int h;
int d;
Mat3d(int w, int h, int d);
float& operator()(int i, int j, int k);
void operator=(float const & value);
private:
float* data;
};
Mat3d::Mat3d()
{
w = 0;
h = 0;
d = 0;
data = nullptr;
}
Mat3d::~Mat3d()
{
if (data)
{
delete [] data;
}
data = nullptr;
}
inline Mat3d::Mat3d(int w, int h, int d)
{
int length = w * h * d;
data = new float[length];
}
inline float& Mat3d::operator()(int i, int j, int k)
{
// TODO: insert return statement here
return data[k*w*h+j*w+i];
}
inline void Mat3d::operator=(float const& value)
{
}