From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84272 invoked by alias); 20 Jan 2016 18:31:55 -0000 Mailing-List: contact gsl-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sourceware.org Received: (qmail 84238 invoked by uid 89); 20 Jan 2016 18:31:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=reorder, triplets, csc, CSC X-HELO: mail-io0-f180.google.com Received: from mail-io0-f180.google.com (HELO mail-io0-f180.google.com) (209.85.223.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 20 Jan 2016 18:31:51 +0000 Received: by mail-io0-f180.google.com with SMTP id q21so29040801iod.0 for ; Wed, 20 Jan 2016 10:31:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=yWz1AikAAn/4ii6tCGxJ0g3JivhBB8BWpLL48AyUFzE=; b=lNxlrH9UicCYIVi2Ybt0rvoB7jGbypKD02QXIydaIIGA/GwvUixksNnl/9nBiEM+I2 WCT+ZR24NdUEVWbcyXVu7N63NcaQxRg/wnrf0Di684h3xlB6mhlzgIygsREGI8eLYs2p /JB9RgLYBApiylbBaN8x/Ky3fpA/LGpCiEgpSt0PFaQnjdyf5tbJOD8pw227PSokoRzb IhPQ+3abEsMRRQFrKknXDm/N1iLsTuNfdKtt5AG9Q1bZM1aF7EEknf0q7vQabLCv5F4l 8017COMALLRBzzX7p1Rf+8ExuQZCtaZ1k8fZAxdTLQO9eVMjWljI/vF9rort6f6pPkTU RGkQ== X-Gm-Message-State: ALoCoQlKqpcpSUoFlm2Uzj9beVwGyhFgxgTr2Mec/Qfg0MTniaRBZMg6QDKxWFXQLeVFGoJHDM3il9ezN05lekGuIVFfhSMrnw== MIME-Version: 1.0 X-Received: by 10.107.9.6 with SMTP id j6mr35099902ioi.6.1453314709604; Wed, 20 Jan 2016 10:31:49 -0800 (PST) Received: by 10.79.118.156 with HTTP; Wed, 20 Jan 2016 10:31:49 -0800 (PST) In-Reply-To: <569EA1A9.2080101@colorado.edu> References: <569E6C33.1090505@colorado.edu> <569EA1A9.2080101@colorado.edu> Date: Wed, 20 Jan 2016 18:31:00 -0000 Message-ID: Subject: Re: Sparse matrix extension From: Alexis Tantet To: Patrick Alken Cc: "gsl-discuss@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-q1/txt/msg00004.txt.bz2 Hi Patrick, I've cloned gsl.git, made my modifications to spmatrix/ and spblas/ and pushed them to master at: https://github.com/atantet/gsl This time, I've tried to modify the code as little as possible. I've usually added comments labelled "AT" with each modification. I also have a few questions about the code which I've labelled "?AT". Finally, I've added the corresponding tests to both test.c (successful on my machine). I see that duplicates are handled for the triplet format by replacing. Thus, I removed the function taking care of sorting and summing duplicates that I had added to _compress (the trick was to transpose with copy to reorder first, transpose back and remove the duplicates then, taken from Eigen C++). Instead, I have added an option to sum the duplicates (useful e.g. when counting links of a graph or transitions of a Markov chain). One may need the third option of repeating the triplets, but then avl_insert should also be modified. However, if I've understood well, no sorting of the inner indices is performed right now. This could be problematic in the future (e.g. in functions such as _equal). For _spdgemm for CRS matrices, I've used the trick (A B)^t = B^t A^t to convert the problem to CSC. I've tested it successfully but you may not like the coding style. I hope that helps, Best, Alexis On Tue, Jan 19, 2016 at 9:50 PM, Patrick Alken wrote: > > > On 01/19/2016 12:55 PM, Alexis Tantet wrote: >> >> Hi Patrick, >> >> Thanks for the quick reply! I wanted to be sure that this contribution >> is useful before to spend time on the merging with the latest version. >> I will create the gsl.git repository and work on it during the week. >> >> I had already had a look at the documentation but did not know about >> the iterative solvers (a link between each modules would be useful). >> My contribution indeed fits in the sparse matrix module + the update >> of the dgemm and dgemv functions to support CRS (an update may also be >> needed for the solvers). > > > The solvers only call dgemv (as far as I remember) so they shouldn't need an > update once dgemv is updated. > >> >> I have also developed a simple C++ object allowing to use gsl_spmatrix >> as a user-defined matrix in ARPACK++ (a maintained fork of ARPACK++ >> can be found at https://github.com/m-reuter/arpackpp), allowing to >> avoid having to use other libraries such as superLU. It could be >> useful to others, maybe as an extension. Now that I think about it, >> the iterative solvers could also be used to support the shift and >> invert modes (see ARPACK++ documentation). What do you think (I could >> work on it)? > > I've never used ARPACK, but if you want to make an extension to interface > GSL/ARPACK its fine with me - such an extension would never be added to the > main GSL code since GSL tries to be as standalone as possible. > > >> >> If you have major comments, the sooner the better, so that I can work >> on them while merging. >> >> Thank you for your interest, >> Alexis >> >> On Tue, Jan 19, 2016 at 6:02 PM, Patrick Alken wrote: >>> >>> Hi Alexis, >>> >>> This looks like very good work! Adding compressed row storage has been >>> on >>> my todo list for a while. The 'gslsp' extension is unfortunately very out >>> of >>> date, and the current git contains newer code (including a GMRES >>> iterative >>> linear solver). I removed the gslsp extension from the web page a while >>> back >>> to reflect this. You can browse the latest manual to see the current >>> sparse >>> matrix capabilities (http://www.gnu.org/software/gsl/manual/gsl-ref.pdf) >>> - >>> there are 3 chapters: sparse matrices, sparse blas and sparse linear >>> algebra >>> - it looks like your contributions will fit into the sparse matrices >>> chapter. >>> >>> Would you be able to verify that your changes are compatible with the >>> current gsl.git repository? This will make it much easier for me to merge >>> everything into the git when ready. It would be best if you made a new >>> branch of gsl.git, and add your changes so I can then pull them from >>> github >>> or somewhere. I will try to find some time in the next few days to look >>> over >>> your code. >>> >>> Thanks again, >>> Patrick >>> >>> >>> On 01/19/2016 09:43 AM, Alexis Tantet wrote: >>>> >>>> Dear GSLers, >>>> >>>> As a scientist rather than a developer, I have developed an extension >>>> of the sparse matrix module (CRS, I/O, manipulation, see below), which >>>> I have tested. These modifications conserve the structure of the >>>> original module and be useful for a large number of sparse matrices >>>> users. >>>> >>>> I'm not familiar with the contributing process here. My repository can >>>> be found there: >>>> https://github.com/atantet/gslsp >>>> Unfortunately, I did not know of the gsl.git repository and I forked it >>>> froml: >>>> https://github.com/drjerry/gslsp , >>>> which seems to be a bit older than gsl.git. >>>> >>>> How can I push/merge to gsl.git ? Should it be as an update or another >>>> extension? Is it necessary to adapt to the newest version of the code >>>> ? >>>> >>>> Best regards, >>>> Alexis Tantet >>>> >>>> CHANGES.md: >>>> >>>> Extension of the sparse matrix module of GSL >>>> >>>> =================================== >>>> >>>> Introduction >>>> ------------ >>>> >>>> Usages of sparse matrices are numerous in scientific computing. >>>> When numerical linear algebra problems become large, sparse >>>> matrices become necessary to avoid memory overload and unnecessary >>>> computations, at the cost of element access and matrix construction. >>>> As a result, most large scale linear solvers or eigen solvers perform >>>> on sparse matrices. >>>> >>>> Fortunately, a very useful sparse matrix module has recently been >>>> introduced to GSL. >>>> However, important features are still lacking, such has >>>> Compressed Row Storage (CRS) matrices, input/output functions and >>>> other matrix properties and manipulation functions. >>>> This new version attempts to address this, conserving the original >>>> structure of the module and conventions. >>>> >>>> Major changes >>>> ------------- >>>> >>>> * Add CRS format and update functions manipulating compressed matrices : >>>> - additional flag GSL_SPMATRIX_CRS and macro GSLSP_ISMATRIX ( >>>> gsl_spmatrix.h ) >>>> - additional members innerSize and outerSize used to iterate >>>> matrix elements ( gsl_spmatrix.h ) >>>> - rename some variables for coherence ( gsl_spmatrix.h , *.c ) >>>> - update all functions on compressed matrices ( *.c ) >>>> * Allow to sum duplicate elements when compressing ( spcompress.c ) : >>>> - modify gsl_spmatrix_compress >>>> - add gsl_spmatrix_sum_duplicate >>>> * CCS <-> CRS and fast transpose inplace in spswap.c : >>>> - add gsl_spmatrix_switch_major >>>> - add gsl_spmatrix_transpose >>>> * Add printing and scanning functions in spio.c : >>>> - add gsl_spmatrix_fprintf >>>> - add gsl_spmatrix_fscanf >>>> * Add manipulation functions in spmanip.c (particularly useful for >>>> Markov chain transition matrices) : >>>> - add gsl_spmatrix_get_rowsum : get vector of sum over row >>>> elements >>>> - add gsl_spmatrix_get_colsum : get vector of sum over column >>>> elements >>>> - add gsl_spmatrix_div_rows : divide all elements of each row >>>> by a vector element >>>> - add gsl_spmatrix_div_cols : divide all elements of each >>>> column by a vector element >>>> * Add test functions in atprop.c : >>>> - add gsl_spmatrix_gt_elements : greater than test for each >>>> matrix >>>> element >>>> - add gsl_spmatrix_ge_elements : greater or equal than test for >>>> each matrix element >>>> - add gsl_spmatrix_lt_elements : lower than test for each matrix >>>> element >>>> - add gsl_spmatrix_le_elements : lower or equal than test for >>>> each matrix element >>>> - add gsl_spmatrix_any : test if any non-zero element in >>>> matrix >>>> >>>> Other minor changes have been made, such as error tests. >>>> test.c has also been updated to test new features. >>> >>> >> >> > -- Alexis Tantet