On Sat, Sep 11, 2010 at 3:57 PM, I wrote:
> currentLevel- currentLevel*"1 2 A
This turns out to be wrong, but I have a blind spot here
(I do not really understand Lie algebras so I am working
by rote, rather than based on an understanding of the
problem domain).
That said, here is how I might structure the testing
aspect of this algorithm:
cartReflect =: 1 : 0
:
y - y *&(x&{) m
)
byLevel=: 3 :0
'w A maxLevel'=. y
reflect =: A cartReflect"0 1
newFromWeight =. 4 : 'y reflect x' i...@#"1
weights=. currentLevel=.,:w
for.i.maxLevel do.
newW=. (0&< *"0 1 newFromWeight) currentLevel
mask=. ($ $ *./\@:-.@:=...@i.@{:@$) currentLevel
keep=. (*./"1 (0) < newW ^mask) *. +./"1 newW ~: 0
currentLevel=. keep #&(,/) newW
weights=. weights, currentLevel
end.
)
A =: 4 4 $ 2 _1 0 0 _1 2 _1 0 0 _1 2 _1 0 0 _1 2
assert (byLev-: byLevel) (1 1 1 1 ; A ; 10)
That is rather clumsy -- I should probably pull the
anonymous functions out of the loop and give them
names. And I am not really taking advantage of
the structure because I am still using an explicit
definition with a low rank, and the whole point of
this rephrasing was to let me use native ranks
rather than low rank on an explicit function.
But I hope it conveys the gist of my suggestion --
that it's possible to defer the compression of
the result, and work with regular structures inside
the loop.
That said, I have other things I need to work
on and I need to set this aside for now.
FYI,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm