[Jprogramming] complex x in Copy
Devon McCormick
devonmcc at gmail.com
Sat Apr 27 15:19:15 UTC 2019
Is this what you want?
a=: 10+i.2 3
(6,(#,a),6)# 0 1 0
0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0
((6,(#,a),6)# 0 1 0)#^:_1 ,a
0 0 0 0 0 0 10 11 12 13 14 15 0 0 0 0 0 0
On Sat, Apr 27, 2019 at 11:02 AM Brian Schott <schott.brian at gmail.com>
wrote:
> I have a list `b =. ,a` where a is defined below. b always contains 6
> (real) atoms, not necessarily the values in the current example a.
>
> I want to produce b using complex x values in Copy but cannot seem to get
> the correct x to do so.
>
> ]a =: 10+i. 2 3
> 10 11 12
> 13 14 15
> (0,.~0,.0,~0,])a
> 0 0 0 0 0
> 0 10 11 12 0
> 0 13 14 15 0
> 0 0 0 0 0
> [b =. ,(0,.~0,.0,~0,])a
> 0 0 0 0 0 0 10 11 12 0 0 13 14 15 0 0 0 0 0 0
>
> Below are my attempts at learning to use complex x in Copy.
>
> 0j6 # 4
> 0 0 0 0 0 0
> 0j6 1 # 4
> 0 0 0 0 0 0 4
>
> The above examples seemed to provide me a guideline, but when I try similar
> examples with a list right hand argument, I seem to lose the (leading) 10
> when I don't get a length error.
>
> 0j6 1 1 1# 10 11 12
> |length error
> | 0j6 1 1 1 #10 11 12
> 0j6 1 1 # 10 11 12
> 0 0 0 0 0 0 11 12
> 0j6 1 1 1 # 10 11 12
> |length error
> | 0j6 1 1 1 #10 11 12
>
> How do I get the desired result b(and preserve the 10 in the simpler
> examples)?
>
> --
> (B=) <-----my sig
> Brian Schott
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
Quantitative Consultant
More information about the Programming
mailing list