Skip to content

Commit

Permalink
[feat] accept 3-element srcparam1/srcparam2 in mcxlab/pmcx
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Feb 4, 2024
1 parent 20b0aa2 commit 007ecce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/mcxlab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,8 @@ void mcx_set_field(const mxArray* root, const mxArray* item, int idx, Config* cf
} else if (strcmp(name, "srcparam1") == 0) {
arraydim = mxGetDimensions(item);

if (arraydim[0] == 0 || arraydim[1] != 4) {
mexErrMsgTxt("the 'srcparam1' field must have 4 columns");
if (arraydim[0] == 0 || (arraydim[1] != 3 && arraydim[1] != 4)) {
mexErrMsgTxt("the 'srcparam1' field must have 3-4 columns");
}

double* val = mxGetPr(item);
Expand Down Expand Up @@ -689,8 +689,8 @@ void mcx_set_field(const mxArray* root, const mxArray* item, int idx, Config* cf
} else if (strcmp(name, "srcparam2") == 0) {
arraydim = mxGetDimensions(item);

if (arraydim[0] == 0 || arraydim[1] != 4) {
mexErrMsgTxt("the 'srcparam2' field must have 4 columns");
if (arraydim[0] == 0 || (arraydim[1] != 3 && arraydim[1] != 4)) {
mexErrMsgTxt("the 'srcparam2' field must have 3-4 columns");
}

double* val = mxGetPr(item);
Expand Down
8 changes: 4 additions & 4 deletions src/pmcx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ void parse_config(const py::dict& user_cfg, Config& mcx_config) {
arraydim[1] = buffer_info.shape.at(1);
}

if (arraydim[0] == 0 || arraydim[1] != 4) {
throw py::value_error("the 'srcparam1' field must have 4 columns");
if (arraydim[0] == 0 || (arraydim[1] != 3 && arraydim[1] != 4)) {
throw py::value_error("the 'srcparam1' field must have 3-4 columns");
}

auto val = static_cast<float*>(buffer_info.ptr);
Expand Down Expand Up @@ -600,8 +600,8 @@ void parse_config(const py::dict& user_cfg, Config& mcx_config) {
arraydim[1] = buffer_info.shape.at(1);
}

if (arraydim[0] == 0 || arraydim[1] != 4) {
throw py::value_error("the 'srcparam2' field must have 4 columns");
if (arraydim[0] == 0 || (arraydim[1] != 3 && arraydim[1] != 4)) {
throw py::value_error("the 'srcparam2' field must have 3-4 columns");
}

auto val = static_cast<float*>(buffer_info.ptr);
Expand Down

0 comments on commit 007ecce

Please sign in to comment.