PageRenderTime 22ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/groovylab/examples/moreTest.gvl

http://groovylab.googlecode.com/
Unknown | 20 lines | 16 code | 4 blank | 0 comment | 0 complexity | 8ba0b2a155ebcacef3bb3e1105437846 MD5 | raw file
 1import static org.math.array.Matrix.*
 2import static org.math.plot.Plot.*
 3
 4def A = rand(10,3) 		// random Matrix of 10 rows and 3 columns
 5def B = fill(10,3,1.0) 	// one Matrix of 10 rows and 3 columns
 6def C = A + B 			// support for matrix addition with "+" or "-"
 7def D = A - 2.0			// support for number addition with "+" or "-"
 8def E = A * B			// support for matrix multiplication or division
 9def F = rand(3,3)	
10def G = F**(-1)			// support for matrix power (with integers only)
11
12println A				// display Matrix content
13
14plot("A",A,"SCATTER")	// plot Matrix values as ScatterPlot
15
16def M = rand(5,5) + id(5) //Eigenvalues decomposition
17println "M=\n" + M
18println "V=\n" + V(M)
19println "D=\n" + D(M)
20println "M~\n" + (V(M) * D(M) * V(M)**(-1))