Quantcast

Great improvements in Groovy's performance for numerical computing

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Great improvements in Groovy's performance for numerical computing

Stergios Papadimitriou
Hi,

I'm impressed on how much Groovy's performance has improved for
numerical computing.

Groovy 1.8 in my project jlab (http://code.google.com/p/jlabgroovy/)
sometimes outperforms Scala's performance in my other project ScalaLab
(http://code.google.com/p/scalalab) !!

I think that the reason for this is that Groovy no longer generates
dynamically typed code for primitive numerical operations.


For interfacing Java scientific libraries,
the Groovy mechanism of MetaClass programming is more convenient to me,
than the implicit conversions of Scala,
and therefore that although both languages are excellent and powerful,
Groovy takes some advantage,
and therefore I resumed the development of jLab.

In the recent version of jLab, there exist Matlab-like interfaces for
both jFreeChart and the more powerful VISAD. Examples can be found at
the demos, but I also have them for convenience:

JFreeChart example:


jfigure(1)
t = inc(0, 0.01, 10);   x = sin(0.23*t)
lineSpecs = "."
jplot(t,x, lineSpecs)
jtitle("drawing multiple line styles")
jhold(true)  // hold axis
lineSpecs = ":r+"
jplot(t, 0.1*cos(9.8*x), lineSpecs)
// redefine the color of line 2
jlineColor(2, Color.BLUE)

jfigure(2)
jsubplot(222)
x11 = sin(8.23*t)
jplot(t,x11)
jhold(true)
lineSpecs = ":g"
jplot(t,sin(5*x11), lineSpecs)
jsubplot(223)
lineSpecs = ":r"
jplot(t,x11, lineSpecs)


// create a new figure and preform a plot at subplot 3,2,1
 nf = jfigure()
 jsubplot(3,2,1)
 t2 = inc(0, 0.01, 10);  x2 = sin(3.23*t2)+2*cos(0.23*t2)
 jplot(t2,x2, ".-")
jsubplot(3,2,3)
x3 = cos(2.3*t2)+9*sin(4.5*t2)
jplot(t2, x3)
jlineColor(1, Color.RED)
jsubplot(3,2,5)
x4 = cos(12.3*t2)+9*sin(2.5*t2)
jplot(t2, x4+x3)
jlineColor(1, Color.GREEN)
jsubplot(3,2,6)
jplot(t2, 6*x4+x3)
jtitle("6*x4+x3")
jlineColor(1, Color.BLUE)

// now plot again at figure 2
jfigure(2)  // concetrate on figure 2
jhold(true);
jsubplot(2, 2, 1)
vr = rand(1, 2000)
jplot(vr)
jtitle("A Random Vector")
td = t.getv()
jsubplot(224)
jplot(td, sin(1.34*td))
jplot( td, sin(3.6*td))
jtitle("Multiple Plots")



// demonstrate PieDataChart

c = new String[3];  c[0] = "Class1"; c[1] =  "Class2"; c[2] = "Class3"
v = new double[3]; v[0]=5.7; v[1] = 9.8;  v[2] = 3.9
pieChartName = "Test Pie Chart"
myPie = jplot(pieChartName, c, v)







VISAD Example (requires installation of Java 3-D)




//demonstrate Matlab-like plotting using VISAD
   // create signals
        t=inc(0, 0.01, 10); x = sin(3.4*t)
        y = sin(0.48*t)
        z = sin(5.7*x+0.2*y)

        vfigure(1);
        vsubplot(2,1,1);
        vplot(x, y, z)  // 3-D plot
        vsubplot(2,1,2);
        vplot(x, y, sin(9.8*z))

        vfigure(2);    
        vsubplot(2, 2, 1);   vplot(x, 8);  // plot with 8 point line
        vsubplot(2, 2, 2);   vplot(x)
        vsubplot(2, 2, 3);   vplot(sin(0.89*x))
        zz = z+cos(0.8*z)
        vsubplot(2, 2, 4);  vplot(z);
        vaddplot(zz)   // add the plot without erasing previous, i.e. in
"hold on" state
        zzz = zz+ sin(3.4*zz)
        vaddplot(zzz, "zzx", "zzy", 5)

   
        vfigure(3);    
        vsubplot(2, 2, 1);   vplotPoint(x);  // plot with 8 point line
        vsubplot(2, 2, 2);   vplot(x)
        vsubplot(2, 2, 3);   vplotXYPoints(x, y, "x", "y", 8)
        vsubplot(2, 2, 4);  vplot(z)
        vaddplot(zz)   // add the plot without erasing previous, i.e. in
"hold on" state
        vaddplot(zzz, "zzx", "zzy", 5)

       
   



Regards

Stergios



 





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...