help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: matrices


From: Jaroslav Hajek
Subject: Re: matrices
Date: Tue, 2 Jun 2009 06:55:25 +0200

On Tue, Jun 2, 2009 at 12:40 AM, Dmitri A. Sergatskov
<address@hidden> wrote:
> On Mon, Jun 1, 2009 at 5:21 PM, Carlo Rossi <address@hidden> wrote:
>> Hello,
>>  I have a matrix A and I need to do it:
>>
>> sum1 = SUM_of_all_element_on_diagonal
>
> sum1 = trace(A)
>
>> sum2 = sum_ofAllElemetNonOn_theDiagonal;
>>
>
> sum2 = sum(sum(A)) - sum1
>

A minor note: if A is strongly diagonally dominant, that formula may
bring an unacceptable amount of cancellation. In that case, you better
do
sum2 = sum ((A- diag (diag (A)))(:));

regards

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]