On 25.11.2006, at 06:17, Sebastian Haase wrote: > Just out of curiosity: Can I ask what is special about a > Geometry.Vector ? What is the difference to a normal numpy array ?
1) A Vector always has exactly three elements of type "float". 2) A Vector is immutable. 3) Only addition and substraction work like for an array, i.e. elementwise. Multiplication between vectors is the dot product, division is an error. 4) A Vector has additional methods: length, normal, cross, dyadicProduct, angle. Implementationwise, a vector object has a smaller memory footprint than an array object, at least since I reimplemented Vector in Pyrex a while ago. So why would one want to use a special Vector object rather than an array of shape (3,)? 1) Readability: the intention of the programmer is much clearer. 2) The additional methods are quite useful. 3) Safeguarding against mistakes: with arrays, additional checks for shape and element size would be needed to make code robust. 4) Performance (especially memory-wise). Konrad. -- --------------------------------------------------------------------- Konrad Hinsen Centre de Biophysique Moléculaire, CNRS Orléans Synchrotron Soleil - Division Expériences Saint Aubin - BP 48 91192 Gif sur Yvette Cedex, France Tel. +33-1 69 35 97 15 E-Mail: [EMAIL PROTECTED] --------------------------------------------------------------------- _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion