# Use a vector as tensor argument?

Posted 2 months ago
370 Views
|
3 Replies
|
1 Total Likes
|
 Good morning,I want to assign a certain value to an element of a tensor. This element is identified by an array obtained from some evaluations, so we fix it. Here i present an oversimplified core part of my code: DimensionA = 3; v = {1, 2, 3}; Array[TensorA, Table[10, DimensionA], 0]; TensorA @@ v = 12; at this point i receive an error Set::write: Tag Apply in TensorA@@{1,2,3} is Protected. Obviously if i do TensorA[1, 2, 3] = 12;it is all ok but my aim is to give in input a vector with an arbitrary number of indices. Let me know how should I give in input the vector to the tensor without receiving this error.Please admins don't remove this question.
3 Replies
Sort By:
Posted 2 months ago
 Do you mean this? In[1]:= DimensionA = 3; v = {1, 2, 3}; Array[TensorA, Table[10, {DimensionA}], 0]; TensorA[Sequence @@ v] = 12 Out[4]= 12 In[5]:= TensorA[1, 2, 3] Out[5]= 12