Post Reply 
Problems with the command cumSum and Workaround
05-11-2015, 07:50 PM (This post was last modified: 05-11-2015 08:00 PM by Eddie W. Shore.)
Post: #1
Problems with the command cumSum and Workaround
Example: store {10, 20, 10} to L1

cumSum(L1):

sometimes returns {10, 40, Nan}
sometimes returns {10, 30, 40} (the right answer)
sometimes causes the calcualtor to crash

Software Version 6975


Here is a possible workaround:
CSUM(list)
BEGIN
LOCAL k;
FOR k FROM 2 TO SIZE(list) DO
list[k]:=list[k]+list[k-1];
END;
RETURN list;
END;

CSUM({10,20.10}) returns {10,30,40}
Visit this user's website Find all posts by this user
Quote this message in a reply
05-11-2015, 08:42 PM
Post: #2
RE: Problems with the command cumSum and Workaround
I couldn't reproduce the errors and the crash you're reporting!
Find all posts by this user
Quote this message in a reply
05-11-2015, 08:54 PM
Post: #3
RE: Problems with the command cumSum and Workaround
Hi Eddie'

I could not reproduce your error. Tried in HOME mode and CAS with various values in L1.
Find all posts by this user
Quote this message in a reply
05-11-2015, 09:04 PM
Post: #4
RE: Problems with the command cumSum and Workaround
eddie,

I tried 20 times in CAS and same in Home but could not reproduce the error. Textbook setting, 6975 SW on the actual calculator.

Cheers, Terje
Find all posts by this user
Quote this message in a reply
12-30-2017, 05:17 PM (This post was last modified: 12-30-2017 05:52 PM by StephenG1CMZ.)
Post: #5
RE: Problems with the command cumSum and Workaround
One oddity I have just noted is that whereas cumSum normally returns a list, the built-in cumSum({}) returns numerical 0 instead - a result of a different type.
I am not certain what the correct result should be, but I would expect/hope for either {} or {0}, not 0.

Stephen Lewkowicz (G1CMZ)
Does every Android "improvement" make Android worse?
Visit this user's website Find all posts by this user
Quote this message in a reply
12-30-2017, 07:13 PM
Post: #6
RE: Problems with the command cumSum and Workaround
I have implemented cumSum for TI compatibility, and it returns 0 for an empty list.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)