'How to multiply first row of a matrix with other rows in python?

I'm trying to develop python code for an algorithm from a research paper. How can I calculate p? (please see reference image for better understanding)

X(t) = [[x1(t1)   x1(t2) . . . x1(tn)],
        [x2(t1)   x2(t2) . . . x2(tn)],
        [x3(t1)   x3(t2) . . . x3(tn)],
          .          .            .
          .          .            .
        [xn(t1)   xn(t2) . . . xn(tn)]] 

h = [x1(t1) x1(t2) ··· ··· x1(tN)]

H = [[x2(t1)   x2(t2) . . . x2(tn)],
     [x3(t1)   x3(t2) . . . x3(tn)],
          .          .            .
          .          .            .
     [xn(t1)   xn(t2) . . . xn(tn)]] 

p = hH^H / hh^H

as I understand, we need to multiply first row with the rest of the matrix

required calculation theory



Solution 1:[1]

Here's an implementation using Python (3.X).

import numpy as np

# This can work for any matrix X
# This line just generates a quick example
X = np.arange(30).reshape((3,-1))

h,H = X[0,:],X[1:,:]
p = ([email protected]().T)/([email protected]())

For the X I used in this script, the resulting vector p is (the one-dimensional array) [2.57894737 4.15789474] .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ben Grossmann