Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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 *)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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