0

I am trying to write a function that will return wether the vectors in a matrix are orthonormal. For example if I have a matrix with three vetors:

B=matrix([[1,1,2],[1,2,1],[2,1,1])

I want a function that wil return B[0]*B[1], B[0]*B[2], B[2]*B[3].

or in general a fuction that will go over a list and multiply each element with each other. eg. list_eg=[1,2,3]

outcome=[1* 2,1* 3,2* 3]=[2,3,6]

1 Answers1

0

from itertools you can use combinations

from itertools import combinations
[a*b for a,b in combinations([1,2,3], 2)]

# [2, 3, 6]

For the matrix version you can use the numpy Here a thread like this: using the numpy

Glauco
  • 1,385
  • 2
  • 10
  • 20