How to construct matrix from vectors?

lanuradha at gmail.com lanuradha at gmail.com
Sun Jun 21 12:00:08 EDT 2015


On Sunday, 21 June 2015 20:43:15 UTC+5:30, Dennis Lee Bieber  wrote:
> On Sun, 21 Jun 2015 09:32:55 +0100, Mark Lawrence declaimed the following:
> 
> >On 21/06/2015 04:47, Nasser M. Abbasi wrote:
> >
> >>
> >> But it is not as intuitive as with Matlab
> >>
> >
> >For those of us who don't know would you be kind enough to do a cost 
> >comparison of Matlab vs Python licenses?
> 
> 	Or even Matlab vs Octave

Well if its a parentheses minimization contest, APL will beat the pants of everything.

Heres a web-session at http://baruchel.hd.free.fr/apps/apl/

   v1 ← 1 2 3
   v2 ← 4 5 6
   v3 ← 7 8 9
   v4 ← 10 11 12
   v1
1 2 3

# We need to reshape (⍴)
   v1 ← 3 1⍴ v1
   v1
1
2
3
# Likewise
   v2 ← 3 1⍴ v2
   v3 ← 3 1⍴ v3
   v4 ← 3 1⍴ v4
   v1,v2
1 4
2 5
3 6

# So we need to catenate in a different dimension

   v1⍪v2
1
2
3
4
5
6

#Likewise
   v3⍪v4
 7
 8
 9
10
11
12

# Thats the only parentheses used
   (v1⍪v2),(v3⍪v4)
1  7
2  8
3  9
4 10
5 11
6 12


# And we dont even need all these
   (v1⍪v2),v3⍪v4
1  7
2  8
3  9
4 10
5 11
6 12



More information about the Python-list mailing list