Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.
Moderators: chulett , rschirm , roy
NEO
Premium Member
Posts: 163 Joined: Mon Mar 22, 2004 5:49 pm
Post
by NEO » Thu Jul 12, 2007 8:05 am
Hi,
I am trying to do some arithmetic on an array. I have two sets of data.
X=[1,2,3]
Y=[10,20,30]
I would like to be able to do some arithmetic like this.
SUM(XY)-SUM(X)SUM(Y) = (10+40+90)-(1+2+3)*(10+20+30)
I know how to multiply arrays but not sure about summing elements in an array. I have a feeling its real simple but I havent thought through it
Any help highly appreciated as always.
Thanks.
NEO
Premium Member
Posts: 163 Joined: Mon Mar 22, 2004 5:49 pm
Post
by NEO » Thu Jul 12, 2007 8:33 am
Turns out it is very simple. SUM(X) gives the sum of all elements in the array !
NEO
Premium Member
Posts: 163 Joined: Mon Mar 22, 2004 5:49 pm
Post
by NEO » Thu Jul 12, 2007 8:34 am
Did anyone try to do Matrix algebra using dynamic arrays in Basic ?
NEO
Premium Member
Posts: 163 Joined: Mon Mar 22, 2004 5:49 pm
Post
by NEO » Thu Jul 12, 2007 12:09 pm
As part of the same topic, how do you multiply a vector with a scalar.
For example.
X=[1,2,3,4,5]
Y=2*X=[2,4,6,8,10]
kcbland
Participant
Posts: 5208 Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:
Post
by kcbland » Thu Jul 12, 2007 1:06 pm
Look in your DS BASIC manual at the MULS function.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kcbland
Participant
Posts: 5208 Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:
Post
by kcbland » Thu Jul 12, 2007 1:11 pm
Actually, look at the following:
ADDS
DIVS
MULS
SUBS
They do a lot of array mathematics. To simulate vector with a scalar, simply convert your single value into an array of that same value repeated as many times in your list.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607 Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:
Post
by ray.wurlod » Thu Jul 12, 2007 2:03 pm
If you have multi-valued fields in your dynamic array SUM() will only total the values into fields. Prefer SUMMATION() in this case.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.