From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1088 invoked by alias); 22 May 2008 11:34:59 -0000 Received: (qmail 1078 invoked by uid 22791); 22 May 2008 11:34:58 -0000 X-Spam-Check-By: sourceware.org Received: from mail21.bluewin.ch (HELO mail21.bluewin.ch) (195.186.18.66) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 22 May 2008 11:34:24 +0000 Received: from [192.168.1.38] (85.0.150.139) by mail21.bluewin.ch (Bluewin 7.3.121) id 480C94D60060F85F; Thu, 22 May 2008 11:35:08 +0000 Subject: Re: RFC bit_vectors From: Ivo Alxneit Reply-To: ivo.alxneit@psi.ch To: Brian Gough Cc: gsl-discuss@sourceware.org In-Reply-To: <87mymi937v.wl%bjg@network-theory.co.uk> References: <1211361194.31910.9.camel@pc6411.psi.ch> <87mymi937v.wl%bjg@network-theory.co.uk> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-bA7JkUdG0NgCZKnspAvV" Date: Thu, 22 May 2008 11:34:00 -0000 Message-Id: <1211456026.3010.35.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-4.fc8) 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 X-SW-Source: 2008-q2/txt/msg00027.txt.bz2 --=-bA7JkUdG0NgCZKnspAvV Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Content-length: 2050 On Thu, 2008-05-22 at 09:01 +0100, Brian Gough wrote: > At Wed, 21 May 2008 11:13:14 +0200, > Alxneit-Kamber Ivo wrote: > > attached please find an implementation of 'bit_vectors' (maybe bit > > fields would be a better name) that might be an interesting addition to > > GSL. 'bit_vectors' can be used similarly like a C bit field, only that > > they grow and shrink dynamically depending on the number of bits in use. > > Currently the user is limited to 'maximum(size_t)' bits (the bit number > > is passed as size_t) or by the amount of memory available. Note, > > however, that memory for all bits does not necessarily need to be > > allocated because high bits that are either all 1 or 0 are stored as a > > single implied bit. >=20 > Hello, >=20 > Did you have a specific use in mind? This is probably more suited to > a general C library rather than scientific library.=20=20 >=20 well, i used bit_vectors "to keep track of information". i had a global gsl_vector, some of its elements shared among different (only a few) objects. because each object would access "most" of the elemets of the gsl_vector it was much cheeper to use one bit_vector per object to keep track of the information needed than to use one gsl_vector per object. the gsl_vector was dynamically growing and became very large (~1GB). so i ended up with code like=20 res=3D0.0; for(i=3D0; i< n; i++) res +=3D gsl_vector_get(v,i)*bit_vector_test(bv,i); to only sum the contribution of object bv. the read/write/print was used mainly for debugging. some of the logical operators were used in situations to find elements shared by a group of objects or unique to a certain object. shift was implemented just for fun. bit_vector are probaly not suited to do math of very large integers (like 2048 bit numbers). regards --=20 Dr. Ivo Alxneit Laboratory for Solar Technology phone: +41 56 310 4092 Paul Scherrer Institute fax: +41 56 310 2688 CH-5232 Villigen http://solar.web.psi.ch Switzerland gnupg key: 0x515E30C7 --=-bA7JkUdG0NgCZKnspAvV Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part Content-length: 189 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBINVoUAd7CE1FeMMcRAnsxAKCpmrRg9OA9afb/9IpHbjQ2lrLx3QCePg/d biNuRIqlhjZOUq9YTDACib8= =1FtZ -----END PGP SIGNATURE----- --=-bA7JkUdG0NgCZKnspAvV--