I am trying to simulate a signal and need to solve the matrix equation Ax = B. Here A and B are both known: A is 500x40 matrix (40 signal source candidates), B is a 500x1 vector (my target signal), and x is the 40x1 vector I am looking for (coefficients).
I have found the function numpy.linalg.lstsq. However I have certain boundary restrictions in this case:
- all the elements of x must be positive;
- there are 5 characteristic peaks in the target signal that need to be fixed, in other words, 5 particular elements of the final product A*x must be the same with B.
How can I first apply the boundary conditions and then find the solution with least square? Shall I keep using numpy.linalg.lstsq or another function? I am clueless right now and would really appreciate your help.
Thanks a lot in advance!
Somi