Implements a function in one line and without creating a list or tuples or any other collection that is not of fixed length and without using numpy using the given def signature
here what i did
def inner_product_c(c1: Iterable[complex], c2: Iterable[complex]) -> complex:
return list(map(lambda x, y: x*y.conjugate() , c1, c2)) ;
i define inner product space such that u,v are 2 vectors and i want the sum of all elements accordingly to the same position where u(i) * conjugate(v(i))
here is the only one line way that i came up with is there any other ways to do it in one line?
In Python3:
range()
returns an iterator in Python3, with space-complexityO(1)
Therefore the above does not create anything (other than the return list) of space-complexityO(n)
(being n the length of the vectors)