From: gorkiana m. <gor...@gm...> - 2008-06-23 09:15:08
|
Dominique, Yes, I noticed that, I also made some changes because it asked numerix which was inside Fipy. Thank you. But yet I could not use it. Nevertheless I managed to solve my problem during this weekend. Basically pysparse.spmatrix.ll_mat objects have two methods: keys() and values() With this two it is possible to do what I want. This is what I did: A = pysparse.spmatrix.ll_mat(10,10) # a 10 x 10 sparse matrix X = numpy.arange(0,10) # a dense vector of length 10 A[0,1] = 10; A[0,2] = 10; A[0,3] = 10 To add the first row of A to X one just needs to do the following: A_indices = numpy.array(A[0,:].keys())[:,1] # keys is a list of tuples, so converting to numpy.array yelds a matrix # the first column is the row index and the second column the column index # we just need the column index # we get a vector with the indices where A has nonzero values at row 0 A_values = numpy.array(A[0,:].values()) # the nonzero values of row 0 X[A_indices] = X[A_indices] + A_values Simple! Thank you very much Dominique and Daniel for your help. Probably I will have more looks at FiPy because I will have more problems for sure! -artur palha On Sat, Jun 21, 2008 at 2:58 PM, Dominique Orban <dom...@gm...> wrote: > Artur, > > On top of the file that Daniel sent, you also need sparseMatrix.py > which you can download from the repository Daniel mentioned earlier. I > also attach it below. > > Good luck, > Dominique > > On Fri, Jun 20, 2008 at 10:09 AM, Daniel Wheeler > <dan...@gm...> wrote: > > On Fri, Jun 20, 2008 at 6:50 AM, Artur Palha <art...@gm...> > wrote: > >> Thank you for your help Daniel > > > > No problem. > > > >> I have downloaded it but it is asking for more modules from your > project. > > > > Yes. I realized that Dominique Orban created a version of this that > > works with pysparse alone. See attachment. It really needs to be > > integrated into pysparse properly. I just haven't had a chance yet. > > > >> I will try to have a look and see if I can do something based on what > >> you did. In the meantime I will also have a look a pyTrilinos. > > > > Try scipy as well. > > > > -- > > Daniel Wheeler > > > > ------------------------------------------------------------------------- > > Check out the new SourceForge.net Marketplace. > > It's the best place to buy or sell services for > > just about anything Open Source. > > http://sourceforge.net/services/buy/index.php > > _______________________________________________ > > Pysparse-users mailing list > > Pys...@li... > > https://lists.sourceforge.net/lists/listinfo/pysparse-users > > > > > |