I've to map R^2 array X=[x1, x2] into R^3 array X'=[x1, x2, x1^2].
Is there any compact solution?
ADDED: My starting array is a numpy array e.g. x = numpy.array([2, 3]). I want to end up with another numpy array e.g. x' = numpy.array([2, 3, 4]).
Xis a list, you can do[X[0], X[1], X[0]**2], orX + [X[0]**2]arraymodule, or an ndarray from thenumpymodule. The last has some shortcuts to make array modifications quicker and easier and more compact. Which kind of array are you starting with and what kind of array do you want as a result? It would be best to show an example array, building it with Python code.numpyarray e.g.x = numpy.array([2, 3]), I want anothernumpyarray e.g.x' = numpy.array([2, 3, 4]).