[Question]
  [
I have written [a few challenges](https://codegolf.stackexchange.com/search?q=user:31516%20[matrix]%20is:question) related to matrices, and common for all are that I use a format like the one below when representing the matrices, both in examples and in test cases:
```
16    2    3   13
 5   11   10    8
 9    7    6   12
 4   14   15    1
```
This is likely a cumbersome format in many languages.
---
# Challenge:
Write a program/function that can **take a matrix on the form given in the top as input (directly copy/pasted from this post), and output the same matrix on all of the three other conventional formats shown below**. 
### The input format:
Numbers separated by a varying number of spaces, and newlines to represent rows (see test cases).
* The number of spaces between numbers are not guaranteed to be consistent. You may however assume that the last digit in each column align (if that helps any).
* There can be both integers and floats, and they can be positive, negative or zero. A matrix will not contain integers *and* floats at the same time.
* You may assume that no number is longer than 10 characters, including the minus and decimal point for negative floats.
* You may assume that there are the same number of entries in each row and in each column.
* There won't be any empty input matrices, but there can be single numbers, or matrices with only one row or column.
	+ You may in these cases choose between the output formats shown in the test cases
Your program/function must handle the input if it's directly copied from this post and pasted into the interpreter (STDIN or as function argument or something equivalent). You may have whatever you like (brackets, quotation marks, parentheses) in front of, and/or after the matrix, but you must consider the matrix a sequence of characters that can't be altered (that includes the newlines).
**To clarify:** Assume your function/program is called `f` and the matrix is:
```
1 -2
3  5
6  7
```
then you may give the matrix as function arguments like this (and infinitely many other options):
```
f(1 -2
3  5
6  7)
f([1 -2
3  5
6  7])
f("""1 -2
3  5
6  7""")
```
If your language can't, in any way, take the copy/pasted matrix as input then I'm afraid you have to pick another language.
---
### The output format:
You should output the matrix on the following three formats (order doesn't matter):
```
[[16, 2, 3, 13], [5, 11, 10, 8], [9, 7, 6, 12], [4, 14, 15, 1]]
{{16, 2, 3, 13}, {5, 11, 10, 8}, {9, 7, 6, 12}, {4, 14, 15, 1}}
[16, 2, 3, 13; 5, 11, 10, 8; 9, 7, 6, 12; 4, 14, 15, 1]
```
* You may separate the three outputs however you want (e.g. a newline)
* You must output the numbers using the same precision as the input (for instance, you must not trim the number of decimals, nor output integers as floats).
* The spaces are mandatory
* You must use `-` for negative numbers, not `_` or similar.
### Test cases:
```
16    2    3   13
 5   11   10    8
 9    7    6   12
 4   14   15    1
----
[[16, 2, 3, 13], [5, 11, 10, 8], [9, 7, 6, 12], [4, 14, 15, 1]]
{{16, 2, 3, 13}, {5, 11, 10, 8}, {9, 7, 6, 12}, {4, 14, 15, 1}}
[16, 2, 3, 13; 5, 11, 10, 8; 9, 7, 6, 12; 4, 14, 15, 1]
```
```
0.14778   0.27114   0.24415
0.45997   0.12287   0.67470
0.28945   0.37928   0.51887
----
[[0.14778, 0.27114, 0.24415], [0.45997, 0.12287, 0.6747], [0.28945, 0.37928, 0.51887]]
{{0.14778, 0.27114, 0.24415}, {0.45997, 0.12287, 0.6747}, {0.28945, 0.37928, 0.51887}}
[0.14778, 0.27114, 0.24415; 0.45997, 0.12287, 0.6747; 0.28945, 0.37928, 0.51887]
```
```
-0.0398301   0.2403455  -0.2253368   0.3565870   0.0605803   0.0830780
-0.3254422  -0.1185191  -0.2989537   0.1647319   0.3621135   0.2018815
-0.0022281  -0.3362287  -0.3568447   0.4419063   0.3801872  -0.2847033
---
[[-0.0398301, 0.2403455, -0.2253368, 0.3565870, 0.0605803, 0.0830780], [-0.3254422, -0.1185191, -0.2989537, 0.1647319, 0.3621135, 0.2018815], [-0.0022281, -0.3362287, -0.3568447, 0.4419063, 0.3801872, -0.2847033],]
{{-0.0398301, 0.2403455, -0.2253368, 0.3565870, 0.0605803, 0.0830780}, {-0.3254422, -0.1185191, -0.2989537, 0.1647319, 0.3621135, 0.2018815}, {-0.0022281, -0.3362287, -0.3568447, 0.4419063, 0.3801872, -0.2847033},}
[-0.0398301, 0.2403455, -0.2253368, 0.3565870, 0.0605803, 0.0830780; -0.3254422, -0.1185191, -0.2989537, 0.1647319, 0.3621135, 0.2018815; -0.0022281, -0.3362287, -0.3568447, 0.4419063, 0.3801872, -0.2847033]
```
```
0       4       1       0
0       0      -6       0
0       1       4      -3
2       0       0       8
0       0       0       0
----
[[0, 4, 1, 0], [0, 0, -6, 0], [0, 1, 4, -3], [2, 0, 0, 8], [0, 0, 0, 0]]
{{0, 4, 1, 0}, {0, 0, -6, 0}, {0, 1, 4, -3}, {2, 0, 0, 8}, {0, 0, 0, 0}}
[0, 4, 1, 0; 0, 0, -6, 0; 0, 1, 4, -3; 2, 0, 0, 8; 0, 0, 0, 0]
```
```
1
----
[1]     (or [[1]])
{1}     (or {{1}})
[1]     (or 1)
```
```
1 2
----
[1, 2]  (or [[1, 2]])
{1, 2}  (or {{1, 2}})
[1, 2]
```
```
4
5
----
[[4], [5]]
{{4}, {5}}
[4; 5]
```
---
I'm fully aware of [this](https://codegolf.meta.stackexchange.com/a/8077/31516), but in this challenge, the cumbersome I/O format is the whole point. The challenge will be all about formatting the output in some languages, while reading the input will be the hardest part in other languages.
Please do not be discouraged if reading the input is hard, those submissions might be the most interesting ones. Short isn't necessarily the same as impressive. And as always, explanations are encouraged!
  
[Answer]
# [Retina](https://github.com/m-ender/retina), 52 bytes
This answer is based on my [Perl answer](https://codegolf.stackexchange.com/a/129142/55508), with the help of [Martin Ender](https://codegolf.stackexchange.com/users/8478/martin-ender) for the golfing with Retina.
```
^ *
[
$
]
\s+
, 
m):`.+
[$&]
*T`[]`{}
], .
; 
^.|]$
```
[Try it online!](https://tio.run/##ZVE7UsQwDO11CheBWXY3GX38kckxlm4JEwoKCiiADrgWB@BiQbYzyyx4JnqKpPf8lLw8vD0@3y/fXzDCYR5HuNhsDJc7t4UjdDDB7esO9g6erq7nYQfH7nKC7c18nOb3T5j2boDRwd3wMXWwHOZuoejscAliDwm4UJBKwFJWcLlgKqFME4PzBWso044AcCCfktoLDpyoNi3znoL1fMg51Qoxa8ti8gmtx5p9qBVJmZtCINUE0OOAklWQVjUUH2zW6sxBJLZpCTFowppjxKAoLTdmUiwywsF75kol0kCZmkzWHGS1Fn0Syk0yMpE0W4zmxtYobpDNf6Pa9W2XvjpQ75uMrZwxNgeixk3tWlbbV8Q@lWvHr0gr4qmzYh//deic2wvwOeeE@lftFwHsh5FjAA/hBw "Retina – Try It Online")
The explanations can be found on my Perl answer. The differences are: 
```
*
[
$
]
```
Instead of `s/^ *(.+)/[$1]/gm` to both remove the leading spaces and add brackets around the lines. 
```
^.|]$
```
To remove the leading and trailing brackets for the third output.
[Answer]
## [Retina](https://github.com/m-ender/retina), ~~57~~ 54 bytes
Byte count assumes ISO 8859-1 encoding.
```
m`^ +
¶
] [
 +
, 
:`.+
[[$&]]
*T`[]`{}
], .
; 
^.|]$
```
[Try it online!](https://tio.run/##ZVFLTsQwDN37FFkMCDHTyr8kDj3GsKs6KgsWLGCB2AHX4gBcrDhNNWggUv1c2@/luX19fHt6eVi@v2CA4zwMcHXjsDzPp7AH8PIURvD0EOBu7vcwjrvraYLb@3mc5vdPmA6hhyHAqf@YdrAc591CKfjhGsQfEgixItWAtWwQSsVcQ50mhqAV11CnAwFgT5qz@Qv2nGlteqZK0XsaS8lrhZitZSlrRu@xFY1rRXLhphDJLAN02KMUE6RNDUWjz3qdOYqkNi0xRcu45pgwGkrLnZkNq4xwVGVeqUQWqVCTKVaibNaSZqHSJBMTSbPF6G58jeoG2f03ql/fdulWB6baZHzlgqk5EHNubtey@b4i/qlCO7ohbYjnzoZd@tehS24nwJecM9pftV8E8B9GgQEU4g8 "Retina – Try It Online")
The TIO link currently prints no linefeeds between the three formats but that's because it uses an unstable commit. The program does print the intermediate linefeeds in Retina 0.8.2.
### Explanation
```
m`^ +
```
Get rid of leading spaces on each line.
```
¶
] [
```
Replace linefeeds with `] [`.
```
 +
, 
```
Replace all runs of spaces with a comma and a space.
```
:`.+
[[$&]]
```
Wrap the entire thing in `[[...]]` which completes the first format. Print the result.
```
*T`[]`{}
```
Replace brackets with braces and print the result without actually changing the working string (i.e. the first format is restored after this is printed).
```
], .
; 
```
Replace `], [` with a semicolon and a linefeed.
```
^.|]$
```
Remove the first `[` and the last `]`. This completes the third format.
[Answer]
# Scala, ~~183~~ ~~181~~ 149 bytes
[Try it online!](https://tio.run/##pVRLj9MwEL77VwzWHhJIIr8fLQXtkQMnxKn0ENrsUhTSyg1oUZTfXsZxy7LsBQUr8ozn8c3M5ySnbd3W58Pnr822h/f1voOBAOyaO/iGh6wO96cF3IZQ/1x/6MO@u9/kC/jY7XtYYSQJGaWUQyngumQlcREJoLTCJ9q4IBrAVIynGCUwK6@O4bD7vu3f9U2o@0Oo7g6hqbdfsiPW6dsuJzH2csjyx1oRXBMDYOfD/EcD85tXRM@va6Jx4llGSiUBHWWklLNodgR8lDZuJtEOkX8@bXq6idn1WcWVtQ4drBKWT5ioKcU1YZXS3tvJwoVwSTNWWYY@4bzSk0VaLxKC5s7Nv72SVUx6J6f3KTbBpNJYAu1CaClNKiK10c6ySWeGacdk0jHTOkYwXAp8SYWYUjl3mnueYLzzWl4mMspK7hOkEZzLNI1gOAROH7thAsdOqVg@UVBOHTilEgwy5ZlJHUiHuTaVFQ5pknL@xVw@PHWRl28MkPqrlkRpnnn409xSEvE057d0f6M9yn/tfDz/qFsIq@xhkX4l@erNEE271UMVmmNbb5vbts3opw5e0oIuAXH/tGdvX79Y5vAKfQX6ltmJrtc3w@4alMWUgm4KWNN83GxocaLD8DxgLGDAgHGMAeub3QYP5/H8Cw "Scala – Try It Online")
## New version, using `String` replacements and regexes:
```
(x:String)=>{val d=x.replaceAll("\n *","; ").replaceAll("(?<!;) +",", ");(s"[[${d.replace("; ","], [")}]]",s"{{${d.replace("; ","}, {")}}}",s"[$d]")}
```
The new version has the same semantics and usage as the old version using `split`, `map` and `mkString`.
## Old version, using `split`, `map` and `mkString`:
### Edit: Redundant character class for space removed
```
(x:String)=>{val d=x.split("\n").map(_.trim.split(" +").mkString(", "));(d.map(x=>s"[$x]").mkString("[",", ","]"),d.map(x=>s"{$x}").mkString("{",", ","}"),d.mkString("[","; ","]"))}
```
Lambda. Execute in REPL. Accepts input as triple-quoted `String` parameter, returns output as a 3-tuple of the required outputs. The REPL renders tuples separated by commas, bordered by parentheses.
## Explanation:
### New version:
Mostly the same logic as the other regex-based answers, except for the tricky lookbehind to handle leading spaces on lines.
### Old version:
We split the input matrix representation into a 2D `String` array, then map it to a 1D array by collapsing the inner arrays by separating the elements with `,` . Finally, we just create the different outputs by collapsing the 1D arrays by using the required newline separators and boundary markers (prefixes and suffixes). It's all implemented via `split` (reading), `map` (transforming) and `mkString` (collapsing).
Example REPL session:
```
scala> val r=(x:String)=>{val d=x.split("\n").map(_.trim.split(" +").mkString(", "));(d.map(x=>s"[$x]").mkString("[",", ","]"),d.map(x=>s"{$x}").mkString("{",", ","}"),d.mkString("[","; ","]"))}
scala> r("""16    2    3   13
     |  5   11   10    8
     |  9    7    6   12
     |  4   14   15    1""")
res12: (String, String, String) = ([[16, 2, 3, 13], [5, 11, 10, 8], [9, 7, 6, 12], [4, 14, 15, 1]],{{16, 2, 3, 13}, {5, 11, 10, 8}, {9, 7, 6, 12}, {4, 14, 15, 1}},[16, 2, 3, 13; 5, 11, 10, 8; 9, 7, 6, 12; 4, 14, 15, 1])
```
For the few-element edge cases, this provides the desired output.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~63~~ 53 bytes
This was coming in at 44 bytes before I noticed that the spacing in the output was mandatory.
```
·®¸f
"[[{q"],["}]]
\{\{{q"},\{"}}}
[{q';}]"r",|;"_+S
```
[Test it](http://ethproductions.github.io/japt/?v=d2af30a143a0774cde9e8ff45afc3a55efee2383&code=t664ZgoiW1t7cSJdLFsifV1dClx7XHt7cSJ9LFx7In19fQpbe3EnO31dInIiLHw7Il8rUwo=&input=IjE2ICAgIDIgICAgMyAgIDEzCiA1ICAgMTEgICAxMCAgICA4CiA5ICAgIDcgICAgNiAgIDEyCiA0ICAgMTQgICAxNSAgICAxIg==)
---
## Explanation
```
          :Implicit input of string U
·         :Split to an array on newlines.
®         :Map over the array.
¸         :Split each element to an array on spaces.
f         :Filter to remove empty elements from the subarrays.
"[[       :Start building the output string. In Japt strings, anything enclosed in {}s will be evaluated before being added to the string.
{q"],["}  :Join the array to a string using ],[ The sub-arrays will be cast to comma separated strings in the process.
]]        :That's the first line done.
\{\{      :The start of the second line. A few bytes have to be sacrificed to esapce the {s
{q"},\{"} :Join the array to a string using },{
}}        :That's the second line done.
[         :And on to the last line.
{q';}     :This time we join the array with a semi-colon.
]"        :And that's the string completed.
r         :Except we still need to replace...
",|;"     :  All occurrences of a comma or a semi-colon with...
_+S       :  Itself and a space.
          :Implicit output of resulting string.
```
[Answer]
# [Perl 5](https://www.perl.org/), 71 bytes
69 bytes of code + `-p0` flags.
```
s/^ *(.+)/[$1]/gm;s/\s+/, /g;$_="[$_]
{".y/[]/{}/r."}
".s/], \[/; /gr
```
[Try it online!](https://tio.run/##K0gtyjH9r6xYAKQVdAsM/hfrxyloaehpa@pHqxjG6qfnWhfrxxRr6@so6Kdbq8TbKkWrxMdyVSvpVepHx@pX1@oX6SnVcinpFevH6ijEROtbA9UV/f9voAABJlDaEEobcMFkoLSuGYaMIapeXWMuI1Q9cNoC3TQEDQA "Perl 5 – Try It Online")
**Explanations**
`s/^ *(.+)/[$1]/gm;` adds `[]` around each line while removing the leading spaces.  
`s/\s+/, /g;` replaces runs of spaces and newlines with a comma and a space.  
The first output is then obtained by surrounding with braces: `[$_]`.  
The second needs to replace braces with curly bracket (`y/[]/{}/r`) and surround with curly brackets `"{" ... "}"`.  
For the third, `], [` are replaces with a semicolon and a space (`s/], \[/; /gr`).
---
After writing this solution, I tried adpating Martin Ender's Retina answer, but it ended up 10 bytes longer ([TryItOnline](https://tio.run/##ZYyxDsIwDER3f4UJ3WjiFApCqvgSYzqhLiBFzYSifHuwRAAVvLzTne/Cdb7ty3oVlGiDL5EuuCGa7kMkIEGmSZVaLapqxpNhbkYRSMm4B7FQyjQ7kzOwcZGkxTPToM9qiinF4@v6yq7SwzuptIe/pFt27Q62y86Hx9@1L58)):
```
s/^ +//gm;s/
/] [/g;s/ +/, /g;$_="[[$_]]
{{".y/[]/{}/r."}}
[".s/], \[/; /gr."]"
```
For this version, see Martin's [answer](https://codegolf.stackexchange.com/a/129138/55508) for the explanations.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 60 bytes
```
`jtU&D32', 'XHYXw]xXhH&Zc91wh93htD[]&D{}&DXED&GxvUH&4$'; 'TD
```
[Try it online!](https://tio.run/##y00syfn/PyGrJFTNxdhIXUdBPcIjMqI8tiIiw0MtKtnSsDzD0jijxCU6Vs2lulbNJcLVRc29oizUQ81ERd1aQT3E5f9/QwUjLmMFEy5TBTMuLgA "MATL – Try It Online")
Thanks a lot to Luis Mendo for shaving off a quarter of my bytecount in a masterclass in chat. 
Paste the input, followed by an empty line.
```
% Act I: Taking input.
`jt             w]    % Take input line by line until an empty line is encountered.
   U                  % Convert string input to numerical row array
    &D                % Convert back to string, adding brackets and single spaces
      32', 'XHYX      % Add commas before the spaces. Store ',  ' in clipboard H.
% Act II: Nested square brackets
x                     % Discard the tab character
 Xh                   % Concatenate all strings as cell array.
   H&Zc               % Join all the strings together, using clipboard H as a separator
       91wh93h        % Wrap in square brackets (ASCII 91 and 93)
              tD      % Display a copy of the result.
% Act III: Nested curly brackets
[]&D{}&D              % Convert empty array and cell array to string.
        XE            % Use to substitute square for curly brackets.
% Act IV: MATLAB-style input.
&Gxv                  % Get all the input again, discard the tab, and concatenate vertically.
    U                 % Convert to numerical 
     &4$     TD       % Convert to string, using row- and column separators
        H'; '         % Namely, clipboard H and a semicolon.
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~45~~ 44 [bytes](https://github.com/Adriandmen/05AB1E/blob/master/docs/code-page.md)
```
|„  ð:ðδÛ˜ð¡„, ý''KD…[ÿ]=„[]„{}‡,"], ["„; :=
```
[Try it online!](https://tio.run/##MzBNTDJM/f@/5lHDPAWFwxusDm84t@Xw7NNzDm84tBAopqNweK@6urfLo4Zl0Yf3x9oChaJjgUR17aOGhTpKsToK0UpArrWCle3//4ZmCkBgBCKMgdjQmEvBFEQbgggDkLAFl4IliDYHESDVhkZcCiYgGkyAVCsYAgA "05AB1E – Try It Online")
**First output**
```
|                           # push a list of the inputs
 „  ð:                      # replace any instance of 2 spaces with 1 space
      ðδÛ                   # remove any leading spaces
         ˜                  # flatten to a 1D list
          ð¡                # split on spaces
            „, ý            # merge on ", "
                ''K         # remove all single quotes
                   D        # duplicate for use in output 3
                    …[ÿ]    # interpolate between square brackets
                        =   # print without popping 
```
**Second output**
```
„[]„{}‡,                    # translate square brackets to curly brackets and print
```
**Third output**
```
                            # the copy from the first output is used here
 "], ["„; :                 # replace "], [" with "; "
           =                # print
```
[Answer]
# [Python 2](https://docs.python.org/2/), 143 bytes
```
import re
b=re.sub
def f(s):s='[['+b('\n','], [',b(' +',', ',b('\n +','\n',s)))+']]';print s,b('\[','{',b('\]','}',s)),b('\], \[','; ',s)[1:-1]
```
[Try it online!](https://tio.run/##JYzBDoIwDIbve4qGS1mYxoGiQniSsQsRIgcH2fBgjM8@29Gk/9@//bb1sz0XV8Y4v9bFb@BHMXR@PIb3IB7jBFMeZBM6NAaLIcfeoUKrwKCiBAUlBWnuXUoMBCllgdZiu/rZbRDSnZ7gd0ctjb/E7VFBurbAO6Obg7ZxyrMs0zVQlSwVta4EXNg1y4nXNwF39isL07oUcGZPwjTomr6S8Q8 "Python 2 – Try It Online")
[Answer]
# Javascript (ES6), ~~121~~ ~~110~~ 106 bytes
-15 bytes thanks to @Shaggy and @Justin
```
m=>`[[${(a=m.split`
`.map(x=>x.match(/\S+/g).join`, `)).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`
```
Example code snippet:
```
f=
m=>`[[${(a=m.split`
`.map(x=>x.match(/\S+/g).join`, `)).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`
console.log(f(
`1 -2
 3  5
 6  7`
))
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~163~~ ~~152~~ ~~150~~ 145 bytes
*-5 bytes thanks to Felipe Nardi Batista who suggested the use of splats (sorry, I just need an excuse to say that word :P).*
```
import re
a=str.replace
def f(s):r=a(`[re.findall('[\.\d]+',i)for i in s.split('\n')]`,"'",'');print r,a(a(r,*']}'),*'[{'),a(r[1:-1],'], [','; ')
```
[Try it online!](https://tio.run/##TY5Bb4QgFITv/IoXLw9algjCgrvZX6ImS7qaklg16KVp@tst6KWXmcc3kwnL9/Y5T2rfw9cyxw1iT/xj3aKI/TL6j568@gEGurJbfHj6bGIvhjC9/DhSbFrRvrp35IENc4QAYYJVrMsYNorthKx78gILjsjuSwxTWueeehr5G3a/yJI1P8kSaeTtIjuOHYcGOd4B2T7QoigkXBSpAAy5AtgEGCFnkN4AKkuKQVYETHaZpczYEaiz2yy5LRUBnf2Q3Ab5b7EUUlvrEi2FsvJopUtraUgptKlrexCplDuvq9W2TJlytTYHqWytzgUjnTv@u/8B "Python 2 – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~184 178 174 173 169 163\* 157\*~~ 153 bytes
**Input/Output Format:** Output with a space between the matrices and input with this function call (as shown on TIO):
```
g("""<paste matrix here>""")
```
This is the function :
```
def g(s,r=str.replace):a=str([[[int,float]['.'in y](y)for y in x.split()]for x in s.split('\n')]);print(a,r(r(a,*'[{'),*']}'),'['+r(a,'], [','; ')[2:-1])
```
[Try it online!](https://tio.run/##rVFBboMwELz7Fav0YNwCYg3EkKgvoRxocFIkBMhYTVDVt1MvpK3SXmPJO@tZe3ZsD5N967t4nmt9hJM3@uZ5tCY0emirgxa7ipZeURRNZ/1j21e2LHjImw6m0pvEsTcwgVtdwnFoG@uJkqgLUeOV4i8dF6XYD8ZpeJVvPOPiIy8@uHBQfjrgBX8ilpc@FNzne@CikLsASzGzk7fZbKIQE6UyAIhCqRCTNUsSTFkUJmmeq4VBKbM126pERa4mszxJFyZWuVwVUswy5VQFY6stAct4gKqudU32e1NrA7aHVlfvGjp9bptOj/Cq7VnrDqweLRyqUY9sdYhbUpAUYjcxZkBtESlERGcMckLyB7QbJQO6yHIbpN2Ad3YVrRJLm0X/iu5lvrMVgu2/Ct6eDWImb8/8YPZX7Rfv/cr31oMgdX@hCIIMAvdTAWIUOR5z6jV/AQ "Python 3 – Try It Online")
---
\**Saved a 6 bytes thanks to @officialaimm (from 169 to 163 bytes).*
\**Saved 4 bytes thanks to @FelipeNardiBatista.*
---
Explanation to come after further golfing.
[Answer]
# C, 415 bytes
```
#import<stdio.h>
#define A(a,c,o)for(l=strlen(a)-o,k=0;c[k];)a[l+k]=c[k++];
j,k,l;main(i){char s[999],a[999]="[",b[999]="{",c[999]="[",t[]=" ";for(;fgets(s,999,stdin);){A(b,"{",0)A(a,"[",0)for(i=0;s[i];++i){j=0;for(;s[i]-32&&s[i]-10&&s[i];++i){j=1;t[0]=s[i];A(c,t,0)A(b,t,0)A(a,t,0)}if(j){A(c,", ",0)A(b,", ",0)A(a,", ",0)}}A(c,"; ",2)A(b,"}, ",2)A(a,"], ",2)}A(c,"]",2)A(b,"}",2)A(a,"]",2)puts(a);puts(b);puts(c);}
```
It's a monster and waaayyyy too long, but I'm done with it. Should have gone for a different approach probably.
[Try it online!](https://tio.run/##RY/djoMgEIXvfQpikwbidCO2@2NYN@lzEC6Qaku12ih71fjsLoN2S8KcM8MHM5jd2Zh53tjbvR/c9@hOtn@7/ESbU1XbriJHqsFAz@p@oG0xuqGtOqrZroemSIWRjRJMyzZpVOGTJFEiukIDrbhp21HLHuaiBzLKPM8V6CBFLGMoV/uIwbyqTnolscBuoj5XbqQj@FPAuTom2ONIS8BLKcPJ8E4aZrN@mlFaJZLEN736LLyBpd0@226D4elinhAXTqaqCKUjNeDCs@WqOuhka3rFvgZiIPFK/Fv9tNMUEOGTbEEmWL1n1OIXRr2QF4Du/us/rJkIWq5qmJjmmX8QvzIMe7/5PiLvqBxDiuWviOSonxiQ5llEDqghIE34Hw)
[Second test case](https://tio.run/##RY/RjoIwEEXf/QqCiWnDSFqELaTLJn4H6UOpoBUEA@yT4dvZtuD6dM/cuZ2ZquNVqWXZ68ezH6bvcbroPrz97PaXqtZd5Z2RBAU9rvsBtfk4DW3VIYmPPTQ54apoBMeyaING5KYIAsF3d2ig5Q@pO6TxS93k4I1FlmUCpJPcL3woN3z5oD7uVBj1fG638fpaTSMawXTB3tVhjl9nVIJ9RLC9zL4h7jZtrhkLLXgQmKV3U7kZ1jqeosPBASUrvEOUTwURubPOSMHkxpabSqezrtHd7lXgg@dviX@Ub5xnF@GmiNbIDBubjFh5zYhP5BOw9Pw1H5aYOy03VZjPy0JCGjOWep5HwohRGq8UxzTZkTBOsow5h0ZRutIXixkxvSjN4sQ5J5ZF64SEpin7Aw)
|
[Third test case](https://tio.run/##RY/NbsIwEITvPIWVSlWsGLT@S2y5qcRzRDkYEyBASUXSE8qzU/@k5TSfNzM7G7c@Ovd8vvVf38N9@hinfT9sTp@rt3136G8d2uaWODLgw3DPr/U43a/dLbd4PZBLDcY1l9Zg21yLS1v7R1G0ZnUmF3I1X7a/5T1@uJO9o7HRWrfERqmzJiO7BR8Zca/p1HhFmQlt5nDspjEfif9Kwl03bPBjm@9ICAEOl4UMxNt6f83Y9K0pCl969q@4I4zWnL2/R6CQ4M9EzdRAW8fRNndkimt3i9qoc3/Iz6HXkYygbHH8o/3DeY4W4x8sWWaysPe0iZOnfVlehkDfP/6HLTZRd4s6bObncw0b4FpxoAgh2DABXEiJkJ8zJjkvVZxzWUpVQWQoQSrgiX2yUrDyds6kEIzFKKVKUk3TGq205FW001JUnOq0smSUcplqgSpFZVgDwBhTKerrPVeJZamESGuEoBrKdAFXPlulWqZEBZz/Ag)
|
[Fourth test case](https://tio.run/##ZY9NboMwEIX3nAIRKbLFUJmkqhq5VOIclhfGgcRAIAJ3FXF2ahsTlNab783Mmx/L5CLlPO/U7d4P@mvUZ9W/Xb@D3bmsVFeGORIgocdVP6A2G/XQlh0SOOmhyQiVrOEUC9bGDc9MEMecBjU00NKbUB1S@CGvYghHdjqdOAiHLGIRFF4@IpBbVjPDMKJ2G60upR7RCKYK9q4OU/zIUQG2iWB7me0h7jZlrhmZ4jSOzdLaRG6GTSXHw37vREoWsZpSqhnhmUvlSIJ2YwtP4TipCtV2r4QIwsg7nlKscpqchZrgsFgm8Np4@KIXD98sm8Gq@4/5sMDUsfCUmE7zTMLlvXumniRYK57Jx79K@tqbHIPDa8@Tn3@nbfwF)
|
[Fifth test case](https://tio.run/##RY/BjoMgEIbvfQpDkwbiuNHuyUzdxOcgHJBqi1pthD0Zn90FtOvp/2f4ZuZHJQ@l1vWsX@9xsjdj73r8ev6czve60UMdlVSCgpE140T7wtiprwcqWTJCV6SoeCeQSd7HnShcEccCTy100ONL6oFqNqunnCLD8zwXIIMUhBOodjsTUEfXcqcRQX8Nm0dtDTXgXsHnGhiyuaQV@KGU@WR@Jg3ZtEtjuBYYx@5o66qww7eS7@vlEkyWbuYDZWh5KorQKqkCG9ZWu8qgi25o6@8qIBCRnfi38mOXJSDoiuuGLLB7x4jNb4w4kAPw7v3rPiwZBq12VQyXdc3@AA)
| [Sixth test case](https://tio.run/##RY/BjoMgEIbvfQpDkwbiuNHuyUzdxOcgHJBqi1pthD0Zn90FtOvp/2f4ZuZHJQ@l1vWsX@9xsjdj73r8ev6czve60UMdlVSCgpE140T7wtiprwcqWTJCV6SoeCeQSd7HnShcEccCTy100ONL6oFqNqunnCLD8zwXIIMUhBOodjsTUEfXcqcRQX8Nm0dtDTXgXsHnGhiyuaQV@KGU@WR@Jg3ZtEtjuBYYx@5o66qww7eS7@vlEkyWbuYDZWh5KorQKqkCG9ZWu8qgi25o6@8qIBCRnfi38mOXJSDoiuuGLLB7x4jNb4w4kAPw7v3rPiwZBq12VQyXdc2i6x8)
| [Seventh test case](https://tio.run/##RY9BboMwEEX3OQVypMgWQ0XSdIGmVOIclhfGgcRAIMLuCnF2ahtSVv/P@M3Mt0ruSi3LUT9fw2i/jb3p4ePxczjeqlr3VVRQCQoGVg8j7XJjx67qqWTJAG2eouKtQCZ5F7cid0UcCzw00EKHT6l7qtmkHnKMDM@yTIAMkhNOoNzsREDtXcudRgT9NazvlTXUgHsFn6tnyKaCluCHUuaT@Zk0ZNMujeFaYBy7o42rwg7fSj4vp1Mw53Q1b@iMlqciD62CKrBhbbmpDDrrmjb@rgICEdmIfyvfdp4Dgq64rMgMm3eMWP3KiB3ZAe9ev@7DkmHQclPFcF6W6@HrDw)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 37 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
j€⁾, j⁾; ⁾[]j
ỴḲLÐf$€VµŒṘṄ“[]“{}”yṄȧÇ
```
A full program printing the three formats on three lines.
**[Try it online!](https://tio.run/##y0rNyan8/z/rUdOaR437dBSygKS1ApCIjs3ierh7y8Mdm3wOT0hTAcqHHdp6dNLDnTMe7mx51DAnOhZIVNc@aphbCRQ4sfxw@////w3NFIDACEQYA7GhMZeCKYg2BBEGIGELLgVLEG0OIkCqDY24FExANJgAqVYwBAA "Jelly – Try It Online")**
### How?
```
j€⁾, j⁾; ⁾[]j - Link 1, create the 3rd format (semicolon-style): list of lists
  ⁾,          - literal [',', ' ']
j€            - join for €ach (place ", " between the elements of each row)
      ⁾;      - literal [';', ' ']
     j        - join (place "; " between the rows)
         ⁾[]  - literal ['[', ']']
            j - join (surround the whole result with a pair of brackets)
ỴḲLÐf$€VµŒṘṄ“[]“{}”yṄȧÇ - Main link: list of characters
Ỵ                       - split at newlines
     $€                 - last two links as a monad for €ach row:
 Ḳ                      -   split at spaces
   Ðf                   -   filter keep those for which the following is truthy:
  L                     -     length (this removes all the empty lists "between" spaces)
       V                - evaluate as jelly code (yields a list of lists of numbers)
        µ               - monadic chain separation, call that x
         ŒṘ             - get a Python string representation of x
           Ṅ            - print that (the 1st format) plus a newline, and yield it
            “[]“{}”     - literal [['[', ']'],['{', '}']]
                   y    - translate (converts all '[' to '{' and all ']' to '}')
                    Ṅ   - print that (the 2nd format) plus a newline, and yield it
                      Ç - call the last link as a monad with argument x
                     ȧ  - logical and
                        - implicit print of the result (the 3rd format)
```
[Answer]
# [V](https://github.com/DJMcMayhem/V), 41 bytes
```
òJé;òÓ¨ä©ó«/±, 
yss]Y.pkÓ; /], [
Ùòcs]}f[
```
[Try it online!](https://tio.run/##ATwAw/92///DskrDqTvDssOTwqjDpMKpw7PCqy/CsSwgCnlzc11ZLnBrw5M7IC9dLCBbCsOZw7Jjc119Zlv//zI "V – Try It Online")
### Explanation
```
òJé;ò            Join all lines with `; ` (trailing single space)
     Ó¨ä©ó«/±,   :s/\v(\d)\s+/\1, /g
yss]             Surround everything with brackets (completes [x,x;x,x])
Y.pk             (Y)ank, surround with brackets again, (p)aste.  Adds [[x,x;x,x]]
    Ó; /], [     :s/; /[, ]/g (transforms to [[x,x], [x,x]])
Ù                Duplicate this line
 ò               recursively
  cs]}           (c)hange (s)urrounding [] with {}
      f[         go to the next [ until there are none
```
[Answer]
# [R](https://www.r-project.org/), 132 bytes
```
function(x,p=paste0,g=gsub)cat(z<-p('[[',g('\n','], [',y<-g('[:blank:]',', ',x)),']]'),chartr('[]','{}',z),p('[',g('
','; ',y),']'))
```
[Try it online!](https://tio.run/##JY7NboMwEITveQrfjCUTrb3@WafhSSgHggqpWlFEiJSk6rPTBd/G45lvdl77au3vY7d8/ozFQ0/V1N6WD9BDNdzuF9W1S/E6l1Mh61rqoZDvo9Sy0YJfz3PJRn26fLfj16lhXwupH0pxoJFKd9d2XmZObF@/f1K/lN5AO@fA3hvHn1taKrX2hSzhCJgIwQgh4GgdoPNeCPat9YiBdh998BRh1xDAE2DW3IwEB46j9c5Zu1eNIW@SyZhEyWPc4ya4iCZlZLDGoM@zYIiM3zAA1lrKVZ5nHbP2gZzLGOdMgpAvQOJuzLOWXAREqdZ/ "R – Try It Online")
an anonymous function. Takes input like
```
f('1 -2
3 5
6 7')
```
It prints them in the same order as the test cases, but with spaces as the separator.
### Explanation:
It first swaps spaces with `,`  and saves the result as `y`. Then it swaps newlines with `], [`, puts `[[` and `]]` on either end, and saves the result of that as `z`.
Next, `chartr` switches `[` with `{` and `]` with `}` in `z`.
Finally, it takes `y`, swaps newlines with `;`  and puts `[` and `]` on either end.
Then all the results are passed in that order to `cat` which prints them out, all nicely formatted, and separated by a single space.
Mildly ungolfed:
```
function(x)
  cat(
    z<-paste0('[[',gsub('\n','], [',y<-gsub('[:blank:]',', ',x)),']]'),
    chartr('[]','{}',z),
    paste0('[',gsub('\n','; ',y),']'))
```
[Answer]
# Java 8 with Netbeans 8+, 209 bytes
Count is 208 from the code, plus 1 bytes to run it by pressing `F6`.
Cumbersome answer for cumbersome challenge :p
```
interface M{static void main(String[]a){String s="";s=s.trim().replaceAll(" +",", ").replaceAll("\n(, )?","; ");System.out.println("["+s+"]\n[["+s.replace("; ","], [")+"]]\n{{"+s.replace("; ","}, {")+"}}");}}
```
How to use?
Within Netbeans, paste this code in a file called `M.java`. Then copy the matrix you want to use. Then between the two consecutive characters `""`, press `ctrl`+`v` as required by the challenge.
Now press `F6`! This will compile the code, run it and output the expected matrix representations.
[Answer]
# Mathematica, 129 bytes
```
s=StringSplit
r=StringReplace
Print[#,n,#~r~{"{"->"[","}"->"]"},n,#~r~{"{{"->"[","}}"->"]","}, {"->"; "}]&@ToString@s@s[#,n="
"]&
```
The third and fourth lines together define a pure function taking a string as input; for example, if we set `f=Print...&`, then the last test case would be called as:
```
f@"4
5"
```
The snippet
```
ToString@s@s[#,n="
"]
```
parses the input string as a matrix (of strings—we never try to interpret the entries as numerical quantities) and converts the resulting expression back to a string; this automatically generates the output format with curly braces. Then `Print[#,n,#~r~{"{"->"[","}"->"]"},n,#~r~{"{{"->"[","}}"->"]","}, {"->"; "}]` prints that output format and the two others, separated by newlines, by using straightforward string replacement rules.
[Answer]
# [Pip](https://github.com/dloscutoff/pip), ~~49~~ 46 bytes
45 bytes of code, +1 for `-r` flag.
```
g|>:sYP(RPg^w)R';kPyR'['{R']'}O'[OgRwkJ"; "']
```
Takes input from stdin. [Try it online!](https://tio.run/##K8gs@P8/vcbOqjgyQCMoID2uXDNI3To7oDJIPVq9Okg9Vr3WXz3aPz2oPNtLyVpBST32/39DMwUgMAIRxkBsaMylYAqiDUGEAUjYgkvBEkSbgwiQakMjLgUTEA0mQKoVDP/rFgEA "Pip – Try It Online")
### Explanation
```
                 Preset variables used: s is " ", w is regex `\s+`, k is ", "
g                With -r flag, g is a list of lines from stdin
 |>:s            Left-strip spaces from (elements of) g and assign back to g
YP(RPg^w)R';k
     g^w         Split (elements of) g on runs of whitespace
   RP            Apply Pip's built-in repr, which wraps lists in [] and separates items
                   with ; (e.g. [[1;2];[3;4]])
  (     )R';k    Replace the semicolons with ", " to obtain format #1
YP               Print and yank into y variable
PyR'['{R']'}
 yR'['{          In y, replace [ with {
       R']'}     and ] with }
P                and print (format #2)
O'[OgRwkJ"; "']
O'[              Output [ with no newline
   O             Output with no newline:
    g              Take g (list of lines of stdin, with leading spaces stripped)
     Rwk           Replace runs of whitespace with ", "
        J"; "      and join lines on "; "
             ']  Print the final ] to complete format #3
```
(This explanation format feels a bit convoluted to me, so let me know if anything didn't make sense.)
[Answer]
# SCALA, 590 bytes
Was hard, but I think I'm done with it
```
var o=s.replaceAll("  *"," ").replaceAll("\n ","\n")
var z=o.split("\n")
var h=z.length
var k=new Array[Array[String]](h)
for(i<-0 to h-1)k(i)=z(i).split(" ")
var u=k.length-1
print("{")
for(i<-0 to u){print("{")
for(j<-0 to k(i).length-2)print(k(i)(j)+", ")
print(k(i).last)
print("}")}
print("}[")
for(i<-0 to u){print("[")
for(j<-0 to k(i).length-2)print(k(i)(j)+", ")
print(k(i).last)
print("]")}
print("][")
for(i<-0 to u-1){for(j<-0 to k(i).length-2)print(k(i)(j)+", ")
print(k(i).last)
print("; ")}
for(j<-0 to k(k.length-1).length-2)print(k(u)(j)+", ")
print(k.last.last)
print("]")
```
Quick explanation : I take input surrounded by triple quotes, then take off unrequired spaces ; split the string two times (once for lines and once for columns) ; and I print with my three routines. It might be possible defining a function to mutualize, but I don't know how.
[Try it online!](https://tio.run/##rZLBcoMgEIbP5Sl2OEEbnWhMD2095AF66tF4oIZEDUUHSZvq@OwWo8aktrcwzML@C9/P7FBETLAme095pOGVJRL4UXO5KWCV5xW62/AtfDCtkiMpnt7MKne0aj6ZgswvbMVzwSK@EoJggHs8w4DplbqWYNS1xBS1l0o/s4tcJJqMWuyXtuByp@NTuvcl/4KVUuw76GJnG4YkpmibKZK8WHPQGcSWQ/ckoX5pwoCFnnrw9z3VclBuAKZW4WvAgVa/KmlfabHDdZd2h1qNpPQBz1qPUbMFK/Qg4BrT@rwP/jUMbmYYXhiGE0PTouo2Ps/QGl2zxhb/AT1MoSfi5PlNjfovhjF2wHJhGAt7YQaCUQDwlp6ZbeK4F5UlwKM9d7rEcw2Jorr5AQ)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 34 bytes
```
|εð¡õK}€ï"ÿ"Ð„[]„{}‡s¦¨"], ["„; :»
```
[Try it online!](https://tio.run/##MzBNTDJM/f@/pqzy8IZDCw9v9a7VfNS05vB6pcP7lQ5PeNQwLzoWSFTXPmpYWHxo2aEVSrE6CtFKQCFrBatDu///NzRTAAIjEGEMxIbGXAqmINoQRBiAhC24FCxBtDmIAKk2NOJSMAHRYAKkWsEQAA "05AB1E – Try It Online")
`ε...}` has been replaced with `vy...})` on TIO since it hasn't been pulled there yet.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 214 bytes
```
(s)=>{var result=Regex.Replace("[["+Regex.Replace(s.Replace("\n","], [")," +(\\d)",", $0")+"]","  +"," ").Replace("[, ","[");return$"{result}]\n{result.Replace('[','{').Replace(']','}')}}}\n[{result.Replace("[","").Replace("],",";")}";};
```
[Try it online!](https://tio.run/##XVBNa8MwDL37VwhTSEy9tln3iddeygaF7bINdnB8CKnbBTKn2E7pCP7tmbyOtszg9@SnZ0modBdlY3Xfusps4O3bef0lyPlr9K73fvSqN21d2Mf91mrnqsY40Zd14RxsO@J84asSdk21gpeiMqnzFgtItWQxGWMo7AZmsJQTJchTa8qHg84PNIc1Zsl4vGhWGj611SR1bDbvdoUF7NjWfpZSKekQB9F7HGdbF6VO3TGiuaGcKg6SMk5hmOb5iqHCYZBRNqSKspNXcsAUOoXVvrVmQLtDk6By8xce3YlMeNIlp@@JQiEkLISQG/nfjmU5PW@mcAgqKAtUBEEWuLqm1qMPW3n9XBmdrlPcDWOCBBL6vs9uAM9lhCnebErgOnIWYRLlOwL3kW8jRHd2SeAq8i9EN2Q/ "C# (.NET Core) – Try It Online")
Takes the Matrix as a string, returns the three formats as a single string separated by newlines.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 38 bytes
```
≔Ｅ⪪θ¶⪫Φ⪪ι λ, θＥ⪪[]{}²⪫ι⪫Ｅθ⪫ιλ, ⪫[]⪫θ; 
```
[Try it online!](https://tio.run/##XYzNCsIwEITveYqwpxQqmNZfevLiQRBEj7WHIkEXQtqmpRfx2eNuaVVcsvNBZnZuj9LfqtKGsGtbvDt1LGt1qS12qoklXB1EsTxU6NQebWf86CF5ki1LC/QiYhNl4uTRdT8lkBfPFwWSqQb/2Iw8m9741ij8FNJMfUOCquB7BNmQyULIAUCvJE3CktLqVMglU7PM@Xsj5Ja5ZuG0ToRcMAfhtNTUVIRZb98 "Charcoal – Try It Online") Note: Trailing space. Link is to verbose version of code. Charcoal has a multiline input option delimited using `["""` and `"""]`. Explanation:
```
   θ                Input string
  ⪪ ¶               Split on newlines
 Ｅ                  Map over each line
        ι           Current line
       ⪪            Split on spaces
      Φ   λ         Filter out empty strings
     ⪫     ,        Join with `, `
≔            θ      Assign resulting array to variable
```
This takes the input and prepares it by splitting it into lines and normalising the separators.
```
 ⪪[]{}²             Split `[]{}` into substrings of length 2
Ｅ                   Map over the substrings
          Ｅθ        Map over array from above
            ⪫ιλ     Wrap each element with the substring
         ⪫     ,    Join elements with `, `
       ⪫ι           Wrap with the substring
                    Implicitly print each result on a separate line
```
This handles the `[[ ... ], [ ... ]]` and `{{ ... }, { ... }}` cases.
```
    θ               Array from above
   ⪫ ;              Join elements with `; `
⪫[]                 Wrap result with `[]`
                    Implicitly print
```
This handles the `[ ... ; ... ]` case.
Before I golfed a byte off the above solution I used to have two 39-byte solutions; this is the other:
```
⮌Ｅ⪪[]{}[]²⪫ι⪫ＥＥ⪪θ¶⪫Φ⪪λ ν, ⎇κ⪫ιλλ⁺§;,,κ 
```
[Try it online!](https://tio.run/##RYzNCsIwEITvfYplTylEMPUfT14EBaGot9pD0YDBEGtaRRGfPe7WShdmBjJf5ngu/PFa2BBSb1wttvqhfaXFpijFrrSmFpjl70@Wo4QklrC@GidMmwx14E0CHhz@oaWxtfZtZ6kDrhyJpjCm3GvvCv8Sl27Wxiyy1N4rsahX7qSfAudS0qdL/Ftpbh5ChohqDHQJ24CkBhGMOBVbn5@nEcw4J2xMqySCIWdjTIOipTz0HvYL "Charcoal – Try It Online") Note: Trailing space. Link is to verbose version of code. Explanation:
```
  ⪪[]{}[]²                              Split `[]{}[]` into substrings of length 2
 Ｅ                                      Map over the substrings
                θ                       Input string
               ⪪ ¶                      Split on newlines
              Ｅ                         Map over each line
                     λ                  Current line
                    ⪪                   Split on spaces
                   Φ   ν                Filter out empty strings
                  ⪫     ,               Join with `, `
             Ｅ                          Map over each line
                          ⎇κ   λ        If outer index is zero, just use the line
                            ⪫ιλ         Otherwise wrap the line in the substring
            ⪫                   ⁺§;,,κ  Join with `; ` or `, ` per outer index
          ⪫ι                            Wrap in the substring
⮌                                       Reverse the order of the results
                                        Implicitly print each result on a separate line
```
]