I can do elementwise operation like sum using
Zipped function. Let I have two Lists
L1 and L2 as shown
below
val L1 =
List(1,2,3,4)
val L2 =
List(5,6,7,8)
I can
take element wise sum in following
way
(L1,L2).zipped.map(_+_)
and
result is
List(6, 8,
10, 12)
as
expected.
I am using
Zipped function in my actual code but it takes too much
time. In reality My List Size is more than 1000 and I have
more than 1000 Lists and my algorithm is iterative where
iterations could be up to one billion.
In code I have to do following
stuff
list =(
(L1,L2).zipped.map(_+_).map (_ * math.random) ,
L3).zipped.map(_+_)
size
of L1,L2 and
L3 is same. Moreover I have to execute my actual code on a
cluster.
What is the fastest way to take
elementwise sum of Lists in Scala?
No comments:
Post a Comment