For those interested in the mathematical power of Jython for engineering and
scientific application I will start sending some code snippets of working
code. I find Jython (read also Python), very efficient, organized and fast
to develop any kind of application.
Here goes an easy one:
""" Use of Java arrays, sin() and cos() methods.
Java Source: "Technical Java Developing Scientific And Engineering
Applications". Prentice Hall. ISBN 0131018159
Ported to Jython by: Alfonso Reyes, October 2007
"""
import jarray
from jarray import array, zeros
from java.lang import Math
# number of points. The array will show them from 0 to (numPoints1)
numPoints = 9;
x = jarray.zeros(numPoints, "d") # array of double
y = jarray.zeros(numPoints, "d")
""" Distribute points around a circle of radius 1.0
"""
for i in range(0, numPoints, 1): # array index goes from 0 to
(numPoints1)
angle = i * 2.0 * Math.PI/(numPoints1);
x[i] = Math.cos(angle);
y[i] = Math.sin(angle);
# use C like formatting for a nice output
print "x[%d]=%12.5f \t\t y[%d]=%12.5f" % (i, x[i], i, y[i])

View this message in context: http://www.nabble.com/Usingarrayswithtrigonometricmethods.Jythonexamplestf4621352.html#a13198129
Sent from the jythonusers mailing list archive at Nabble.com.
