in reply to Re^2: How to vector
in thread How to vector
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to vector
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] |