w4nderlust wrote: > Il giorno 09/gen/2011, alle ore 00.06, David Bateman ha scritto: > > >> w4nderlust wrote: >> >>> That's the way i'm working right now. >>> Really not right now, because i discovered a bug in the single thread >>> version and i'm correcting it at this time. Can you help me about it? >>> The problem is this: if the result matrix is a vector 1xn or nx1 the >>> final c.transpose() gives a segmentation fault. I really can't >>> understand why. >>> You can easly reproduce the problem addint a true as third parameter >>> to the function (it calculates only the diagonal values and returns it >>> in a colum vector). >>> Like: >>> A = sprand(400, 400, 0.02); >>> B = sprand(400, 400, 0.02); >>> Z= fl_spcompose(A, B, true); >>> >>> I attach the code >>> >>> >> I really have no idea what your code is trying to do, but trying to >> decypt what you've written and rewriting, I'd suggest the attached >> instead.. I suspect the code doesn't do what you want however as the >> matrix A is only checked at elements where the matrix B is non zero. >> >> D. >> > > The algorithm is doing what i want don't worry about it ;) > By the way, the column vector is full data structure, i wanted to return a > 1xn or nx1 sparse matrix for two main reasons: the result will probably be > full of zeroes because it's computed from 2 sparse matrices/vectors so > returning a full data structure is a waste of memory; the second reason is > simply consistence between returned data types among different inputs and > also consistency between the input types and the return types. > A 1xn sparse matrix uses the following memory
cidx: (n + 1) * sizeof(octave_idx_type) ridx: nnz *sizeof(octave_idx_type) data: nnz * sizeof(double) so this is likely to use more memory than a column vector. Yes a nx1 column vector will use more memory than the sparse version by I think the code overhead is worth it as you have to make the rest of the code more complex to reuse it for both versions. > Isn't there a way to make the transpose over a sparse 1xn or nx1 matrix work > without segmentation fault? > Thanks > transpose of a sparse column vector gets you a sparse row vector, one of them is going to use more memory than you want to. I'd suggest just sticking with the column vector as sparse/full matrices can be mixed and matched without problems.. If you really want a sparse column vector returned, I'd say keep a similar code structure and create the sparse column vector in a separate code block. I didn't even look at why you were getting a segfault. D. ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev