Thanks a lot, now it works nicely (i also tried not to count the real nel and put all to nonzero and then compress, but the results are really equivalent). now for 100*100 matrices it works twice faster than the full version, but for 700x700 matrices it is slower (15% slower than the full version). I'll try to use the transpose of A and let's see if it gets faster.
P.S. sorry for the reply and not reply all, i always forget.... 2010/12/28 David Bateman <dbate...@dbateman.org>: > Please keep responses on the list as the list is an invaluable source of > information for people that have similar problems, and going offline > deprives them of this information. > > w4nderlust wrote: >> First thing: Thanks really much :) >> then some questions: >> 1) what's the difference between .cdx and .xcdx ? This is just to know. >> > > The "x" before data in Sparse and Full matrices and ridx and cidx in > Sparse matrices prevents some bounds checking. If you "know" that your > indexing is correct, using xridx rather than ridx then your code will be > faster, but will it will crash octave if your indexing is incorrect. > >> 2) how can owrking on the transpose of a help performances? >> > The compressed column format of Octave means that working with a Sparse > matrix column by column is many times faster than working with a matrix > row by row. The reason is that working by columns we can access the data > sequentially in "data" and "ridx" whereas as not only can't we do that > when working by rows, we have to traverse all of the elements of a > column of the sparse matrix to find the offset into "data" and "ridx" > for a particular row. > >> 3) if i run this code octave crashes... why? (using octave 3.2.4) >> >> >>>>> SA = sprand(100, 100, 0.2); >>>>> SB = sprand(100, 100, 0.2); >>>>> tic; spmaxmin_ST_new(SA, SB); toc; >>>>> >> octave: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char >> *) >> &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, >> fd))) >> ) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned >> long)((((__buil >> tin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - >> 1)) >> & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned >> long >> )old_end & pagemask) == 0)' failed. >> panic: Aborted -- stopping myself... >> attempting to save variables to `octave-core'... >> >> some other times it gives me just: >> >> panic: Segmentation fault -- stopping myself... >> >> some ideas? >> Thanks >> > Because my assumption that the maximum number of non zeros elements in > the return matrix is nnzA+nnzB is incorrect. I suggest counting the > number of elements in the returned matrix first as this can be done at > significantly lower cost than the full calculation, sizing the return > matrix correctly and then removing the call to maybe_compress as its no > longer needed. Try the attached > > David > > > ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev