Tag Info

Hot answers tagged

10

Using Composition I can apply RotationTransform, TranslationTransform , ShearingTransform one after the other. Graphics3D[{ Opacity[1] , Red , Arrow[{{0, 0, 0}, {1, 0, 0}}] , Green , Arrow[{{0, 0, 0}, {0, 1, 0}}] , Blue , Arrow[{{0, 0, 0}, {0, 0, 1}}] , Opacity[0.2] , GeometricTransformation[Cuboid[-{1, 1, 1}/4, {1, 1, 1}/4], ...


4

You can use matrix[[#, #2 ;; #3]] & @@@ triplets A 20 by 10 example: matrix = RandomInteger[10, {20, 10}]; matrix // TableForm triplets = Flatten/@Transpose[{RandomInteger[{1, 20}, {8}], Sort/@RandomInteger[{1, 10}, {8, 2}]}] {{14, 5, 10}, {11, 4, 10}, {2, 2, 10}, {10, 8, 10}, {12, 3, 9}, {3, 3, 5}, {6, 4, 7}, {5, 5, 10}} matrix[[#, #2 ;; ...


3

you still can use MapThread. consider the example given by kguler: MapThread[matrix[[#, #2 ;; #3]] &, Transpose[triplets]]


2

exp = (a A + a B) /. {a -> 2, A -> {{1, 2}, {3, 4}}, B -> {{8, 7}, {6, 5}}}; exp[[1, 1]] The original code takes part [[1,1]] of the expression which is a, hence 2. Alternatively you could put parentheses around expression and rules and take part or Part[(a A + a B) /. {a -> 2, A -> {{1, 2}, {3, 4}}, B -> {{8, 7}, {6, 5}}}, 1, ...


2

Although I prefer kguler's method I don't want to be left out of the fun therefore: Cases[triplets, {r_, c1_, c2_} :> matrix[[r, c1 ;; c2]]]


2

Here is one possible way to do it: L1 = {{1, 2}, {1, 3}, {1, 4}}; L2 = {{1, 2}, {1, 3, 2}, {1, 4, 3, 2}}; Outer[Boole[#1 == #2[[{1, -1}]]] &, L1, L2, 1] which produces $$\left( \begin{array}{ccc} 1 & 1 & 1 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \\ \end{array} \right),$$ which shows that the computation of L2 is redundant, since the ...


1

Since V10 you can play with Inactivate and Activate x = a A + a B /. {a -> 2, A -> {{1, 2}, {3, 4}}, B -> {{8, 7}, {6, 5}}} // Inactivate; x[[1]] x[[2]] y = Activate[x, ReplaceAll] z = Activate[y] {{18, 18}, {18, 18}} z[[1, 1]] 18 Or, directly Activate[x][[2, 2]] 18


1

If I understand you correctly: f[n_, t_] := Select[{#, Eigenvalues@#} & /@ Tuples[{0, 1}, {n, n}], MemberQ[#[[2]], t] &][[All, 1]] But be careful because the tuples thing grows ... quickly :). Finding an efficient way is more complicated.



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