1

Let's say I have a matrix like [a1 a2 a3 a4], where the ai's are the columns, and a sequence of Ints like (p1, p2, p3, p4). What is the best way to create the matrix [a1^p1 a2^p2 a3^p3 a4^p4]?

Ultimately, the output I need is a vector where the entries are the products of the rows of the matrix [a1^p1 a2^p2 a3^p3 a4^p4].

I've tried a bunch of different ways using mapValues, mapPairs, map, and product, but they all seem kind of hacky.

duplode
  • 33,731
  • 7
  • 79
  • 150

0 Answers0