Skip to content

Commit e6827db

Browse files
committed
fixed ctors
1 parent 0bdd811 commit e6827db

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/SIMDMatrix.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ SIMDMatrix::~SIMDMatrix()
9191
}
9292

9393
SIMDMatrix::SIMDMatrix(const SIMDMatrix& other)
94-
: m_rows(other.m_rows), m_cols(other.m_cols), m_stride(other.m_stride)
94+
: m_rows(other.m_rows), m_cols(other.m_cols), m_stride(other.m_stride), m_strideRow(other.m_strideRow)
9595
{
96-
size_t bytes = m_rows * m_stride * sizeof(float);
96+
size_t bytes = m_strideRow * m_stride * sizeof(float);
9797
m_data = (float*)alloc_aligned(bytes, SIMD_ALIGNMENT);
9898
std::memcpy(m_data, other.m_data, bytes);
9999
}
@@ -103,8 +103,8 @@ SIMDMatrix& SIMDMatrix::operator=(const SIMDMatrix& other)
103103
if (this == &other)
104104
return *this;
105105

106-
size_t neededBytes = other.m_rows * other.m_stride * sizeof(float);
107-
size_t currentBytes = m_rows * m_stride * sizeof(float);
106+
size_t neededBytes = other.m_strideRow * other.m_stride * sizeof(float);
107+
size_t currentBytes = m_strideRow * m_stride * sizeof(float);
108108

109109
if (neededBytes != currentBytes)
110110
{
@@ -115,6 +115,7 @@ SIMDMatrix& SIMDMatrix::operator=(const SIMDMatrix& other)
115115
m_rows = other.m_rows;
116116
m_cols = other.m_cols;
117117
m_stride = other.m_stride;
118+
m_strideRow = other.m_strideRow;
118119
std::memcpy(m_data, other.m_data, neededBytes);
119120

120121
return *this;
@@ -124,11 +125,14 @@ SIMDMatrix::SIMDMatrix(SIMDMatrix&& other) noexcept
124125
: m_rows(other.m_rows),
125126
m_cols(other.m_cols),
126127
m_stride(other.m_stride),
128+
m_strideRow(other.m_strideRow),
127129
m_data(other.m_data)
128130
{
129131
other.m_data = nullptr;
130132
other.m_rows = 0;
131133
other.m_cols = 0;
134+
other.m_stride = 0;
135+
other.m_strideRow = 0;
132136
}
133137

134138
SIMDMatrix& SIMDMatrix::operator=(SIMDMatrix&& other) noexcept
@@ -141,6 +145,7 @@ SIMDMatrix& SIMDMatrix::operator=(SIMDMatrix&& other) noexcept
141145
m_rows = other.m_rows;
142146
m_cols = other.m_cols;
143147
m_stride = other.m_stride;
148+
m_strideRow = other.m_strideRow;
144149

145150
other.m_data = nullptr;
146151
other.m_rows = 0;

0 commit comments

Comments
 (0)