本文整理汇总了Python中java.lang.Math.random方法的典型用法代码示例。如果您正苦于以下问题:Python Math.random方法的具体用法?Python Math.random怎么用?Python Math.random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Math
的用法示例。
在下文中一共展示了Math.random方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gemm
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import random [as 别名]
def gemm(self, n):
import time
#from no.uib.cipr.matrix.nni import BLAS,LAPACK;
from jarray import array, zeros
from java.lang import Math, System
import no.uib.cipr.matrix as matrix
if n < 100:
r = 100
else:
r = 10
t = time.time()
#A = zeros(n*n,'d')
#B = zeros(n*n,'d')
#C = zeros(n*n,'d')
pin = range(n*n)
#for i in pin:
# A[i] = Math.random();
# B[i] = Math.random();
# C[i] = Math.random();
A = matrix.Matrices.random(n,n);
B = matrix.Matrices.random(n,n);
C = matrix.Matrices.random(n,n);
alpha = Math.random()
beta = Math.random()
print "Random numbers time: "+str((time.time() - t))
for i in range(10):
#BLAS.gemm(BLAS.ColMajor, BLAS.NoTrans, BLAS.NoTrans, n, n, n, alpha, A, n, B, n, beta, C, n)
A.multAdd(alpha,B, C)
C.scale(beta);
#E=D.mult(C, C.copy())
t = time.time()
for i in range(r):
#BLAS.gemm(BLAS.ColMajor, BLAS.NoTrans, BLAS.NoTrans, n, n, n, alpha, A, n, B, n, beta, C, n)
#D=A.mult(B, B.copy()); E=D.mult(C, C.copy());
A.multAdd(alpha,B, C)
C.scale(beta);
s = (time.time() - t)
print s
f = 2 * (n + 1) * n * n
mfs = (f / (s * 1000000.0)) * r
print str(mfs)
示例2:
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import random [as 别名]
from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ColorFontUtil
from org.eclipse.jface.dialogs import MessageDialog
from java.lang import Math
if Math.random() > 0.5:
color = ColorFontUtil.getColorFromRGB(0,160,0)
colorName = "green"
else:
color = ColorFontUtil.RED
colorName = "red"
import WidgetUtil
WidgetUtil.setBackColor(display, "myIndicator", color)
WidgetUtil.setMyForeColor(widget, color)
MessageDialog.openInformation(
None, "Dialog from Python Script", "Python says: my color is " + colorName);
示例3: createValueList
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import random [as 别名]
def createValueList(d, d1, i):
arraylist = ArrayList()
for j in range(0, i):#Generate 20 values for each serie
d2 = d + Math.random() * (d1 - d)
arraylist.add(Double(d2))
return arraylist