Here is a Euclidian norm verb that is correct for vectors with complex 
components.  How would you write it?

   en =: [: %: [: +/"1 (* +)
   
   ]zz =: 2 2 $ 1j1 1j1 1j2 4j10
1j1  1j1
1j2 4j10
   
   en zz  NB. norms of vectors 1j1 1j1 and 1j2 4j10
2 11

The Euclidian norm of a vector with complex components is the square root of 
the sum of the squares of the absolute values of its components.  Verb  en  
above makes use of the "Hermitian product"   hp =: [: +/"1 (* +)  .  For 
vectors  x  and  y ,  x hp y  is the Hermitian product of x with y , and  hp y  
is the Hermitian product of y with itself.

--Kip Murray

Sent from my iPad

> On Dec 16, 2013, at 12:53 AM, "Linda Alvord" <[email protected]> wrote:
> 
> en=: [: %: [: +/"1 *:
> 
> Linda
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Ganesh Rapolu
> Sent: Sunday, December 15, 2013 10:54 PM
> To: [email protected]
> Subject: Re: [Jprogramming] Length of a vector
> 
> en =. +/"1&.:*:
> 
> 
>> On Sun, Dec 15, 2013 at 5:38 PM, km <[email protected]> wrote:
>> 
>> This is an easy one, but let's see what you come up with.
>> 
>> The Euclidian norm or length of a vector is the square root of the sum 
>> of the squares of its components.  Write verb  en  below.  It should 
>> be able to find the length of a vector of any number of components.
>> 
>>   ]yy =: 2 2 2 $ 3 4 5 12 8 15 7 24
>> 3  4
>> 5 12
>> 
>> 8 15
>> 7 24
>>   en yy  NB. lengths of 3 4 and 5 12 and 8 15 and 7 24
>> 5 13
>> 17 25
>> 
>> -- Kip Murray
>> 
>> Sent from my iPad
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to