# [Rcpp-devel] trans() changed in latest RcppArmadillo

Tue May 31 01:48:41 CEST 2011

```Sorry, I had too many spaces in the vectors. The conclusion is the same though.

library(inline)

## let's calculate this product
c(-1-1i, 1-1i) %*% c(1i, -1i)
## 0-2i

## trans() with v0.2.19
fx <- cxxfunction( signature() , '
arma::cx_colvec A = "(-1,-1) (+1,-1);", B = "(+0,1) (+0,-1);" ;
arma::cx_colvec res = trans(A) * B;

return wrap( res ) ;

fx()
## 0-2i

## strans() with v0.2.21
fx <- cxxfunction( signature() , '
arma::cx_colvec A = "(-1,-1) (+1,-1);", B = "(+0,1) (+0,-1);" ;
arma::cx_colvec res = strans(A) * B;
return wrap( res ) ;

fx()
## 1-1i

On 31 May 2011 11:42, baptiste auguie <baptiste.auguie at googlemail.com> wrote:
> After a couple hours switching back and forth between versions, I
> found a problem with the scalar product of complex vectors. Here is a
> minimal example,
>
> library(inline)
>
> ## let's calculate this product
> c(-1-1i, 1-1i) %*% c(1i, -1i)
>  ## 0-2i
>
> ## trans() with v0.2.19
> fx <- cxxfunction( signature() , '
>  arma::cx_colvec A = " (-1,-1)    (+1,-1) ;", B = "(+0,1)  (+0,-1) ;" ;
>                arma::cx_colvec res = trans(A) * B;
>
>                return wrap( res ) ;
>        ', plugin = "RcppArmadillo" )
>
> fx()
> ## 0-2i
>
> ## strans() with v0.2.21
> fx <- cxxfunction( signature() , '
>  arma::cx_colvec A = " (-1,-1)    (+1,-1) ;", B = "(+0,1)  (+0,-1) ;" ;
>                arma::cx_colvec res = strans(A) *B;
>
>                return wrap( res ) ;
>        ', plugin = "RcppArmadillo" )
>
> fx()
> ## 1-1i
>
> Best regards,
>
> baptiste
>
>
>
> On 31 May 2011 10:01, baptiste auguie <baptiste.auguie at googlemail.com> wrote:
>> I was a bit optimistic yesterday; I have not yet been able to produce
>> a minimal example but it seems trans/strans was not the end of the
>> story in my code. Something else was broken with the change to
>> 0.2.21.Thankfully the end results are very visibly wrong.
>>
>> Best regards,
>>
>> Baptiste
>>
>> On 31 May 2011 07:02, Savitsky, Terrance <savitsky at rand.org> wrote:
>>> Dr. Sanderson, I've been able to verify that my issue resides in the
>>> inv() function (that I typically apply to small p x p matrices, where p
>>> = 3 - 10).  In particular, the new version/algorithm induces numerical
>>> instability.  I've not yet tested that the results of the inv()
>>> computation are generally accurate, only that they are not numerically
>>> robust in comparison to 0.2.19.  I'm up against a deadline, so I
>>> switched back to 0.2.19, which resolves my problem, for now, but will
>>> provide a reproducible example when finished with my work.
>>>
>>> Terrance
>>>
>>> -----Original Message-----
>>> Sent: Monday, May 30, 2011 6:34 AM
>>> To: rcpp-devel at r-forge.wu-wien.ac.at
>>> Cc: Savitsky, Terrance
>>> Subject: Re: trans() changed in latest RcppArmadillo
>>>
>>> On 30 May 2011, Terrance Savitsky wrote:
>>>> previously working code (across many functions) ceased working (on a
>>>> Windows XP installation).  I re-installed the previous version
>>> (0.2.20)
>>>> from CRAN (via a server location not yet updated to 0.2.21); didn't
>>> fix it.
>>>> The timing may be a coincidence, though reading the post on
>>>> trans() encourages me to make this post.  While I use 'trans' across
>>> my
>>>> functions, it is not applied on complex-valued matrices; only
>>>> real-valued.  So the prior post wouldn't explain my issue.
>>>
>>> Hi, I'm the main author of Armadillo.
>>>
>>> I'm interested in hearing about all regressions -- can you provide
>>> more details ?
>>>
>>> There have been a lot of changes between Armadillo 1.2 and the latest
>>> beta (1.99.3).  I'd like to shake out all known bugs before releasing
>>> 2.0.
>>>
>>>
>>> Cheers,
>>>
>>> --
>>> Dr Conrad Sanderson : Sr Research Scientist : NICTA :
>>> http://arma.sf.net/cs
>>>
>>> __________________________________________________________________________
>>>
>>> This email message is for the sole use of the intended recipient(s) and
>>> may contain confidential information. Any unauthorized review, use,
>>> disclosure or distribution is prohibited. If you are not the intended