From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21819 invoked by alias); 28 Jan 2014 02:08:58 -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 21807 invoked by uid 89); 28 Jan 2014 02:08:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f42.google.com Received: from mail-wg0-f42.google.com (HELO mail-wg0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 28 Jan 2014 02:08:56 +0000 Received: by mail-wg0-f42.google.com with SMTP id l18so5108133wgh.5 for ; Mon, 27 Jan 2014 18:08:53 -0800 (PST) X-Received: by 10.194.79.131 with SMTP id j3mr22180562wjx.17.1390874933504; Mon, 27 Jan 2014 18:08:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.60.137 with HTTP; Mon, 27 Jan 2014 18:08:32 -0800 (PST) In-Reply-To: <52E6EFF3.1000808@colorado.edu> References: <52E6EFF3.1000808@colorado.edu> From: Rhys Ulerich Date: Tue, 28 Jan 2014 02:08:00 -0000 Message-ID: Subject: Re: increment a single element of matrix/vector To: Patrick Alken Cc: "gsl-discuss@sourceware.org" Content-Type: text/plain; charset=ISO-8859-1 X-SW-Source: 2014-q1/txt/msg00018.txt.bz2 > I was thinking of adding two routines to GSL, to increment a single element > of a matrix or vector by some amount, since I'm always doing things like: > > gsl_vector_set(v, i, gsl_vector_get(v, i) + x); > > which I think is ugly and annoying.... Agreed. This has often bugged me. > Or also is there another solution to this problem that I don't know about? How about using INLINE_DECL double * gsl_vector_ptr (gsl_vector * v, const size_t i); to say *gsl_vector_ptr(v, i) += x ? Never knew about this until I just went fishing for it. - Rhys