RuleOfCramer/generate.py

42 lines
731 B
Python
Raw Permalink Normal View History

2016-08-07 12:24:41 +02:00
'''
Created on 06.08.2016
@author: wn
'''
2016-08-09 16:55:30 +02:00
from __future__ import print_function
2016-08-07 12:24:41 +02:00
import random
2016-08-09 16:55:30 +02:00
2016-08-07 12:24:41 +02:00
order = 10
lowerBound = 0.0
upperBound = 1000.0
2016-08-09 16:55:30 +02:00
resultForFortran = []
cntForFortran = 0
2016-08-07 12:24:41 +02:00
matrix = []
2016-08-09 16:55:30 +02:00
2016-08-07 12:24:41 +02:00
for i in range(order+1):
vector = []
for j in range(order):
2016-08-09 16:55:30 +02:00
f = random.uniform(lowerBound, upperBound)
vector.append(f)
if i < order:
print("%f, " % f, end="")
cntForFortran += 1
if (cntForFortran == 5):
cntForFortran = 0
print(" &")
else:
resultForFortran.append(f)
2016-08-07 12:24:41 +02:00
matrix.append(vector)
2016-08-09 16:55:30 +02:00
print("")
for i in range(order):
print("%f, " % resultForFortran[i], end="")
print("")
print("")
2016-08-07 12:24:41 +02:00
print(matrix)