# Setting to zero non defined array variables

I have a situation like this (for example):

vv[1, 2, 3] = a;
vv[1, 3, 2] = 11;
vv[3, 1, 2] = 7;
vv[2, 1, 3] = 5;

Sum[LeviCivitaTensor[3][[mu, nu, eta]]*vv[mu, nu, eta], {mu, 1,
3}, {nu, 1, 3}, {eta, 1, 3}]


I obtain this:

   -9 + a + vv[2, 3, 1] - vv[3, 2, 1]


I have not defined vv[2, 3, 1] and vv[3, 2, 1]so they appear as symbolic expressions, there is another symbolic expr which is vv[1, 2, 3] = a. Now here is the question. Is there a way to set to zero all the components not defined like these ones, if yes does it discriminate the variable a and vv[3, 2, 1] ?

Thank you.

• Something like vv[__] = 0? Oct 12, 2018 at 23:12
• Sum[LeviCivitaTensor[3][[mu, nu, eta]]*vv[mu, nu, eta], {mu, 1, 3}, {nu, 1, 3}, {eta, 1, 3}] /. _vv :> 0 Oct 12, 2018 at 23:36
• @BobHanlon please could you tell me why using your sintax the code works even if some parts of array are not defined? Oct 13, 2018 at 19:08
• @siderius - any undefined terms have the form vv[mu, nu, eta], that is, an expression with the Head of vv. The rule _vv :> 0 replaces any expression with Head of vv with 0. Oct 13, 2018 at 19:10
• @BobHanlon and correctly it discriminates a. Thank you for the answer. Oct 13, 2018 at 19:16

vv = SparseArray[{{1, 2, 3} -> a, {1, 3, 2} -> 11,