Apply MapThread to all but one variableHow do you efficiently return all of a List but one element?All values for a function with two arguments without OuterEfficiently finding the maximum value of a column in a matrixnested use of Apply/Map/MapThread in pure functionsMapThread AlternativesFinding neighbors from listMapThread problemapply binary operation to all adjacent pairsFlip sign of one variable in listFind numbers from Mean, Variance and Correlation coefficient

Overlay of two functions leaves gaps

Classification of surfaces

Can someone publish a story that happened to you?

What is causing the white spot to appear in some of my pictures

Map of water taps to fill bottles

How could Tony Stark make this in Endgame?

Critique of timeline aesthetic

How to stop co-workers from teasing me because I know Russian?

How to pronounce 'c++' in Spanish

Dynamic SOQL query relationship with field visibility for Users

Initiative: Do I lose my attack/action if my target moves or dies before my turn in combat?

Does a large simulator bay have standard public address announcements?

Do I have an "anti-research" personality?

Implications of cigar-shaped bodies having rings?

Coordinate my way to the name of the (video) game

How to prevent z-fighting in OpenSCAD?

What happened to Captain America in Endgame?

How does Captain America channel this power?

Why does nature favour the Laplacian?

Pulling the rope with one hand is as heavy as with two hands?

What term is being referred to with "reflected-sound-of-underground-spirits"?

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

can anyone help me with this awful query plan?

Could the terminal length of components like resistors be reduced?



Apply MapThread to all but one variable


How do you efficiently return all of a List but one element?All values for a function with two arguments without OuterEfficiently finding the maximum value of a column in a matrixnested use of Apply/Map/MapThread in pure functionsMapThread AlternativesFinding neighbors from listMapThread problemapply binary operation to all adjacent pairsFlip sign of one variable in listFind numbers from Mean, Variance and Correlation coefficient













2












$begingroup$


I would like to know what is the most efficient to implement the following computation. Given three lists



 a = a_1,a_2, a_3, …, a_n
b = b_1,b_2, b_3, …, b_n
c = c_1,c_2, c_3, …, c_n


and a function $f(x_1,x_2,x_3)$, obtain



 f(a_1,b_1,c_1) f(a_1,b_1,c_2) ..... f(a_1,b_1,c_n) 
f(a_2,b_2,c_1) f(a_2,b_2,c_2) ..... f(a_2,b_2,c_n)
..... ..... ..... .....
f(a_n,b_n,c_1) f(a_n,b_n,c_2) ..... f(a_n,b_n,c_n)


I cannot find a solution not using For.










share|improve this question











$endgroup$
















    2












    $begingroup$


    I would like to know what is the most efficient to implement the following computation. Given three lists



     a = a_1,a_2, a_3, …, a_n
    b = b_1,b_2, b_3, …, b_n
    c = c_1,c_2, c_3, …, c_n


    and a function $f(x_1,x_2,x_3)$, obtain



     f(a_1,b_1,c_1) f(a_1,b_1,c_2) ..... f(a_1,b_1,c_n) 
    f(a_2,b_2,c_1) f(a_2,b_2,c_2) ..... f(a_2,b_2,c_n)
    ..... ..... ..... .....
    f(a_n,b_n,c_1) f(a_n,b_n,c_2) ..... f(a_n,b_n,c_n)


    I cannot find a solution not using For.










    share|improve this question











    $endgroup$














      2












      2








      2





      $begingroup$


      I would like to know what is the most efficient to implement the following computation. Given three lists



       a = a_1,a_2, a_3, …, a_n
      b = b_1,b_2, b_3, …, b_n
      c = c_1,c_2, c_3, …, c_n


      and a function $f(x_1,x_2,x_3)$, obtain



       f(a_1,b_1,c_1) f(a_1,b_1,c_2) ..... f(a_1,b_1,c_n) 
      f(a_2,b_2,c_1) f(a_2,b_2,c_2) ..... f(a_2,b_2,c_n)
      ..... ..... ..... .....
      f(a_n,b_n,c_1) f(a_n,b_n,c_2) ..... f(a_n,b_n,c_n)


      I cannot find a solution not using For.










      share|improve this question











      $endgroup$




      I would like to know what is the most efficient to implement the following computation. Given three lists



       a = a_1,a_2, a_3, …, a_n
      b = b_1,b_2, b_3, …, b_n
      c = c_1,c_2, c_3, …, c_n


      and a function $f(x_1,x_2,x_3)$, obtain



       f(a_1,b_1,c_1) f(a_1,b_1,c_2) ..... f(a_1,b_1,c_n) 
      f(a_2,b_2,c_1) f(a_2,b_2,c_2) ..... f(a_2,b_2,c_n)
      ..... ..... ..... .....
      f(a_n,b_n,c_1) f(a_n,b_n,c_2) ..... f(a_n,b_n,c_n)


      I cannot find a solution not using For.







      list-manipulation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 3 hours ago









      corey979

      20.9k64382




      20.9k64382










      asked 3 hours ago









      SmerdjakovSmerdjakov

      1305




      1305




















          4 Answers
          4






          active

          oldest

          votes


















          4












          $begingroup$

          Here's one way to do it with Outer:



          n = 3;
          l1 = Array[a, n];
          l2 = Array[b, n];
          l3 = Array[c, n];

          Outer[
          f[#1[[1]], #1[[2]], #2] &,
          Transpose @ l1, l2,
          l3,
          1
          ]



          Out[25]= f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
          f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
          f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
          f[a[3], b[3], c[3]]







          share|improve this answer









          $endgroup$








          • 1




            $begingroup$
            Or Outer[f[Sequence @@ #1, #2] &, Transpose@l1, l2, l3, 1] so you don't need to unravel #1 manually.
            $endgroup$
            – Roman
            3 hours ago


















          2












          $begingroup$

          a = a1, a2, a3, a4, a5;
          b = b1, b2, b3, b4, b5;
          c = c1, c2, c3, c4, c5;

          Table[f[a[[j]], b[[j]], c[[k]]], j, 1, 5, k, 1, 5]


          enter image description here






          share|improve this answer









          $endgroup$




















            2












            $begingroup$

            Another possibility is to use the 3-arg version of Thread. With Sjoerd's example:



            n = 3;
            l1 = Array[a,n];
            l2 = Array[b,n];
            l3 = Array[c,n];


            Using Thread:



            Thread /@ Thread[f[l1, l2, l3], List, 2]



            f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
            f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
            f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
            f[a[3], b[3], c[3]]







            share|improve this answer









            $endgroup$




















              0












              $begingroup$

              Another way with Curry and Through.



              Through /@ Apply[Curry[f, 2, 3, 1] /@ c] /@ Transpose@a, b



              Mathematica graphics




              Hope this helps.






              share|improve this answer









              $endgroup$













                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "387"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197144%2fapply-mapthread-to-all-but-one-variable%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                4












                $begingroup$

                Here's one way to do it with Outer:



                n = 3;
                l1 = Array[a, n];
                l2 = Array[b, n];
                l3 = Array[c, n];

                Outer[
                f[#1[[1]], #1[[2]], #2] &,
                Transpose @ l1, l2,
                l3,
                1
                ]



                Out[25]= f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                f[a[3], b[3], c[3]]







                share|improve this answer









                $endgroup$








                • 1




                  $begingroup$
                  Or Outer[f[Sequence @@ #1, #2] &, Transpose@l1, l2, l3, 1] so you don't need to unravel #1 manually.
                  $endgroup$
                  – Roman
                  3 hours ago















                4












                $begingroup$

                Here's one way to do it with Outer:



                n = 3;
                l1 = Array[a, n];
                l2 = Array[b, n];
                l3 = Array[c, n];

                Outer[
                f[#1[[1]], #1[[2]], #2] &,
                Transpose @ l1, l2,
                l3,
                1
                ]



                Out[25]= f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                f[a[3], b[3], c[3]]







                share|improve this answer









                $endgroup$








                • 1




                  $begingroup$
                  Or Outer[f[Sequence @@ #1, #2] &, Transpose@l1, l2, l3, 1] so you don't need to unravel #1 manually.
                  $endgroup$
                  – Roman
                  3 hours ago













                4












                4








                4





                $begingroup$

                Here's one way to do it with Outer:



                n = 3;
                l1 = Array[a, n];
                l2 = Array[b, n];
                l3 = Array[c, n];

                Outer[
                f[#1[[1]], #1[[2]], #2] &,
                Transpose @ l1, l2,
                l3,
                1
                ]



                Out[25]= f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                f[a[3], b[3], c[3]]







                share|improve this answer









                $endgroup$



                Here's one way to do it with Outer:



                n = 3;
                l1 = Array[a, n];
                l2 = Array[b, n];
                l3 = Array[c, n];

                Outer[
                f[#1[[1]], #1[[2]], #2] &,
                Transpose @ l1, l2,
                l3,
                1
                ]



                Out[25]= f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                f[a[3], b[3], c[3]]








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                Sjoerd SmitSjoerd Smit

                4,610817




                4,610817







                • 1




                  $begingroup$
                  Or Outer[f[Sequence @@ #1, #2] &, Transpose@l1, l2, l3, 1] so you don't need to unravel #1 manually.
                  $endgroup$
                  – Roman
                  3 hours ago












                • 1




                  $begingroup$
                  Or Outer[f[Sequence @@ #1, #2] &, Transpose@l1, l2, l3, 1] so you don't need to unravel #1 manually.
                  $endgroup$
                  – Roman
                  3 hours ago







                1




                1




                $begingroup$
                Or Outer[f[Sequence @@ #1, #2] &, Transpose@l1, l2, l3, 1] so you don't need to unravel #1 manually.
                $endgroup$
                – Roman
                3 hours ago




                $begingroup$
                Or Outer[f[Sequence @@ #1, #2] &, Transpose@l1, l2, l3, 1] so you don't need to unravel #1 manually.
                $endgroup$
                – Roman
                3 hours ago











                2












                $begingroup$

                a = a1, a2, a3, a4, a5;
                b = b1, b2, b3, b4, b5;
                c = c1, c2, c3, c4, c5;

                Table[f[a[[j]], b[[j]], c[[k]]], j, 1, 5, k, 1, 5]


                enter image description here






                share|improve this answer









                $endgroup$

















                  2












                  $begingroup$

                  a = a1, a2, a3, a4, a5;
                  b = b1, b2, b3, b4, b5;
                  c = c1, c2, c3, c4, c5;

                  Table[f[a[[j]], b[[j]], c[[k]]], j, 1, 5, k, 1, 5]


                  enter image description here






                  share|improve this answer









                  $endgroup$















                    2












                    2








                    2





                    $begingroup$

                    a = a1, a2, a3, a4, a5;
                    b = b1, b2, b3, b4, b5;
                    c = c1, c2, c3, c4, c5;

                    Table[f[a[[j]], b[[j]], c[[k]]], j, 1, 5, k, 1, 5]


                    enter image description here






                    share|improve this answer









                    $endgroup$



                    a = a1, a2, a3, a4, a5;
                    b = b1, b2, b3, b4, b5;
                    c = c1, c2, c3, c4, c5;

                    Table[f[a[[j]], b[[j]], c[[k]]], j, 1, 5, k, 1, 5]


                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 3 hours ago









                    corey979corey979

                    20.9k64382




                    20.9k64382





















                        2












                        $begingroup$

                        Another possibility is to use the 3-arg version of Thread. With Sjoerd's example:



                        n = 3;
                        l1 = Array[a,n];
                        l2 = Array[b,n];
                        l3 = Array[c,n];


                        Using Thread:



                        Thread /@ Thread[f[l1, l2, l3], List, 2]



                        f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                        f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                        f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                        f[a[3], b[3], c[3]]







                        share|improve this answer









                        $endgroup$

















                          2












                          $begingroup$

                          Another possibility is to use the 3-arg version of Thread. With Sjoerd's example:



                          n = 3;
                          l1 = Array[a,n];
                          l2 = Array[b,n];
                          l3 = Array[c,n];


                          Using Thread:



                          Thread /@ Thread[f[l1, l2, l3], List, 2]



                          f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                          f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                          f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                          f[a[3], b[3], c[3]]







                          share|improve this answer









                          $endgroup$















                            2












                            2








                            2





                            $begingroup$

                            Another possibility is to use the 3-arg version of Thread. With Sjoerd's example:



                            n = 3;
                            l1 = Array[a,n];
                            l2 = Array[b,n];
                            l3 = Array[c,n];


                            Using Thread:



                            Thread /@ Thread[f[l1, l2, l3], List, 2]



                            f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                            f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                            f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                            f[a[3], b[3], c[3]]







                            share|improve this answer









                            $endgroup$



                            Another possibility is to use the 3-arg version of Thread. With Sjoerd's example:



                            n = 3;
                            l1 = Array[a,n];
                            l2 = Array[b,n];
                            l3 = Array[c,n];


                            Using Thread:



                            Thread /@ Thread[f[l1, l2, l3], List, 2]



                            f[a[1], b[1], c[1]], f[a[1], b[1], c[2]],
                            f[a[1], b[1], c[3]], f[a[2], b[2], c[1]], f[a[2], b[2], c[2]],
                            f[a[2], b[2], c[3]], f[a[3], b[3], c[1]], f[a[3], b[3], c[2]],
                            f[a[3], b[3], c[3]]








                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 2 hours ago









                            Carl WollCarl Woll

                            75.9k3100198




                            75.9k3100198





















                                0












                                $begingroup$

                                Another way with Curry and Through.



                                Through /@ Apply[Curry[f, 2, 3, 1] /@ c] /@ Transpose@a, b



                                Mathematica graphics




                                Hope this helps.






                                share|improve this answer









                                $endgroup$

















                                  0












                                  $begingroup$

                                  Another way with Curry and Through.



                                  Through /@ Apply[Curry[f, 2, 3, 1] /@ c] /@ Transpose@a, b



                                  Mathematica graphics




                                  Hope this helps.






                                  share|improve this answer









                                  $endgroup$















                                    0












                                    0








                                    0





                                    $begingroup$

                                    Another way with Curry and Through.



                                    Through /@ Apply[Curry[f, 2, 3, 1] /@ c] /@ Transpose@a, b



                                    Mathematica graphics




                                    Hope this helps.






                                    share|improve this answer









                                    $endgroup$



                                    Another way with Curry and Through.



                                    Through /@ Apply[Curry[f, 2, 3, 1] /@ c] /@ Transpose@a, b



                                    Mathematica graphics




                                    Hope this helps.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 18 mins ago









                                    EdmundEdmund

                                    26.8k330103




                                    26.8k330103



























                                        draft saved

                                        draft discarded
















































                                        Thanks for contributing an answer to Mathematica Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid


                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.

                                        Use MathJax to format equations. MathJax reference.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197144%2fapply-mapthread-to-all-but-one-variable%23new-answer', 'question_page');

                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        How to create a command for the “strange m” symbol in latex? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do you make your own symbol when Detexify fails?Writing bold small caps with mathpazo packageplus-minus symbol with parenthesis around the minus signGreek character in Beamer document titleHow to create dashed right arrow over symbol?Currency symbol: Turkish LiraDouble prec as a single symbol?Plus Sign Too Big; How to Call adfbullet?Is there a TeX macro for three-legged pi?How do I get my integral-like symbol to align like the integral?How to selectively substitute a letter with another symbol representing the same letterHow do I generate a less than symbol and vertical bar that are the same height?

                                        Българска екзархия Съдържание История | Български екзарси | Вижте също | Външни препратки | Литература | Бележки | НавигацияУстав за управлението на българската екзархия. Цариград, 1870Слово на Ловешкия митрополит Иларион при откриването на Българския народен събор в Цариград на 23. II. 1870 г.Българската правда и гръцката кривда. От С. М. (= Софийски Мелетий). Цариград, 1872Предстоятели на Българската екзархияПодмененият ВеликденИнформационна агенция „Фокус“Димитър Ризов. Българите в техните исторически, етнографически и политически граници (Атлас съдържащ 40 карти). Berlin, Königliche Hoflithographie, Hof-Buch- und -Steindruckerei Wilhelm Greve, 1917Report of the International Commission to Inquire into the Causes and Conduct of the Balkan Wars

                                        Category:Tremithousa Media in category "Tremithousa"Navigation menuUpload media34° 49′ 02.7″ N, 32° 26′ 37.32″ EOpenStreetMapGoogle EarthProximityramaReasonatorScholiaStatisticsWikiShootMe