in reply to Re: How to vector
in thread How to vector
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to vector
by salva (Canon) on Jun 19, 2015 at 20:54 UTC | |
| [reply] |
by Aldebaran (Curate) on Jun 20, 2015 at 00:46 UTC | |
salva, you seem clearly to understand higher math, but this is a 2-sentence contradiction, because the cpan module uses arrays and perl, and achieves what you claim can't be attained. What I think you mean to say is that many of the functions one would need to do vector manipulations are not native to perl, so one would have to write them from scratch. There's always a set of trade-offs with using cpan as opposed to rolling your own. One is that one has to be able to read and use the module effectively, and this exercise gave me the opportunity to dink around with this module for the first time. A difficult matter in this is understanding how the references and dereferencing work, and I wrote a script to help myself--maybe OP as well--understand how perl implements vector math:
I always keep a a routine for printing an array of arrays in my grab bag of utilities. It accepts a reference to the AoA and prints it out element-wise. Crucial for debugging. I didn't use the following line from the original, simply because I couldn't jimmy with it enough to get it to work for me:
I had to feel my way through the data, seeing first that @data contained references, and then looping through them with a structure that I was able to read. I noticed that your data has an unwanted empty line at the top and removed it. Here's the output:
One can see that vect and vector are equivalent representations. versor, however is not a feature one would have out of the box without the inclusion of the module. It wouldn't be hard to write, but the module will give a person much more functionality than this trivial work-up. | [reply] [d/l] [select] |
by salva (Canon) on Jun 20, 2015 at 05:24 UTC | |
this is a 2-sentence contradiction, because the cpan module uses arrays and perl, and achieves what you claim can't be attained. What I think you mean to say is that many of the functions one would need to do vector manipulations are not native to perl, so one would have to write them from scratch. What I meant (and what I think the OP was actually asking) is that raw arrays can't, for instance, be used in the following way:
| [reply] [d/l] |
|
Re^3: How to vector
by pme (Monsignor) on Jun 20, 2015 at 09:40 UTC | |
| [reply] |
|
Re^3: How to vector
by Aldebaran (Curate) on Jun 19, 2015 at 20:56 UTC | |
You posted an example of just that this last week. Unlike hashes, arrays are ordered, so they can fit this bill. A typical Pythagorean triple might be @a = (2,3,7);. There has to be an origin: @o=(0,0,0);. One way this differs from typical mathematical treatments is that the indices begin with zero, but all that requires is that you be consistent. One thing you can't have are strings in your vector so this: @d=(8,7,dog); will never be a vector. Hope this helps. | [reply] [d/l] [select] |