Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'extensions': 0.04; 'python.': 0.05; 'python)': 0.07; 'received:localnet': 0.07; 'python': 0.07; 'arithmetic': 0.09; 'internally': 0.09; 'stealing': 0.09; 'template.': 0.09; 'api': 0.11; 'pm,': 0.11; 'url:code': 0.11; 'wrote:': 0.14; 'andreas': 0.16; 'c/c++.': 0.16; 'downside': 0.16; 'hartley': 0.16; 'inversion': 0.16; 'maintainable': 0.16; 'module?': 0.16; 'numpy': 0.16; 'runtime.': 0.16; 'vectors': 0.16; 'compiled': 0.18; 'jonathan': 0.19; 'modules': 0.20; 'writes:': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'seems': 0.21; 'code': 0.22; 'header:In-Reply-To:1': 0.22; '(and': 0.22; 'issue,': 0.23; 'mainly': 0.24; 'looks': 0.28; 'supports': 0.29; 'are.': 0.29; 'list': 0.30; 'compiling': 0.31; 'monday': 0.31; 'to:addr:python-list': 0.32; 'project': 0.32; 'done': 0.32; 'thank': 0.32; "i've": 0.33; 'pure': 0.33; 'array': 0.33; 'operations': 0.33; "isn't": 0.34; 'reference': 0.34; 'post': 0.34; 'there': 0.35; 'tool': 0.35; 'header:User-Agent:1': 0.35; 'analysis,': 0.35; 'frame': 0.35; 'quite': 0.36; 'received:au': 0.36; 'enough': 0.37; 'some': 0.37; 'addition,': 0.37; '20,': 0.38; 'apr': 0.38; 'consistent': 0.38; 'but': 0.38; 'url:google': 0.38; 'url:org': 0.38; 'though': 0.38; 'list:': 0.39; 'url:au': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'how': 0.39; 'basic': 0.40; 'might': 0.40; 'design': 0.61; 'give': 0.61; 'header:Message-Id:1': 0.62; '2011': 0.62; 'url:p': 0.63; 'batch': 0.69; 'algebra': 0.84; 'matrix': 0.84; 'mention.': 0.84; 'penalty': 0.84; 'ultimate': 0.93 From: Algis Kabaila Organization: PCUG - Users Helping Users To: python-list@python.org Subject: Re: Vectors Date: Tue, 26 Apr 2011 21:26:33 +1000 User-Agent: KMail/1.13.5 (Linux/2.6.35-25-generic-pae; KDE/4.5.1; i686; ; ) References: <62f7ffa9-8511-42e4-8a53-a11ce8636dbe@hd10g2000vbb.googlegroups.com> In-Reply-To: <62f7ffa9-8511-42e4-8a53-a11ce8636dbe@hd10g2000vbb.googlegroups.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: Jonathan Hartley X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 61 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303817205 news.xs4all.nl 81479 [::ffff:82.94.164.166]:48699 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4033 On Monday 25 April 2011 20:49:34 Jonathan Hartley wrote: > On Apr 20, 2:43 pm, Andreas Tawn wrote: > > > Algis Kabaila writes: > > > > Are there any modules for vector algebra (three > > > > dimensional vectors, vector addition, subtraction, > > > > multiplication [scalar and vector]. Could you give me > > > > a reference to such module? > > > > > > NumPy has array (and matrix) types with support for these > > > basic operations you mention. See the tutorial > > > athttp://numpy.scipy.org/ > > > > You might also want to > > considerhttp://code.google.com/p/pyeuclid/ > > > > Cheers, > > > > Drea > > Stealing this from Casey Duncan's recent post to the Grease > users list: > > > - (ab)use complex numbers for 2D vectors (only). Very fast > arithmetic and built-in to Python. Downside is lack of > abstraction. > > - Use pyeuclid (pure python) if ultimate speed isn't an > issue, or if compiled extensions are. It supports 3D and has > a nice api > > - vectypes is a more recent project from the same author as > pyeuclid. It offers a more consistent 'GLSL' like interface, > including swizzling, and internally seems to have more > maintainable code because it generates various sizes of > vector and matrix from a single template. This is done > without performance penalty because the generation is done > at design time, not runtime. > > - Use pyeigen if you want fast vectors, and don't mind > compiling some C/C++. I don't know how the Python api looks > though > > - Use numpy if you want fast batch operations Jonathan, Thank you for a nice and extensive list of references. To clarify my position - surprisingly, speed is not an issue- I've programmed a matrix in pure python (3, but mainly iwth python 2 syntax) and found that inversion was quite fast enough for my requirements. Good vector algebra is necessary for 3 D frame analysis, so a vector package is indicated. numpy is great, but it is a tool like a sledge to drive a nail... OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf