From: Dhruv on 28 Jun 2010 13:29 Hello everyone, I have been trying to use MEX files to generate a sparse matrix Strangely when the MEX call returns back to MATLAB I can access the sparse matrix S and its elements perfectly fine.. When I query size(S) - it shows me the expected m*n. nzmax(S) shows me the actual number of elements in S - However nnz(S) = 0. This is in spite of the fact that I do ahve entires and can access them. On the other hand when I save the workspace and load it elsewhere all the entries disappear. Any idea on what is happening? Dhruv
From: Bruno Luong on 28 Jun 2010 13:47 "Dhruv " <dhruv.singh(a)gmail.com> wrote in message <i0am57$965$1(a)fred.mathworks.com>... > Hello everyone, > > I have been trying to use MEX files to generate a sparse matrix > > Strangely when the MEX call returns back to MATLAB I can access the sparse matrix S and its elements perfectly fine.. When I query size(S) - it shows me the expected m*n. nzmax(S) shows me the actual number of elements in S - However nnz(S) = 0. This is in spite of the fact that I do ahve entires and can access them. > > On the other hand when I save the workspace and load it elsewhere all the entries disappear. > Any idea on what is happening? Perhaps the internal structure is incorrectly built. You must check, using for example SPOK tool on FEX until there is no longer bug in your code. Bruno
From: Dhruv on 28 Jun 2010 23:22 Hi Bruno, Thanks for your suggestions - Can you tell me about the SPOK tool? I am not sure hwo to check the format using it... Also I find that if I try to force nnz(S) =total elements I get a memory error - this seems strange because if the array is present and I can access it using nonzeros(S) then where are those elements stored...I am not separately freeing memory in the C++ MEX code but could that be a problem (I thought MEX engine frees it itself when it returns) Thanks, Dhruv "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <i0an6v$j6e$1(a)fred.mathworks.com>... > "Dhruv " <dhruv.singh(a)gmail.com> wrote in message <i0am57$965$1(a)fred.mathworks.com>... > > Hello everyone, > > > > I have been trying to use MEX files to generate a sparse matrix > > > > Strangely when the MEX call returns back to MATLAB I can access the sparse matrix S and its elements perfectly fine.. When I query size(S) - it shows me the expected m*n. nzmax(S) shows me the actual number of elements in S - However nnz(S) = 0. This is in spite of the fact that I do ahve entires and can access them. > > > > On the other hand when I save the workspace and load it elsewhere all the entries disappear. > > Any idea on what is happening? > > Perhaps the internal structure is incorrectly built. You must check, using for example SPOK tool on FEX until there is no longer bug in your code. > > Bruno
From: Bruno Luong on 29 Jun 2010 01:23 "Dhruv " <dhruv.singh(a)gmail.com> wrote in message <i0boss$a6j$1(a)fred.mathworks.com>... > Hi Bruno, > > Thanks for your suggestions - Can you tell me about the SPOK tool? I am not sure hwo to check the format using it... > Just call it with the sparse matrix as input. The author (Tim Davis) provides a great help file, so why not reading it to reward Tim's effort? Bruno
From: James Tursa on 29 Jun 2010 03:21 "Dhruv " <dhruv.singh(a)gmail.com> wrote in message <i0boss$a6j$1(a)fred.mathworks.com>... > Hi Bruno, > > Thanks for your suggestions - Can you tell me about the SPOK tool? I am not sure hwo to check the format using it... > > Also I find that if I try to force nnz(S) =total elements > I get a memory error - this seems strange because if the array is present and I can access it using nonzeros(S) then where are those elements stored...I am not separately freeing memory in the C++ MEX code but could that be a problem (I thought MEX engine frees it itself when it returns) Other than point you to tools like SPOK, we are not really going to be able to help you much on the newsgroup unless you post your code showing how you are building the sparse matrix. James Tursa
|
Pages: 1 Prev: Envelope detector Next: Reading Excel Data into a list box |