[Numpy-discussion] Construct symmetric matrix
Pierre GM
pgmdevlist@gmail....
Sun Apr 5 14:40:25 CDT 2009
On Apr 5, 2009, at 12:18 AM, David Cournapeau wrote:
> On Sun, Apr 5, 2009 at 11:17 AM, Pierre GM <pgmdevlist@gmail.com>
> wrote:
>> All,
>> I'm trying to build a relatively complicated symmetric matrix. I can
>> build the upper-right block without pb. What is the fastest way to
>> get
>> the LL corner from the UR one ?
>> Thanks a lot in advance for any idea.
>
> I may be missing something, but why not building it from scratch + a
> couple of elementary operations ? Is it too slow ? For example:
>
> # Assuming the lower part of a is zero before the operation
> a + a.T - np.diag(a.diagonal())
Sweet! Works pretty well indeed. I didn't think about that (that was a
bit late on a Sat. night for numpy).
Thx again.
More information about the Numpy-discussion
mailing list