in Education by
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago. Improve this question Given an array [x1 x2 x3 ... xn] containing n elements, it is desired to produce such following array containing K rows: [[x1 x2 x3 ... xn], [x1^2 x2^2 x3^2 ... xn^2], [x1^3 x2^3 x3^3 ... xn^3], ..., [x1^K x2^K x3^K ... xn^K]]. How to get this efficiently ? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can use numpy.power.outer: >>> K=9 >>> numpy.power.outer(numpy.array([1, 4, 5]), numpy.arange(1, K+1)).T array([[ 1, 4, 5], [ 1, 16, 25], [ 1, 64, 125], [ 1, 256, 625], [ 1, 1024, 3125], [ 1, 4096, 15625], [ 1, 16384, 78125], [ 1, 65536, 390625], [ 1, 262144, 1953125]])

Related questions

0 votes
    I'm learning oop in python after learning it in Java. It happens that i'm trying to create an array from my class ... .name = name person1 = Person() person1.set_name("John") #...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I need to create a hollow pyramid with a solid top layer like so: Height: 5 * *** * * * ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    I need to Separate multiple Array entries with a newline. the names in the aray value. Again I want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Can someone help me with the correct use of the split function in perl Here is my input list called ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What is the problem Here ? I got an error shows ValueError: too many values to unpack This code ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I need to iterate through the elements in a numpy array so I can treat any zero elements separately. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    arr = [(line.rstrip('\n').split(';')) for line in open('C:/Config_Changer.csv')] import ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I need to iterate through the elements in a numpy array so I can treat any zero elements separately. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    arr = [(line.rstrip('\n').split(';')) for line in open('C:/Config_Changer.csv')] import ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    arr = [(line.rstrip('\n').split(';')) for line in open('C:/Config_Changer.csv')] import ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    I have an array of the shape (100000, 1) with each element in an array of type positive integer and not ... help would be appreciated. Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    Write a program to eliminate duplicates in a sorted array. in python Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
...