1
$\begingroup$

I need to evaluate the tensor product 10 times in a given list( {g,e,r})

Here I have evaluated for 3 times...

#\[TensorProduct]#\[TensorProduct]#&[{g,e,r}]
..
..

Evaluated for 6 times...

#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#\[TensorProduct]#&[{g,e,r}] (*n=6*)

Each time I need to include the tensor product on the list. Is there any better way to do this for large no.?

$\endgroup$
2
$\begingroup$

You can generate the chained function on-the-fly for each n:

ClearAll@chainTensorProduct
chainTensorProduct[list_, n_Integer] := Function[TensorProduct @@ ConstantArray[#, n]]@list

Example:

#\[TensorProduct]#\[TensorProduct]#&[{g, e, r}] == chainTensorProduct[{g, e, r}, 3]
(* True *)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.