Another approach:

NB. Subtract projection of x onto y from x, leaving x orthogonal to y
   orthox =: [ - ] +/ . * %.
NB. Convert list to a column vector
   entable =: ,:^:(1=#@$)
NB. For each column, take orthogonal part & append to previous columns
   orthogonalize =: (] ,~ orthox&.|:)&entable/&.|:

   ]o =. orthogonalize 4 4 ?@$ 100
 0.376604 _1.95486 _16.0435 48
 _1.27576 _20.7855  54.7391 12
_0.461323  57.2098  18.8696  6
  1.38657 0.440836       61  0
   +/ . *"1/~ |:o    NB. check orthogonality
     3.90478  5.34905e_13 _5.54223e_13 _2.55795e_13
 5.34905e_13      3709.01 _1.42109e_13 _9.66338e_13
_5.54223e_13 _1.42109e_13      7330.83 _2.70006e_13
_2.55795e_13 _9.66338e_13 _2.70006e_13         2484

Time me no timings!  If I wanted speed I'd use LAPACK.

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

Reply via email to