help-octave
[Top][All Lists]
Advanced

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

Re: sparse matrix operators


From: David Bateman
Subject: Re: sparse matrix operators
Date: Tue, 16 Nov 2004 20:18:08 +0100
User-agent: Mutt/1.4.1i

I fail to see why you need an oct-file or something special for what
you want. Consider the code

n = 10;
p = 0.2;
a = sprand(n,n,p);
b = sprand(n,n,p);

## This version does a full matrix multiply and then extracts the diagonal
c = diag(a * b, 0);

## This version only multiplies the diagonal
d = sum(a .* b',2);

## Compare the two results and see they are the same
assert(c,d)

That does exactly what you want. I.E. calculate only the matrix multiply
on the diagonal..

Regards
David


-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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