Skip to content

Commit 9f5c8b5

Browse files
fixed the transpose of the matrices, no crash
1 parent 3702281 commit 9f5c8b5

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/Core/Algorithms/Legacy/Fields/FieldData/ConvertIndicesToFieldDataAlgo.cc

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ ConvertIndicesToFieldDataAlgo::runImpl(FieldHandle input_field, DenseMatrixHandl
8686
return (false);
8787
}
8888

89-
size_type nrows = input_matrix->nrows();
89+
size_type nrows = input_matrix->nrows();
9090
size_type ncols = input_matrix->ncols();
9191

9292
std::string algotype;
@@ -141,12 +141,10 @@ ConvertIndicesToFieldDataAlgo::runImpl(FieldHandle input_field, DenseMatrixHandl
141141
VField* voutput = output_field->vfield();
142142
voutput->resize_fdata();
143143

144-
DenseMatrixHandle dmh(boost::make_shared<DenseMatrix>(input_matrix));
145-
146144
if (algotype == "Scalar")
147145
{
148146
int max_index = input_matrix->nrows() * input_matrix->ncols();
149-
double *dataptr = dmh->data();
147+
const double *dataptr = input_matrix->data();
150148
VMesh::size_type sz = vinput->num_values();
151149
for (VMesh::index_type r = 0; r<sz; r++)
152150
{
@@ -165,12 +163,11 @@ ConvertIndicesToFieldDataAlgo::runImpl(FieldHandle input_field, DenseMatrixHandl
165163
{
166164
if (input_matrix->ncols() != 3)
167165
{
168-
auto dmht = dmh->transpose();
169-
dmh.reset(new DenseMatrix(dmht));
166+
input_matrix.reset(new DenseMatrix(input_matrix->transpose()));
170167
}
171168

172-
double *dataptr = dmh->data();
173-
int max_index = dmh->nrows();
169+
const double *dataptr = input_matrix->data();
170+
int max_index = input_matrix->nrows();
174171

175172
VMesh::size_type sz = vinput->num_values();
176173
for (VMesh::index_type r = 0; r<sz; r++)
@@ -190,13 +187,12 @@ ConvertIndicesToFieldDataAlgo::runImpl(FieldHandle input_field, DenseMatrixHandl
190187
{
191188
if ((input_matrix->ncols() != 6) && (input_matrix->ncols() != 9))
192189
{
193-
auto dmht = dmh->transpose();
194-
dmh.reset(new DenseMatrix(dmht));
190+
input_matrix.reset(new DenseMatrix(input_matrix->transpose()));
195191
}
196192

197-
int max_index = dmh->nrows();
198-
double *dataptr = dmh->data();
199-
int ncols = dmh->ncols();
193+
int max_index = input_matrix->nrows();
194+
const double *dataptr = input_matrix->data();
195+
int ncols = input_matrix->ncols();
200196

201197
VMesh::size_type sz = vinput->num_values();
202198
for (VMesh::index_type r = 0; r<sz; r++)

0 commit comments

Comments
 (0)