Skip to content

subtract 1 #125

Closed
Closed
@taiwuchiang

Description

@taiwuchiang

Hi Jonath:

Here is another bug I found. The following Matlab script when converted there is an error.

Matlab:
J = zeros(6,12);
X_kk = ones(3,3);
J(1:2:end,[1 4 7]) = -X_kk';

C++ (wrong):

int main(int argc, char** argv)
{
mat J, X_kk ;
urowvec _aux_urowvec_1 ;
J = arma::zeros(6, 12) ;
X_kk = arma::ones(3, 3) ;
uword __aux_urowvec_1 [] = {1, 4, 7} ;
_aux_urowvec_1 = urowvec(__aux_urowvec_1, 3, false) ;
J(m2cpp::span(1-1, 2, J.n_rows-1), _aux_urowvec_1) = -arma::trans(X_kk) ;
return 0 ;
}

C++ (correct):

int main(int argc, char** argv)
{
mat J, X_kk ;
urowvec _aux_urowvec_1 ;
J = arma::zeros(6, 12) ;
X_kk = arma::ones(3, 3) ;
uword __aux_urowvec_1 [] = {1, 4, 7} ;
_aux_urowvec_1 = urowvec(__aux_urowvec_1, 3, false) ;
J(m2cpp::span(1-1, 2, J.n_rows-1), _aux_urowvec_1 - 1) = -arma::trans(X_kk) ;
return 0 ;
}

The _aux_urowvec_1 should subtract one from it.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions