Message Boards Message Boards

Problems in RSetting complex matrices from Mathematica 12.0 to R 3.6.3

Hi, I am having trouble transferring complex matrices from Mathematica to R. In particular, the Fourier matrix, mat1, in the following code is presenting a problem.

w0 = N@2 Pi/101
mat1 = Table[(Exp[I w0]^Range[3])^i, {i, 0, 2}]
mat2 = Table[(Exp[I w0]^Range[3]), {3}]

Now the following line presents no problem

In[479]:= RSet["mat2", mat2]

Out[479]= {{0.998066 + 0.0621696 I, 0.99227 + 0.124099 I, 
  0.982635 + 0.185548 I}, {0.998066 + 0.0621696 I, 
  0.99227 + 0.124099 I, 
  0.982635 + 0.185548 I}, {0.998066 + 0.0621696 I, 
  0.99227 + 0.124099 I, 0.982635 + 0.185548 I}}

However, for some reason, mat1 fails to be RSet.

In[486]:= RSet["mat1", mat1]

During evaluation of In[486]:= JLink`JavaNew::argx: Incorrect number or type of arguments to constructor for class com.wolfram.links.rlink.dataTypes.inTypes.RComplexVectorInType. The arguments, shown here in a list, were {{1.,0.998066 +0.0621696 I,0.99227 +0.124099 I,1.,<<19>> +<<20>> I,0.969199 +0.246279 I,1.,0.982635 +0.185548 I,0.931144 +0.364652 I},{},«<<1>>»}.

During evaluation of In[486]:= RSet::puterr: Error putting the expression {{1. +0. I,1. +0. I,1. +0. I},{0.998066 +0.0621696 I,<<19>> +<<20>> I,0.982635 +<<20>> I},{0.99227 +0.124099 I,0.969199 +0.246279 I,0.931144 +0.364652 I}} into a variable mat1 in R. The last error message issued by R was Error: 'list' object cannot be coerced to type 'complex'

Out[486]= $Failed

There seem to be some type conversion issues between lists and complex data types. Why is this issue cropping up?

Regards, Hamood

POSTED BY: Hamood Khan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract