Sorry for everything, i'm attaching the full code. to compile i simply did call: mkoctfile spmaxmin_ST.cc and to run it i reated 2 sparse matrices A and B and then: tic; spmaxmin_ST(A, B); toc;
2010/12/27 Søren Hauberg <so...@hauberg.org>: > Hi > > Some practical comments: > > * Please keep the list CC'ed (press reply to all) instead of just > sending me a private mail; that way others can help. > * If you send code, please send ALL relevant code. The code you > send does NOT compile (you have not included relevant headers, > defined HELP or NUM_ARG and you have not declared calc_tnorm). > * Please send the code as an attached file so that we don't have > to copy go through the trouble of creating a new file and > copying the contents of an e-mail to this file (this is relevant > not only to make our lives easier, but also to keep the > encoding). > * Please tell us what you did to compile the code. > * Please tell us what you did to run the code. > > Søren > > man, 27 12 2010 kl. 15:54 +0100, skrev w4nderlust: >> I did that because it was suggested in the api manual. >> Anyway, if i remove it it compiles, but when i run it in octave i get >> this error: >> error: Sparse::SparseRep::elem (octave_idx_type, octave_idx_type): sparse >> matri >> x filled >> >> here's the full code: >> >> DEFUN_DLD (spmaxmin_ST, args, nargout, HELP) >> >> { >> >> if (args.length() != NUM_ARG) >> >> print_usage(); >> >> else >> >> { >> >> SparseMatrix a = args(0).sparse_matrix_value(); >> >> SparseMatrix b = args(1).sparse_matrix_value(); >> >> dim_vector dimsA = a.dims(); >> >> int rowsA = dimsA(0); >> >> int colsA = dimsA(1); >> >> >> >> dim_vector dimsB = b.dims(); >> >> int rowsB = dimsB(0); >> >> int colsB = dimsB(1); >> >> >> >> SparseMatrix c = SparseMatrix(rowsA, colsB, rowsA*colsB); >> >> dim_vector dimsC = c.dims(); >> >> int rowsC = dimsC(0); >> >> int colsC = dimsC(1); >> >> >> >> //const SparseMatrix tmp(c); >> >> int i,j,k; >> >> double mx,mn; >> >> if (colsA != rowsB) >> >> print_usage(); >> >> else >> >> { >> >> for (i = 0; i < rowsC; i++) >> >> { >> >> for(j = 0; j < colsC; j++) >> >> { >> >> mx = 0; >> >> for (k = b.cidx(j); k <= (b.cidx(j+1) >> - 1); k++) >> >> { >> >> mn = calc_tnorm(a(i, >> b.ridx(k)), b.data(k)); >> >> if (mn > mx) >> >> mx = mn; >> >> } >> >> if (mx != 0) >> >> c(i, j) = mx; >> >> } >> >> } >> >> c.maybe_compress(); >> >> return octave_value(c); >> >> } >> >> } >> >> } >> >> >> >> 2010/12/27 Søren Hauberg <so...@hauberg.org>: >> > man, 27 12 2010 kl. 15:37 +0100, skrev w4nderlust: >> >> Hello everyone. >> >> Compiling an octfile i'm experiencing a compile error. >> >> spmaxmin_ST.cc:62: error: lvalue required as left operand of assignment >> >> >> >> that's how my code works: >> >> //i create a sparse matrix >> >> SparseMatrix c = SparseMatrix(rowsA, colsB, rowsA*colsB); >> >> >> >> //i create a constart temp matrix as suggested in the documentation >> >> const SparseMatrix tmp(c); >> >> >> >> //somewhere in my code i do >> >> if (mx != 0) >> >> >> >> tmp(i, j) = mx; >> >> //mx is a double and it is initialized >> >> >> >> the problem is: >> >> tmp(i, j) = mx; >> >> >> >> i don't know what's wrong because in the documentation there are a lot >> >> of examples with this way of accessing the matrix... >> >> Can someone please help me? >> > >> > I don't know the sparse matrix API that well, but it looks like you have >> > declared a constant matrix tmp (constant means that it will not be >> > changed during the rest of the program). You then alter this matrix (by >> > 'tmp(i, j) = mx'), which is not possible if the matrix is constant. I >> > don't know this trick with the constant temp matrix, but it seems like >> > that is the source of your troubles. >> > >> > Søren >> > >> > > > >
spmaxmin_ST.cc
Description: Binary data
------------------------------------------------------------------------------ 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