Tag Info

Hot answers tagged

3

For your second question, you could use (tabletry = Table[p1*p2, {p1, 0, 2}, {p2, 0, 2}]) // MatrixForm; (* or (tabletry = Array[# #2 &, {3, 3}, 0]) // MatrixForm; *) (tst = Map[{# == 0} &, tabletry, {-1}]) // MatrixForm or (tst2 = Array[# #2 /. {0 -> {True}, _ -> {False}} &, {3, 3}, 0]) // MatrixForm Note the parantheses wrapping ...


2

Your p3 definitions seem different. The following uses 3p3 -5=p1+p2. set = Tuples[Range[0, 2], 2]; set /. {x_, y_} :> (x + y + 5)/3. /; x y == 0 yields: {1.66667, 2., 2.33333, 2., {1, 1}, {1, 2}, 2.33333, {2, 1}, {2, 2}} or if you wish to couple results and {p1,p2}: set /. {{x_, y_} :> Rule[{x, y}, (x + y + 5)/3.] /; x y == 0, {x_, y_} :> ...


1

I post this as another answer (using again $ 3p3=p1+p2-5$) if the matrices are the main aim: sa0 = SparseArray[{i_, j_} :> (i - 1) (j - 1), {3, 3}] // MatrixForm; sa = SparseArray[{{i_, j_} /; ((i - 1) (j - 1) != 0) :> (i - 1) (j - 1), {i_, j_} /; ((i - 1) ( j - 1) == 0) :> (i + j + 5)/3.}, {3, 3}] // MatrixForm; Row[{sa0, ...



Only top voted, non community-wiki answers of a minimum length are eligible