From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11383 invoked by alias); 28 Jan 2014 20:45:48 -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 11363 invoked by uid 89); 28 Jan 2014 20:45:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 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 20:45:46 +0000 From: Patrick Alken Received: from bonanza.ngdc.noaa.gov ([140.172.179.41]) by smtp.colorado.edu with ESMTP/TLS/DHE-RSA-AES256-SHA; 28 Jan 2014 13:45:46 -0700 Message-ID: <52E816F8.9050405@colorado.edu> Date: Tue, 28 Jan 2014 20:45: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> <52E71EC5.800@colorado.edu> In-Reply-To: <52E71EC5.800@colorado.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2014-q1/txt/msg00021.txt.bz2 The functions gsl_vector_inc and gsl_matrix_inc are now in the git repository to accomplish this On 01/27/2014 08:06 PM, Patrick Alken wrote: > 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