I hadn't looked at this thread until just now.
Kip repeats his specification that the input is upper triangular with
real diagonal.
Assuming that is indeed the case, then surely this is adequate and concise:
(NB apologies for any remaining formatting problems - I've tried to
correct them manually)
((++@|:)-(*=)) A
1 2j3
2j_3 4
[Abig=:((</~i.10)*j./?2 10 10$10)+(<:/~i.10)*1+?10 10$10
1 4j6 8j7 2j3 11j6 9j3 18j1 19j6 7 12j5
0 5 6j6 10j2 12j6 16j7 9j3 8j6 13j9 12j5
0 0 5 11j5 15j7 12j4 4j2 8 7j3 11j3
0 0 0 10 8j3 12j4 7j5 16j5 8j1 15j1
0 0 0 0 1 14j8 5j6 6j3 12j1 15j7
0 0 0 0 0 10 14j5 8j6 4 12j1
0 0 0 0 0 0 6 10j2 13j3 15
0 0 0 0 0 0 0 2 16j1 10j6
0 0 0 0 0 0 0 0 3 17j6
0 0 0 0 0 0 0 0 0 5
((++@|:)-(*=))Abig
1 4j6 8j7 2j3 11j6 9j3 18j1 19j6 7 12j5
4j_6 5 6j6 10j2 12j6 16j7 9j3 8j6 13j9 12j5
8j_7 6j_6 5 11j5 15j7 12j4 4j2 8 7j3 11j3
2j_3 10j_2 11j_5 10 8j3 12j4 7j5 16j5 8j1 15j1
11j_6 12j_6 15j_7 8j_3 1 14j8 5j6 6j3 12j1 15j7
9j_3 16j_7 12j_4 12j_4 14j_8 10 14j5 8j6 4 12j1
18j_1 9j_3 4j_2 7j_5 5j_6 14j_5 6 10j2 13j3 15
19j_6 8j_6 8 16j_5 6j_3 8j_6 10j_2 2 16j1 10j6
7 13j_9 7j_3 8j_1 12j_1 4 13j_3 16j_1 3 17j6
12j_5 12j_5 11j_3 15j_1 15j_7 12j_1 15 10j_6 17j_6 5
Mike
PS - for Chris. I ran this in the QtIDE - copy and paste from
that session resulted in no more than single spaces everywhere,
so I've had to pad them out by hand! Here's the original for
the small matrix. The 3 character indent disappears entirely.
((++@|:)-(*=))A
1 2j3
2j_3 4
On 16/01/2013 9:07 AM, km wrote:
Can't use K because its diagonal is not real (is not made up of real numbers).
Kip
Sent from my iPad
On Jan 16, 2013, at 12:55 AM, "Linda Alvord" <lindaalv...@verizon.net> wrote:
I sort of wondered about that word "triangular" but no one else seemed to
worry about it. I should have noticed that A was a triangular matrix when K
showed up
ishermitian=: -:[:+|:
]J=:hermy=. (([: <: [: +: 0 ?@$~ ,~) j. [: <: [: +: 0 ?@$~ ,~) 3
0.82045j_0.713947 _0.216061j_0.616151 _0.560927j_0.861101
0.101964j_0.151381 0.350483j_0.440496 0.58375j0.501941
0.00170859j0.457596 0.637767j0.161541 0.333754j_0.975332
]UT=:(i.3)<:/i.3
1 1 1
0 1 1
0 0 1
]K=:UT*J
0.82045j_0.713947 _0.216061j_0.616151 _0.560927j_0.861101
0 0.350483j_0.440496 0.58375j0.501941
0 0 0.333754j_0.975332
hft =: + +@|:@(- ] * =@i.@#) NB. Kip
ishermitian hft K
0
hft=: (+ +@|: * >/~@i.@#) NB. Ai
ishermitian hft K
0
hft=: (% 1 + =@i.@#)@:+ +@|: NB. Raul
ishermitian hft K
1
hft=:((23 b.&.(a.&i.)&.(2&(3!:5))&.+. +@|:)) NB. Henry
ishermitian hft K
0
hft=: 0&=`(,: +@|:)}
ishermitian hft K
0
Does K sufficient to test these programs, Kip?
Linda
-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of km
Sent: Wednesday, January 16, 2013 1:31 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Hermitian from triangular
Linda and Devon, the assignment was to turn a triangular matrix that has a
real diagonal into a Hermitian matrix. A triangular matrix can be "upper
triangular" like
1 2 3
0 4 5
0 0 6
or "lower triangular" like
1 0 0
2 3 0
4 5 6
The "diagonal" is always the one running from the upper left corner to the
lower right corner, containing 1 4 6 in the first example and 1 3 6 in the
second example. The following upper triangular matrix has a real diagonal
but some numbers off the diagonal are not real.
1 _2j3 0
0 _4 5j_6
0 0 7
Although the numbers in my examples have patterns, in general the numbers in
a triangular matrix need have no pattern except that either numbers below
the diagonal are all 0's or numbers above the diagonal are all 0's.
Kip Murray
Sent from my iPad
On Jan 15, 2013, at 11:19 PM, Devon McCormick <devon...@gmail.com> wrote:
Your results agree with mine - of the three versions of "hft" only
Raul's appears to turn an arbitrary random, complex, square matrix
into one that passes "ishermitian".
On Tue, Jan 15, 2013 at 11:05 PM, Linda Alvord
<lindaalv...@verizon.net>wrote:
Have I gotten all the definitions correct? The only one that
consistently works on a random matrix provided by Kip was provided by
Raul
ishermitian =: -: +@|:
]K=:hermy=. (([: <: [: +: 0 ?@$~ ,~) j. [: <: [: +: 0 ?@$~ ,~) 3
0.681691j_0.530679 0.105724j0.221189 0.140368j_0.982508
_0.469356j_0.623093 0.71661j0.893344 _0.125895j0.532656
_0.882974j_0.727597 0.0632899j_0.0448332 _0.975941j_0.730788
hft =: + +@|:@(- ] * =@i.@#) NB. Kip
ishermitian hft K
0
hft=: (+ +@|: * >/~@i.@#) NB. Ai
ishermitian hft K
0
hft=: (% 1 + =@i.@#)@:+ +@|: NB. Raul
ishermitian hft K
1
hft=:((23 b.&.(a.&i.)&.(2&(3!:5))&.+. +@|:)) NB. Henry
ishermitian hft K
0
hft=: 0&=`(,: +@|:)}
ishermitian hft K
0
Linda
-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Henry
Rich
Sent: Tuesday, January 15, 2013 6:21 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Hermitian from triangular
Nah, that's not beyond impish. The devilish solution is to take the
bitwise OR of the matrix with its conjugate transpose (but that's
easier in assembler language than in J:
(23 b.&.(a.&i.)&.(2&(3!:5))&.+. +@|:)) ). And you need to be sure
that the zeros on the lower diagonal and below are true zeros!
Henry Rich
On 1/15/2013 6:03 PM, km wrote:
Oh, boy! (v1`v2) } y <--> (v1 y) } (v2 y)
Brief and devilish, take care for your soul, Henry!
--Kip
Sent from my iPad
On Jan 15, 2013, at 3:39 PM, Henry Rich <henryhr...@nc.rr.com> wrote:
hft =: 0&=`(,: +@|:)}
Henry Rich
On 1/15/2013 5:25 AM, km wrote:
This is an easy one. A Hermitian matrix matches its conjugate
transpose. Write a verb hft that creates a Hermitian matrix from a
triangular one that has a real diagonal.
ishermitian =: -: +@|:
]A =: 2 2 $ 1 2j3 0 4
1 2j3
0 4
]B =: hft A
1 2j3
2j_3 4
ishermitian A
0
ishermitian B
1
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
---------------------------------------------------------------------
- For information about J forums see
http://www.jsoftware.com/forums.htm
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm