Hi Don,

Are you looking for

y=:5
   c=:(*=)&i.
   c y
0 0 0 0 0
0 1 0 0 0
0 0 2 0 0
0 0 0 3 0
0 0 0 0 4

Cheers, bob

On 2012-11-18, at 7:13 PM, Don & Cathy Kelly wrote:

> OOPs' I meant y=:i.5 5
> 
> Don
> On 18/11/2012 7:04 PM, Don & Cathy Kelly wrote:
>> That gives the diagonal nicely  but the problem that I didn't express 
>> clearly is that I want a matrix as follows
>>   y=:i.5
>> 
>>   ]result =: (* =@i.@#) y
>> 0 0 0 0 0
>> 0 1 0 0 0
>> 0 0 2 0 0
>> 0 0 0 3 0
>> 0 0 0 0 4
>> which II can get by
>> c=:* =@i.@#
>>   c y
>> 0 0 0 0 0
>> 0 1 0 0 0
>> 0 0 2 0 0
>> 0 0 0 3 0
>> 0 0 0 0 4
>> 
>> For my purposes I can use a base nth order unit matrix by the phrase as 
>> given in phrases as  m=:=@i.@# y
>> and then deal with m* y1 , m* y2 etc which suits my purpose which is to form 
>> a specific Jacobean used for power system load flows.
>> I have handled this problem in APL  and am trying to replicate the coding 
>> more directly in J-mainly as an exploration of J for my own satisfaction.
>> 
>> Thank you
>> 
>> Don Kelly
> 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to