help-octave
[Top][All Lists]

## Re: manipulating sparse matrices

 From: David Bateman Subject: Re: manipulating sparse matrices Date: Sat, 15 Oct 2005 14:18:34 +0200 User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

```Mike Miller a écrit :

```
```I'm using Octave 2.1.71 on Linux with Octave-Forge 2005.06.13.

I have two questions about sparse matrices...

If I do this...

a = speye(1000);
a(1,1) = 2;

```
...the resulting 'a' matrix is no longer of class "sparse" and it takes up 8 MB of RAM. That's not good for me. Is there a way to reassign an element of a sparse matrix without changing its class? I believe this just works in 2.9, but is there a way to do it in 2.1.71?
```
```
```Andy responded to this one....

```
How can I find out how much memory is being used by a sparse matrix? If I do this...
```
octave:33> a=speye(1000);
octave:34> whos a

```
...I am told "Total is 1000000 elements using 0 bytes," but is it really zero bytes? That's an impressive feat. There seems to be a function called nzmax that will tell me the memory allocation, but I can't figure out how to get that function...
```
http://octave.sourceforge.net/index/f/nzmax.html

```
nzmax is in 2.9, as the source-forge index was I believe based on a 2.9.2 release, it should probably be updated soon as many things have changed (eg statistics functions, etc). The 0bytes is a missing feature in the octave-forge sparse functions as the bytes size in the whos function I believe was added at 2.1.58, after the octave-forge sparse stuff was written. Basically, it needs to implement a byte_size() function to return the value that will be printed.. This also works in 2.9.3
```
```
As you were asking about cholesky factorizations previously, I've just gotten sparse cholesky factorizations working with cholmod and will commit this soon, I want to try to address the chol2inv, cholinv and inv functions, and update the docs first though...
```
Cheers
David

-------------------------------------------------------------
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
-------------------------------------------------------------

```