Re: Vectors
On Monday 25 April 2011 20:49:34 Jonathan Hartley wrote: On Apr 20, 2:43 pm, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Monday 25 April 2011 12:59:38 rusi wrote: On Apr 25, 4:49 am, Robert Kern robert.k...@gmail.com wrote: On 4/22/11 7:32 PM, Algis Kabaila wrote: On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabailaakaba...@pcug.org.au wrote: 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 Or one of these libraries (ctypes or Cython): BLAS (Intel MKL, ACML, ACML-GPU, GotoBLAS2, or ATLAS) Intel VML ACML-VM Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile if it is unavoidable, but in case of numpy it does not seem a simple matter. Am I badly mistaken? On UNIX machines with compilers and headers properly installed, it's really pretty straightforward. Mostly (on ubuntu/debian) that means do this [Untested] $ aptitude build-dep python-numpy Then you should be ready to build/compile numpy from source Thank you, Robert and Rusi, I will try it RSN, but first the latest version of ubuntu that should become available this week (including today?!). OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Apr 20, 2:43 pm, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On 4/22/11 7:32 PM, Algis Kabaila wrote: On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabailaakaba...@pcug.org.au wrote: 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 Or one of these libraries (ctypes or Cython): BLAS (Intel MKL, ACML, ACML-GPU, GotoBLAS2, or ATLAS) Intel VML ACML-VM Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile if it is unavoidable, but in case of numpy it does not seem a simple matter. Am I badly mistaken? On UNIX machines with compilers and headers properly installed, it's really pretty straightforward. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Apr 25, 4:49 am, Robert Kern robert.k...@gmail.com wrote: On 4/22/11 7:32 PM, Algis Kabaila wrote: On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabailaakaba...@pcug.org.au wrote: 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 Or one of these libraries (ctypes or Cython): BLAS (Intel MKL, ACML, ACML-GPU, GotoBLAS2, or ATLAS) Intel VML ACML-VM Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile if it is unavoidable, but in case of numpy it does not seem a simple matter. Am I badly mistaken? On UNIX machines with compilers and headers properly installed, it's really pretty straightforward. Mostly (on ubuntu/debian) that means do this [Untested] $ aptitude build-dep python-numpy Then you should be ready to build/compile numpy from source -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Saturday 23 April 2011 14:13:31 sturlamolden wrote: On Apr 23, 2:32 am, Algis Kabaila akaba...@pcug.org.au wrote: Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile if it is unavoidable, but in case of numpy it does not seem a simple matter. Am I badly mistaken? There is a Win32 binary for Python 3.1: http://sourceforge.net/projects/numpy/files/NumPy/1.5.1/ I have not tried to compile NumPy as I use Enthought to avoid such headaches. I value my own time enough to pay for a subscription ;-) http://enthought.com/ Sturla Whilst I have Win32 officially paid for OS, never fire it up. I find nix systems much more interesting and convenient for programming and consequently I use ubuntu for computing activities. I do understand that many people prefer Win32 and appreciate their right to use what they want. I just am at a loss to understand *why* ... I guess each to own taste, OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Apr 23, 2:26 pm, Algis Kabaila akaba...@pcug.org.au wrote: I do understand that many people prefer Win32 and appreciate their right to use what they want. I just am at a loss to understand *why* ... For the same reason some people prefered OS/2 or DEC to SunOS or BSD. For the same reason some people prefer Perl or Java to Python. Sturla -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Friday 22 April 2011 11:43:26 Gregory Ewing wrote: Algis Kabaila wrote: the Vector3 class is available without any prefix euclid: import euclid v = Vector3(111.., 222.2, 333.3) Doesn't work that way for me: Python 2.7 (r27:82500, Oct 15 2010, 21:14:33) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type help, copyright, credits or license for more information. import euclid Vector3 Traceback (most recent call last): File stdin, line 1, in module NameError: name 'Vector3' is not defined Are you sure you hadn't previously done 'from euclid import Vector3' or 'from euclid import *' in that session? I've tested it again and it does behave in a standard manner. I must have imported all as you suspected. Makes me much happier, though I do feel sheepish. As they say, sh... happens. BTW, I did modify the euclid very slightly to work with Python 3 - just change the syntax of messages with exception in line with syntax changes. Thanks for sharing your experience with that cute package! OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Apr 20, 9:47 am, Algis Kabaila akaba...@pcug.org.au wrote: 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 Or one of these libraries (ctypes or Cython): BLAS (Intel MKL, ACML, ACML-GPU, GotoBLAS2, or ATLAS) Intel VML ACML-VM -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabaila akaba...@pcug.org.au wrote: 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 Or one of these libraries (ctypes or Cython): BLAS (Intel MKL, ACML, ACML-GPU, GotoBLAS2, or ATLAS) Intel VML ACML-VM Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile if it is unavoidable, but in case of numpy it does not seem a simple matter. Am I badly mistaken? euclid has another attraction - the source is readily available, not too burdened by backward compatibility issues and relatively easy to follow, though I managed to get lost in it :) OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Apr 23, 2:32 am, Algis Kabaila akaba...@pcug.org.au wrote: Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile if it is unavoidable, but in case of numpy it does not seem a simple matter. Am I badly mistaken? There is a Win32 binary for Python 3.1: http://sourceforge.net/projects/numpy/files/NumPy/1.5.1/ I have not tried to compile NumPy as I use Enthought to avoid such headaches. I value my own time enough to pay for a subscription ;-) http://enthought.com/ Sturla -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Thursday 21 April 2011 01:49:57 Andreas Tawn wrote: On Apr 20, 6:43 am, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au 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 Pyeuclid docs don't mention dot or cross products. RJB http://partiallydisassembled.net/euclid/vector-classes.html#S ECTION00222 Bottom of the page. Cheers, Drea Yes, pyeuclid had cross and dot product of vectors. I am impressed with it and curious how it works: the Vector3 class is available without any prefix euclid: import euclid v = Vector3(111.., 222.2, 333.3) works without requiring as in: v = euclid.Vector3( etc...) I am really intrigued by that. OTOH, I also am somewhat aprehensive about using something that affects the program writing after importing euclid, without any need to explicitly refer to euclid. Looks rather risky to me. What does that do to the namespace? Thanks for bringing this to my attention. I confess that I would be hapier if euclid was accessible in a standard manner with prefix of module name for classes in the module. OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
Andreas Tawn andreas.t...@ubisoft.com writes: You might also want to consider http://code.google.com/p/pyeuclid/ Thanks, I was studying quaternions recently and had to use two packages to get some stuff done. And of course one of them used ass-backwards declaration for a quaternion and one didn't... -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
Algis Kabaila wrote: the Vector3 class is available without any prefix euclid: import euclid v = Vector3(111.., 222.2, 333.3) Doesn't work that way for me: Python 2.7 (r27:82500, Oct 15 2010, 21:14:33) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type help, copyright, credits or license for more information. import euclid Vector3 Traceback (most recent call last): File stdin, line 1, in module NameError: name 'Vector3' is not defined Are you sure you hadn't previously done 'from euclid import Vector3' or 'from euclid import *' in that session? -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Wed, Apr 20, 2011 at 12:47 AM, Algis Kabaila akaba...@pcug.org.au wrote: Hi, 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? Dunno if it has 3D-specific features, but NumPy is the gold standard for matrix-y stuff in Python: http://numpy.scipy.org/ And apparently it's even Python 3.1-compatible now; that's quite a feat. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
Algis Kabaila akaba...@pcug.org.au 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 at http://numpy.scipy.org/ -- http://mail.python.org/mailman/listinfo/python-list
RE: Vectors
Algis Kabaila akaba...@pcug.org.au 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 at http://numpy.scipy.org/ You might also want to consider http://code.google.com/p/pyeuclid/ Cheers, Drea -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Apr 20, 6:43 am, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au 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 Pyeuclid docs don't mention dot or cross products. RJB -- http://mail.python.org/mailman/listinfo/python-list
RE: Vectors
On Apr 20, 6:43 am, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au 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 Pyeuclid docs don't mention dot or cross products. RJB http://partiallydisassembled.net/euclid/vector-classes.html#SECTION00222 Bottom of the page. Cheers, Drea -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors in Visual Python
Thanks for all your help everyone, if only it had addressed what I had asked I may have actually learned something about Python!! If anything was addressed to my problem then it has completely passed me by as most points were clearly made by a computer scientist and I am not one of those in the slightest. My experience of using any type of programming language is limited to the little we are taught in my non-computing subject and hence I have no idea what the below is all about!! In future example code may be more useful to help newbies like me :) That ``speciufication'' (sic) is no more ``a declaration'' than any other parameter you can pass to a constructor (or any other factory callable). -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors in Visual Python
Arthur [EMAIL PROTECTED] wrote: thinking that the visciousness with wihich you were attacking someone suggesting a proposal for an optional feature - even if an iill adivised proposal for and ill advised optional feature (I frankly don't care much about that part of the discussion one way or another) While in my case it's essentially ALL that I care about in this discussion: the technical aspects of Python. - was unwarranted, and more importantly *unwise* for someone in a If, like you, I didn't care about the technical aspects of Python, it sure would be unwise to get upset -- I could let the language go to hell in a handbasket, as long as I made sure I looked good myself. Caring deeply and passionately about something greater than oneself, particularly something which may seem dry and abstract to those who don't care a whit for it, might no doubt be deemed intrinsically unwise -- and yet, there is much to be said for such passion. Without the ability to get passionate and inflamed, we might perhaps be wiser, but we'd be Vulcans, not humans. Moreover, unless some of us felt such passion for certain technical issues, you guys who don't care would not get the benefits of the time and energy we freely devote to them -- so it's unwise, even from a strictly selfish viewpoint, to try to turn us firebrands into such coolly calculating Vulcans. postion of community leadership - considering past, recent, and undoubtedly future issues that have and will arise. What don't *you* understand about that?? Could you _really_ believe, considering the many years of consistent history of my posts on this group, that by reviving the issue you could get *any* other effect but fanning the flames all over again? THAT is what I don't understand: whether you're doing that _deliberately_, or out of almost-unbelievable levels of cluelessness. We all have are own kinds of stupidities, it seems to me. This is no doubt the case. For example, many of us instinctively brake and swerve when a small animal jumps into the road in front of the car they're driving, seriously endangering themselves and the passengers thereby. If we were presented the issue in a context giving us time to reflect and react rationally -- To how much danger to life and limb would you subject yourself, your wife, and your children, to increase the likelihood of survival for some stupid cat who can't wait to cross the road? -- we'd probably react quite differently. And yet, while it IS objectively stupid to behave that way, it _is_ one of the stupidities that make us human. A _deliberate_ and consistent preference can be disagreed with, but it's pretty pointless to call it stupid or unwise; there is just no accounting for tastes. If you _prefer_ the flame about declarations to continue for its own sake (or because you believe it makes you look good, whatever), while not caring about its contents, I may consider that evil and hateful, but it's neither intelligent nor stupid _per se_. If your preferences are otherwise, and yet your behavior is easily seen to be such as to have that effect, then THIS is indeed very stupid. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors in Visual Python
Arthur [EMAIL PROTECTED] wrote: is that VPython vectors are in effect flat 3 element Numeric arrays, and Numeric ararys can be constructed with Float64 specified as the datatype. (wonder if that speciufication is a declaration, and if so whether that would indicate some conflict between Python's ideology (Alex's version) and that of its defacto standard numerical processing library - but I digress) . That ``speciufication'' (sic) is no more ``a declaration'' than any other parameter you can pass to a constructor (or any other factory callable). I find it hard to believe that this can be less than totally, entirely, and utterly obvious to anybody with a 3-digits IQ. Trying to subdivide the issue into sub-issues that I hope will be pretty obvious even for most 2-digits IQs...: I can pass parameters when I call something -- do you think ``that's a declaration''?! Some of the calls I perform build and return new objects -- do you REALLY think ``that's a declaration''?! Obviously, the parameters I pass will normally affect the results of my calls -- do you TRULY, SERIOUSLKY think ``that's a declaration''?! *WHAT ON EARTH* could *POSSIBLY* make you wonder if any of these aspects make a perfectly ordinary executable statement into what's instead ``a declaration''?!?! Please clarify if you were making a lame joke without smilies, are utterly confused about what declaration *MEANS*, or what other folly prompted you to this astounding remark, thanks. Having found out how to build a lasting killfile, I'd like to see if using it liberally on people who appear to post here just to provoke flamewars, rather than to offer and receive help, and participate in interesting discussion, can make the newsgroup decently usable to me again. It's a pity that any newbie reading the group will be confused and damaged by tons of unchallenged idiocies posted there by large number of fools, but, ah well, I can't fix that, obviously -- I can just hope and trust that the fools' karma suffers in proportion to the stupid harm they inflict. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors in Visual Python
Terry Reedy [EMAIL PROTECTED] wrote: I (and I believe Alex) object to name declaration *statements* and/or the strong typing of *names*. I confirm that my key objection is to declarations in the strict sense: thingies that aren't executable, but rather billets doux to the compiler, for example to affect its treatment of barenames. I (and I believe Alex) approve of the strong typing of *objects*, which Absolute and unqualified agreement on this point, yes. must somehow be indicated in the object creation *expression*. This is absolutely fundamental to Python. There are at least three ways to indicate the desired object type: literal type, constuctor (and other function) identity, and constructor (and other function) arguments. And yes to all of this, as well. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors in Visual Python
On Thu, 10 Feb 2005 00:16:05 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: Arthur [EMAIL PROTECTED] wrote: Please clarify if you were making a lame joke without smilies, are utterly confused about what declaration *MEANS*, or what other folly prompted you to this astounding remark, thanks. Interesting pedagogical technique all-in-all Mr. Martelli. What point is there in trying to help you understand the basis of my confusion, if my confusion is nothing more than a point of ridicule. I know exactly what declaration is - a fucking word, nothing more nothing less. Art -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors in Visual Python
On Thu, 10 Feb 2005 00:16:05 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: Having found out how to build a lasting killfile, I'd like to see if using it liberally on people who appear to post here just to provoke flamewars, rather than to offer and receive help, and participate in interesting discussion, can You are an accomplished provocateur. It is true that I joined the variable declaration discussion without the intent of offering or receiving help. I joined it actually to try to make a point that I thought was community spirited - thinking that the visciousness with wihich you were attacking someone suggesting a proposal for an optional feature - even if an iill adivised proposal for and ill advised optional feature (I frankly don't care much about that part of the discussion one way or another) - was unwarranted, and more importantly *unwise* for someone in a postion of community leadership - considering past, recent, and undoubtedly future issues that have and will arise. What don't *you* understand about that?? We all have are own kinds of stupidities, it seems to me. Art -- http://mail.python.org/mailman/listinfo/python-list