From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21845 invoked by alias); 28 Jan 2014 03:06:49 -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 21823 invoked by uid 89); 28 Jan 2014 03:06:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: ipmx5.colorado.edu Received: from ipmx5.colorado.edu (HELO ipmx5.colorado.edu) (128.138.128.235) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Jan 2014 03:06:47 +0000 From: Patrick Alken Received: from 71-33-172-96.hlrn.qwest.net (HELO [192.168.0.226]) ([71.33.172.96]) by smtp.colorado.edu with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 27 Jan 2014 20:06:45 -0700 Message-ID: <52E71EC5.800@colorado.edu> Date: Tue, 28 Jan 2014 03:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "gsl-discuss@sourceware.org" Subject: Re: increment a single element of matrix/vector References: <52E6EFF3.1000808@colorado.edu> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-q1/txt/msg00020.txt.bz2 On 01/27/2014 07:14 PM, Rhys Ulerich wrote: >> *gsl_vector_ptr(v, i) += x > > Of course, make sure warnings about expressions without side effects > are turned on. Otherwise it may be a long debugging session before > you discover a > > gsl_vector_ptr(v, i) += x > > mistake for integer-like types. > > - Rhys > Nice find - unfortunately since it returns a pointer to the element, you need to do: *(gsl_vector_ptr(v, i)) += x; This could lead to trouble so its probably better to have a function which does range checking, etc. I'll think a little more on a good way to do this. Thanks, Patrick