Obtaining a matrix of complex values from associations giving the real and imaginary parts of each...

What is the purpose of easy combat scenarios that don't need resource expenditure?

How to avoid being sexist when trying to employ someone to function in a very sexist environment?

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

What is Crew Dragon approaching in this picture?

Where is this triangular-shaped space station from?

Find the number of ways to express 1050 as sum of consecutive integers

Do my Windows system binaries contain sensitive information?

What happens if a wizard reaches level 20 but has no 3rd-level spells that they can use with the Signature Spells feature?

c++ How can I make an algorithm for finding variations of a set without repetition (i.e. n elements, choose k)?

On what did Lego base the appearance of the new Hogwarts minifigs?

Can a person refuse a presidential pardon?

I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

Predict mars robot position

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

Why do neural networks need so many training examples to perform?

Am I using the wrong word all along?

Why zero tolerance on nudity in space?

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Could be quantum mechanics necessary to analyze some biology scenarios?

Connecting top and bottom of adjacent circles

How to add multiple differently colored borders around a node?

How to properly claim credit for peer review?

Which branches of mathematics can be done just in terms of morphisms and composition?

What can I substitute for soda pop in a sweet pork recipe?



Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?


Eigenvalues of matrix not giving imaginary partsPlot values of an $mtimes n$ matrix on the complex plane with color varying along $m$Real and Imaginary matrixDefining a non-standard algebraic numberFind the parameter values for my matrix for it to have imaginary eigenvaluesEfficiently select the smallest magnitude element from each column of a matrixGenerate random matrix where the entries in each column are drawn from a different rangeSample matrix indices in proportion to the matrix element valuesKeyed eigensystem for nested AssociationConverting a list of associations into a single association













5












$begingroup$


I have a list of associations keyed by real and imaginary numbers, like so:



matrix = {
{<|"r" -> 0.368252, "i" -> 0.0199587|>,
<|"r" -> -0.461644, "i" -> 0.109868|>,
<|"r" -> -0.216081, "i" -> 0.562557|>,
<|"r" -> -0.479881, "i" -> -0.212978|>},

{<|"r" -> 0.105028, "i" -> 0.632264|>,
<|"r" -> 0.116589, "i" -> -0.490063|>,
<|"r" -> 0.463378, "i" -> 0.231656|>,
<|"r" -> -0.148665, "i" -> 0.212065|>},

{<|"r" -> 0.463253, "i" -> 0.201161|>,
<|"r" -> 0.460547, "i" -> 0.397829|>,
<|"r" -> 0.222257, "i" -> 0.0129121|>,
<|"r" -> 0.168641, "i" -> -0.544568|>},

{<|"r" -> 0.255221, "i" -> -0.364687|>,
<|"r" -> 0.191895, "i" -> -0.337437|>,
<|"r" -> -0.12278, "i" -> 0.551195|>,
<|"r" -> 0.560485, "i" -> 0.134702|>}
}


Given this, I can write



testmatrix = Join[Values[matrix], 2]`


to get a matrix, but it is a matrix of tuples. How can I get the complex number defined in each <|r -> Re[z], i -> Im[z]|> rather than the tuples?










share|improve this question











$endgroup$

















    5












    $begingroup$


    I have a list of associations keyed by real and imaginary numbers, like so:



    matrix = {
    {<|"r" -> 0.368252, "i" -> 0.0199587|>,
    <|"r" -> -0.461644, "i" -> 0.109868|>,
    <|"r" -> -0.216081, "i" -> 0.562557|>,
    <|"r" -> -0.479881, "i" -> -0.212978|>},

    {<|"r" -> 0.105028, "i" -> 0.632264|>,
    <|"r" -> 0.116589, "i" -> -0.490063|>,
    <|"r" -> 0.463378, "i" -> 0.231656|>,
    <|"r" -> -0.148665, "i" -> 0.212065|>},

    {<|"r" -> 0.463253, "i" -> 0.201161|>,
    <|"r" -> 0.460547, "i" -> 0.397829|>,
    <|"r" -> 0.222257, "i" -> 0.0129121|>,
    <|"r" -> 0.168641, "i" -> -0.544568|>},

    {<|"r" -> 0.255221, "i" -> -0.364687|>,
    <|"r" -> 0.191895, "i" -> -0.337437|>,
    <|"r" -> -0.12278, "i" -> 0.551195|>,
    <|"r" -> 0.560485, "i" -> 0.134702|>}
    }


    Given this, I can write



    testmatrix = Join[Values[matrix], 2]`


    to get a matrix, but it is a matrix of tuples. How can I get the complex number defined in each <|r -> Re[z], i -> Im[z]|> rather than the tuples?










    share|improve this question











    $endgroup$















      5












      5








      5





      $begingroup$


      I have a list of associations keyed by real and imaginary numbers, like so:



      matrix = {
      {<|"r" -> 0.368252, "i" -> 0.0199587|>,
      <|"r" -> -0.461644, "i" -> 0.109868|>,
      <|"r" -> -0.216081, "i" -> 0.562557|>,
      <|"r" -> -0.479881, "i" -> -0.212978|>},

      {<|"r" -> 0.105028, "i" -> 0.632264|>,
      <|"r" -> 0.116589, "i" -> -0.490063|>,
      <|"r" -> 0.463378, "i" -> 0.231656|>,
      <|"r" -> -0.148665, "i" -> 0.212065|>},

      {<|"r" -> 0.463253, "i" -> 0.201161|>,
      <|"r" -> 0.460547, "i" -> 0.397829|>,
      <|"r" -> 0.222257, "i" -> 0.0129121|>,
      <|"r" -> 0.168641, "i" -> -0.544568|>},

      {<|"r" -> 0.255221, "i" -> -0.364687|>,
      <|"r" -> 0.191895, "i" -> -0.337437|>,
      <|"r" -> -0.12278, "i" -> 0.551195|>,
      <|"r" -> 0.560485, "i" -> 0.134702|>}
      }


      Given this, I can write



      testmatrix = Join[Values[matrix], 2]`


      to get a matrix, but it is a matrix of tuples. How can I get the complex number defined in each <|r -> Re[z], i -> Im[z]|> rather than the tuples?










      share|improve this question











      $endgroup$




      I have a list of associations keyed by real and imaginary numbers, like so:



      matrix = {
      {<|"r" -> 0.368252, "i" -> 0.0199587|>,
      <|"r" -> -0.461644, "i" -> 0.109868|>,
      <|"r" -> -0.216081, "i" -> 0.562557|>,
      <|"r" -> -0.479881, "i" -> -0.212978|>},

      {<|"r" -> 0.105028, "i" -> 0.632264|>,
      <|"r" -> 0.116589, "i" -> -0.490063|>,
      <|"r" -> 0.463378, "i" -> 0.231656|>,
      <|"r" -> -0.148665, "i" -> 0.212065|>},

      {<|"r" -> 0.463253, "i" -> 0.201161|>,
      <|"r" -> 0.460547, "i" -> 0.397829|>,
      <|"r" -> 0.222257, "i" -> 0.0129121|>,
      <|"r" -> 0.168641, "i" -> -0.544568|>},

      {<|"r" -> 0.255221, "i" -> -0.364687|>,
      <|"r" -> 0.191895, "i" -> -0.337437|>,
      <|"r" -> -0.12278, "i" -> 0.551195|>,
      <|"r" -> 0.560485, "i" -> 0.134702|>}
      }


      Given this, I can write



      testmatrix = Join[Values[matrix], 2]`


      to get a matrix, but it is a matrix of tuples. How can I get the complex number defined in each <|r -> Re[z], i -> Im[z]|> rather than the tuples?







      matrix expression-manipulation associations






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago









      MarcoB

      36.6k556112




      36.6k556112










      asked 10 hours ago









      MKFMKF

      1588




      1588






















          2 Answers
          2






          active

          oldest

          votes


















          6












          $begingroup$

          Apply[Complex, matrix, {2}]



          {{0.368252 +0.0199587 I,-0.461644+0.109868 I,-0.216081+0.562557 I,-0.479881-0.212978 I},

          {0.105028 +0.632264 I,0.116589 -0.490063 I,0.463378 +0.231656 I,-0.148665+0.212065 I},

          {0.463253 +0.201161 I,0.460547 +0.397829 I,0.222257 +0.0129121 I,0.168641 -0.544568 I},

          {0.255221 -0.364687 I,0.191895 -0.337437 I,-0.12278+0.551195 I,0.560485 +0.134702 I}}







          share|improve this answer









          $endgroup$













          • $begingroup$
            Huh, that's a great one! A word of warning though: This method produces unpacked arrays.
            $endgroup$
            – Henrik Schumacher
            3 hours ago










          • $begingroup$
            The Apply[Complex] method will also fail if the entries are not integers or inexact real numbers, e.g. Complex @@ {Pi, Sqrt[2]}.
            $endgroup$
            – J. M. is computer-less
            2 hours ago



















          5












          $begingroup$

          matrix[[All, All, "r"]] + I matrix[[All, All, "i"]]


          or



          Join[Values[matrix], 2].{1, I}





          share|improve this answer











          $endgroup$













          • $begingroup$
            Even better: Values[matrix].{1, I}, which preserves the matrix structure.
            $endgroup$
            – J. M. is computer-less
            2 hours ago











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          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%2f192530%2fobtaining-a-matrix-of-complex-values-from-associations-giving-the-real-and-imagi%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6












          $begingroup$

          Apply[Complex, matrix, {2}]



          {{0.368252 +0.0199587 I,-0.461644+0.109868 I,-0.216081+0.562557 I,-0.479881-0.212978 I},

          {0.105028 +0.632264 I,0.116589 -0.490063 I,0.463378 +0.231656 I,-0.148665+0.212065 I},

          {0.463253 +0.201161 I,0.460547 +0.397829 I,0.222257 +0.0129121 I,0.168641 -0.544568 I},

          {0.255221 -0.364687 I,0.191895 -0.337437 I,-0.12278+0.551195 I,0.560485 +0.134702 I}}







          share|improve this answer









          $endgroup$













          • $begingroup$
            Huh, that's a great one! A word of warning though: This method produces unpacked arrays.
            $endgroup$
            – Henrik Schumacher
            3 hours ago










          • $begingroup$
            The Apply[Complex] method will also fail if the entries are not integers or inexact real numbers, e.g. Complex @@ {Pi, Sqrt[2]}.
            $endgroup$
            – J. M. is computer-less
            2 hours ago
















          6












          $begingroup$

          Apply[Complex, matrix, {2}]



          {{0.368252 +0.0199587 I,-0.461644+0.109868 I,-0.216081+0.562557 I,-0.479881-0.212978 I},

          {0.105028 +0.632264 I,0.116589 -0.490063 I,0.463378 +0.231656 I,-0.148665+0.212065 I},

          {0.463253 +0.201161 I,0.460547 +0.397829 I,0.222257 +0.0129121 I,0.168641 -0.544568 I},

          {0.255221 -0.364687 I,0.191895 -0.337437 I,-0.12278+0.551195 I,0.560485 +0.134702 I}}







          share|improve this answer









          $endgroup$













          • $begingroup$
            Huh, that's a great one! A word of warning though: This method produces unpacked arrays.
            $endgroup$
            – Henrik Schumacher
            3 hours ago










          • $begingroup$
            The Apply[Complex] method will also fail if the entries are not integers or inexact real numbers, e.g. Complex @@ {Pi, Sqrt[2]}.
            $endgroup$
            – J. M. is computer-less
            2 hours ago














          6












          6








          6





          $begingroup$

          Apply[Complex, matrix, {2}]



          {{0.368252 +0.0199587 I,-0.461644+0.109868 I,-0.216081+0.562557 I,-0.479881-0.212978 I},

          {0.105028 +0.632264 I,0.116589 -0.490063 I,0.463378 +0.231656 I,-0.148665+0.212065 I},

          {0.463253 +0.201161 I,0.460547 +0.397829 I,0.222257 +0.0129121 I,0.168641 -0.544568 I},

          {0.255221 -0.364687 I,0.191895 -0.337437 I,-0.12278+0.551195 I,0.560485 +0.134702 I}}







          share|improve this answer









          $endgroup$



          Apply[Complex, matrix, {2}]



          {{0.368252 +0.0199587 I,-0.461644+0.109868 I,-0.216081+0.562557 I,-0.479881-0.212978 I},

          {0.105028 +0.632264 I,0.116589 -0.490063 I,0.463378 +0.231656 I,-0.148665+0.212065 I},

          {0.463253 +0.201161 I,0.460547 +0.397829 I,0.222257 +0.0129121 I,0.168641 -0.544568 I},

          {0.255221 -0.364687 I,0.191895 -0.337437 I,-0.12278+0.551195 I,0.560485 +0.134702 I}}








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 5 hours ago









          kglrkglr

          186k10203422




          186k10203422












          • $begingroup$
            Huh, that's a great one! A word of warning though: This method produces unpacked arrays.
            $endgroup$
            – Henrik Schumacher
            3 hours ago










          • $begingroup$
            The Apply[Complex] method will also fail if the entries are not integers or inexact real numbers, e.g. Complex @@ {Pi, Sqrt[2]}.
            $endgroup$
            – J. M. is computer-less
            2 hours ago


















          • $begingroup$
            Huh, that's a great one! A word of warning though: This method produces unpacked arrays.
            $endgroup$
            – Henrik Schumacher
            3 hours ago










          • $begingroup$
            The Apply[Complex] method will also fail if the entries are not integers or inexact real numbers, e.g. Complex @@ {Pi, Sqrt[2]}.
            $endgroup$
            – J. M. is computer-less
            2 hours ago
















          $begingroup$
          Huh, that's a great one! A word of warning though: This method produces unpacked arrays.
          $endgroup$
          – Henrik Schumacher
          3 hours ago




          $begingroup$
          Huh, that's a great one! A word of warning though: This method produces unpacked arrays.
          $endgroup$
          – Henrik Schumacher
          3 hours ago












          $begingroup$
          The Apply[Complex] method will also fail if the entries are not integers or inexact real numbers, e.g. Complex @@ {Pi, Sqrt[2]}.
          $endgroup$
          – J. M. is computer-less
          2 hours ago




          $begingroup$
          The Apply[Complex] method will also fail if the entries are not integers or inexact real numbers, e.g. Complex @@ {Pi, Sqrt[2]}.
          $endgroup$
          – J. M. is computer-less
          2 hours ago











          5












          $begingroup$

          matrix[[All, All, "r"]] + I matrix[[All, All, "i"]]


          or



          Join[Values[matrix], 2].{1, I}





          share|improve this answer











          $endgroup$













          • $begingroup$
            Even better: Values[matrix].{1, I}, which preserves the matrix structure.
            $endgroup$
            – J. M. is computer-less
            2 hours ago
















          5












          $begingroup$

          matrix[[All, All, "r"]] + I matrix[[All, All, "i"]]


          or



          Join[Values[matrix], 2].{1, I}





          share|improve this answer











          $endgroup$













          • $begingroup$
            Even better: Values[matrix].{1, I}, which preserves the matrix structure.
            $endgroup$
            – J. M. is computer-less
            2 hours ago














          5












          5








          5





          $begingroup$

          matrix[[All, All, "r"]] + I matrix[[All, All, "i"]]


          or



          Join[Values[matrix], 2].{1, I}





          share|improve this answer











          $endgroup$



          matrix[[All, All, "r"]] + I matrix[[All, All, "i"]]


          or



          Join[Values[matrix], 2].{1, I}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered 10 hours ago









          Henrik SchumacherHenrik Schumacher

          55.3k576154




          55.3k576154












          • $begingroup$
            Even better: Values[matrix].{1, I}, which preserves the matrix structure.
            $endgroup$
            – J. M. is computer-less
            2 hours ago


















          • $begingroup$
            Even better: Values[matrix].{1, I}, which preserves the matrix structure.
            $endgroup$
            – J. M. is computer-less
            2 hours ago
















          $begingroup$
          Even better: Values[matrix].{1, I}, which preserves the matrix structure.
          $endgroup$
          – J. M. is computer-less
          2 hours ago




          $begingroup$
          Even better: Values[matrix].{1, I}, which preserves the matrix structure.
          $endgroup$
          – J. M. is computer-less
          2 hours ago


















          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%2f192530%2fobtaining-a-matrix-of-complex-values-from-associations-giving-the-real-and-imagi%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

          Gersau Kjelder | Navigasjonsmeny46°59′0″N 8°31′0″E46°59′0″N...

          What is the “three and three hundred thousand syndrome”?Who wrote the book Arena?What five creatures were...

          Are all UTXOs locked by an address spent in a transaction?UTXO all sent to change address?Signing...