Is there a command for vector sum in User RPL? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Is there a command for vector sum in User RPL? (/thread-1379.html) |
Is there a command for vector sum in User RPL? - HP67 - 05-22-2014 09:29 AM The sigmaLIST command is handy. Is there a vector sum command when operating on vectors? If not, is there a best-practice for this? RE: Is there a command for vector sum in User RPL? - Thomas Klemm - 05-22-2014 12:29 PM (05-22-2014 09:29 AM)HP67 Wrote: Is there a vector sum command when operating on vectors? Not sure whether this is what you are looking for: Code: \<< DUP 1 CON DOT \>> Example: [ 1 2 3 4 5 6 7 8 9 ] -> 45 Cheers Thomas RE: Is there a command for vector sum in User RPL? - HP67 - 05-22-2014 12:44 PM Thanks. I am surprised this isn't included. It seems like it should be. RE: Is there a command for vector sum in User RPL? - Thomas Klemm - 05-22-2014 01:08 PM (05-22-2014 12:44 PM)HP67 Wrote: I am surprised this isn't included. It's easy to create a list with the elements of a vector: Code: \<< OBJ\-> OBJ\-> DROP \->LIST \GSLIST \>> Thus the building blocks are there. You can't blame the developers that they didn't include all combinations. Why is 3PICKSWAP missing in UserRPL but you can find it in SysRPL? Cheers Thomas RE: Is there a command for vector sum in User RPL? - rprosperi - 05-22-2014 01:26 PM (05-22-2014 01:08 PM)Thomas Klemm Wrote: Thus the building blocks are there. You can't blame the developers that they didn't include all combinations. Indeed, you can use Thomas' code, name it MYVECSUM, and 'POOF' it is now inlcuded. And as Thomas notes, as you start to explore SysRPL, you will find that they did include just about every combination stack manipulation sequence into a new command that you can imagine. Plus a whole bunch you can't imagine. There are some that are so obscure I have struggled to imagine there were enough similar stack juggling scenarios to justify introducing a new command. A simple stupid example: there is ROM word for the number 53. Could the number 53 really have been used enough times to justify creating that, just to save a few nibs when it's needed? Nevertheless, I still bow to those guys... "I'm not worthy" RE: Is there a command for vector sum in User RPL? - HP67 - 05-22-2014 01:32 PM (05-22-2014 01:08 PM)Thomas Klemm Wrote: Thus the building blocks are there. That is not what I am saying. By your argument all they had to do was supply a basic set of commands from which all other commands could be coded by the user. But they went much further than that. Where do you draw the line? Let's hope this doesn't degenerate into a discussion of "turing completeness!" Given that many commands do operate on multiple objects it seems somewhat of a puzzling omission that there wasn't a sigma that operated on vectors. I would think sigma for lists is the more unusual built-in given lists can contain non-numeric data where the notion of sigma is not relevant, while vectors only contain numeric data. A vector sum is a fairly basic operation that is useful without having to think too hard. Converting to a list or doing a dot product seem to be pretty expensive alternatives. There is a basic difference in asking if there is a fundamental mathematical operation among the hundreds of operations on the calculator, which is what I asked, and asking why every possible combination of stack-dancing isn't hardcoded in User RPL which I didn't ask and already know the answer to. I don't see much of a connection. I would be more ready to understand it if somebody from HP said "yeah, we forgot about that!" RE: Is there a command for vector sum in User RPL? - Peter Murphy - 05-22-2014 02:46 PM [1 2 3 4 5 6 7 8 9] AXL ΣLIST yields 45. RE: Is there a command for vector sum in User RPL? - Wes Loewer - 05-22-2014 02:49 PM (05-22-2014 09:29 AM)HP67 Wrote: The sigmaLIST command is handy. Is there a vector sum command when operating on vectors? If not, is there a best-practice for this? How about: Code: \<< AXL \GSLIST \>> -wes RE: Is there a command for vector sum in User RPL? - Peter Murphy - 05-22-2014 05:00 PM [1 2 3 4 5 6 7 8 9] 1 PEVAL yields 45. RE: Is there a command for vector sum in User RPL? - HP67 - 05-27-2014 04:30 PM Thanks guys. Many interesting tricks there. I was wondering if there was support for this already. The answer is no. Then I was wondering if any techniques are better than others- use less storage, faster, etc. Then I looked in the doc and found a table that describes the storage used for each type of object. Unless somebody knows otherwise it seems lists are the way to go, even when you could use a vector. They take less space and have more command support. RE: Is there a command for vector sum in User RPL? - Thomas Klemm - 05-27-2014 06:08 PM (05-22-2014 01:32 PM)HP67 Wrote: A vector sum is a fairly basic operation that is useful without having to think too hard. What would that be? I can come up with normalization of weights to make sure that their sum is 1. But looking at vectors as mathematical objects I don't see a lot of applications. What's the geometrical meaning of the sum of the coordinates of a vector? Compared to the scalar product or the length. This value changes even with isometric coordinate transformations: compare [4, 3] to [5, 0] or [2, 2, 1] to [0, 3, 0]. Kind regards Thomas RE: Is there a command for vector sum in User RPL? - Gerson W. Barbosa - 05-28-2014 02:14 AM (05-22-2014 05:00 PM)Peter Murphy Wrote: [1 2 3 4 5 6 7 8 9] 1 PEVAL yields 45. [1 2 3 4 5 6 7 8 9] CNRM yields 45 also. This gives the sum of the absolute values of the elements (that is, it will only work when all elements are positive). RE: Is there a command for vector sum in User RPL? - HP67 - 05-28-2014 05:35 AM (05-27-2014 06:08 PM)Thomas Klemm Wrote:(05-22-2014 01:32 PM)HP67 Wrote: A vector sum is a fairly basic operation that is useful without having to think too hard. That's because you're a mathematician and I'm a programmer I was looking at it as a programming object. And I did have a real problem I was working on. The first thing that comes to mind is to be able to calculate various forms of averages and standard deviations on discrete data without being forced into the built-in stats mode. I had just such a problem I was trying to solve when this issue came up. But really I look at this as a basic operation that should be part of a language. APL, LISP etc. have this capability. Mathematical functions can operate on vectors. There are thousands of functions built in to the 50g like f0gamma. So why not vector sum without having to go through an expensive conversion to list or creating a like-sized vector to do a dot product with? As I found, lists are more storage efficient and have more command support. So I don't see the need for vectors any more until I need to do something that's not supported for lists but is supported for vectors. |