You've already got a good reply from Raul, but I'll offer these variants,
having spent a little while looking at the problem.
The first one possibly overuses what I think of as each (&.>) and every
(&>) :
f1 =: (({: every) ((~.@[);~each ((+/)/.)) >@({.every) )
It does the key operation on the vector of coefficients, >@({.every) v1,
and boxes it up with the nub of basis vectors.
However, if you open v1 by one level, you get a perfectly serviceable
array made up of coefficients in the first column, and the boxed basis
vectors in the other column:
>v1
+---+-----+
|2.3|2 3 4|
+---+-----+
|3.9|1 2 |
+---+-----+
|3.1|2 3 4|
+---+-----+
So, like Raul's f, I think, f2 works on this simpler array and then adds
the extra level of boxing as in your example.
So here, first, is f2o which works on the open of v1:
f2o =: ({:"1 (~.@[ ;~&> +//.) >@({."1))
f2o > v1
+---+-----+
|5.4|2 3 4|
+---+-----+
|3.9|1 2 |
+---+-----+
It's easy to add the required level of boxing using under (&.) :
f2 =: f2o&.(>"1) NB. ie f20 under >"1
resulting in
f2 v1
+-----------+---------+
|+---+-----+|+---+---+|
||5.4|2 3 4|||3.9|1 2||
|+---+-----+|+---+---+|
+-----------+---------+
f2 is slightly leaner in space usage:
ts
6!:2 , 7!:2@]
ts' f1 q' [ q =: 100 $v1
3.93e_5 9472
ts' f2 q'
3.1e_5 7040
Cheers,
Mike
On 25/11/2019 16:12, Arnab Chakraborty wrote:
Dear all,
I am trying to implement a geometric algebra system in J. I have done
much of the stuff, but is getting stuck at one point. Hence this email.
Basically, I have a list of boxes like
v1=: (<2.3; 2 3 4), (<3.9; 1 2), <3.1; 2 3 4
This represents a (multi)vector whose math representation is
2.3 * e_{234} + 3.9 * e_{12} + 3.1 * e_{234}.
Here the e_{...}'s are some basis vectors. As you can see, e_{234} occurs
twice in the list, and so this vector may be reduced to
5.4 * e_{234} + 3.9 * e_{12}.
In J this should be
v2=:(<5.4; 2 3 4), <3.9; 1 2
I want to write a monad f such that f v1 is v2.
Any idea?
Thanks and regards.
Arnab.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm