Beispiel #1
0
#!/usr/bin/python3
import numpy
import np
import random
import math

random.seed()

SIZE = 1500
a = []
for i in range(SIZE):
    b = []
    for j in range(SIZE):
        b.append((random.randint(-100, 100)) / (i + j + 1))
    a.append(b)

y = np.matrix(a)
print(SIZE)
for i in range(SIZE):
    for j in range(SIZE):
        print(y[i].transpose()[j].item(), end=" ")
    print()

print(numpy.linalg.det(y))
Beispiel #2
0
#!/usr/bin/python3
import numpy
import np

y = np.matrix ( ((1, 2, 3), (2, 0, 4), (3, 4, 5)) );
print(3)
for i in range(3):
    for j in range(3):
        print(y[i].transpose()[j].item(), end=" ")
    print()

print(numpy.linalg.det(y))
Beispiel #3
0
import np

def f(x):
    return 1 if x >= 0 else -1

x = [];
w = [];

x.append( np.matrix((-1, 1, -1, 1)) )
x[0] = x[0].transpose()
x.append( np.matrix((1, -1, 1, 1)) )
x[1] = x[1].transpose()
x.append( np.matrix((-1, 1, -1, -1)) )
x[2] = x[2].transpose()

for i in range(len(x)):
    w.append( x[i]*x[i].transpose() )

W = w[0]
for i in range(1, len(w)):
    W = W + w[i] 

for i in range(len(W)):
        W[i].transpose()[i] = np.matrix([[0]])

border = 50

finished = False
times = 0
coll = []
print("Print 4 numbers: it'll be the vector to identificate")
Beispiel #4
0
import np
import random

inf = float("inf")

L = np.matrix( 
((inf, 38, 74, 59, 45),
(38, inf, 46, 61, 72),
(74, 46, inf, 49, 85),
(59, 61, 49, inf, 42),
(45, 72, 85, 42, inf)) )

tau = np.matrix(
((1, 1, 1, 1, 1),
 (1, 1, 1, 1, 1),
 (1, 1, 1, 1, 1),
 (1, 1, 1, 1, 1),
 (1, 1, 1, 1, 1)) )

print ("L = ")
print (L)
print ("tau = ")
print (tau)

eta = np.matrix(L)

for i in range(5):
    for j in range(5):
        eta[i].transpose()[j] = np.matrix(1/eta[i].transpose()[j])

P = np.matrix(L)
Beispiel #5
0
import np

def f(x):
    return -1 if x <= 0 else 1

x = [];
x.append( 0 )
x.append ( np.matrix((1, -1, 1, -1)) )
x.append ( np.matrix((-1, 1, -1, 1)) )
x.append ( np.matrix((1, 1, 1, -1)) )
x.append ( np.matrix((-1, -1, 1, -1)) )


l = []
print("Print 4 numbers: it'll be the vector:")
for i in range(4):
    a = int( input() )
    l.append(a)

x_star = np.matrix(l)

y = []
y.append( 0 )
y.append ( np.matrix((-1, -1, 1)) )
y.append ( np.matrix((-1, 1, -1)) )
y.append ( np.matrix((-1, 1, 1)) )
y.append ( np.matrix((1, -1, -1)) )

W = y[1].transpose()*x[1]
for i in range(2, 5):
    w = y[i].transpose()*x[i]
Beispiel #6
0
#!/usr/bin/python3
import numpy
import np
import random
import math

random.seed()

SIZE=1500
a=[]
for i in range(SIZE):
    b=[]
    for j in range(SIZE):
        b.append((random.randint(-100, 100))/(i+j+1))
    a.append(b)

y = np.matrix (a);
print(SIZE)
for i in range(SIZE):
    for j in range(SIZE):
        print(y[i].transpose()[j].item(), end=" ")
    print()

print(numpy.linalg.det(y))