0

I have a function f(x):[0,1]-> Rⁿ such as:

>>> f(0.54)
array([0.2, 0.3, 4.0, 5.2, ... , 1.0])

How can I efficiently apply that to a vector, in order to generate a matrix?

Example:

>>> f([0.54, 0.32, 0.56, 0.21])
array([0.2, 0.3, 4.0, 5.2, ... , 1.0],
      [0.6, 0.1, 0.0, 2.3, ... , 4.7],
      [0.1, 7.1, 0.2, 4.9, ... , 3.1],
      [1.3, 2.8, 1.2, 1.1, ... , 5.3])

Note: numpy solutions are very welcome :)

3
  • The issue is not about mapping, but on doing the multidimensional mapping in a efficient way. Commented Nov 26, 2017 at 1:42
  • As long as the function is black box there isn't much you can do. A one to many mapping complicates the task. Vectorize takes signature, but is slower. frompyfunc is my favorite. It returns an object. The resulting array will need stacking,. Commented Nov 26, 2017 at 3:24
  • 1
    I added a link to 'vectorize' question with a one-to-many function. Commented Nov 26, 2017 at 3:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.