Пример #1
0
'''from matmul import readm,matmul

A = readm('A.csv')
b = readm('b.csv')
c = matmul(A,b)
print(c)'''

from matmul import readm, matmul
AA = 'A.csv'
BB = 'b.csv'
print(matmul(readm(AA), readm(BB)))
Пример #2
0
import matmul

A = matmul.readm('A.csv')
b = matmul.readm('b.csv')

C = matmul.matmul(A, b)

for row in C:
    print(row)
# 1. read mt A from 'A.csv'
#import pandas as pd
#import csv
from matmul import readm, matmul
#1.read matrix A from
A = 'A.csv'

#2.read matrix b from 'b.csv'
b = 'b.csv'

print(matmul(readm(A),readm(b)))
from matmul import readm, matmul
#1. readm matrix A from 'A.scv'
A = readm('A.csv')
#2. read matrix b from 'b.csv'
b = readm('b.csv')
#3.find the result of C = A x b
#4.printC
C = matmul(A,b)
print('....')
for row in C:
    print(row)
print('....')
#import numpy as np
#D = np.dot(np.array(A), np.array(b))
#print(D)
Пример #5
0
import numpy as np
import matmul

A = matmul.readm('A.txt')
b = matmul.readn('b.txt')

def guass(A,b):
    a = np.array(A)
    n = len(a)
    b = np.array(b)
    
    for k in range(0, n-1):
      for i in range(k+1, n):
        if a[i,k] != 0.0:
            lam = a[i,k]/a[k,k]
            a[i,k+1:n] = a[i, k+1:n] - lam*a[k,k+1:n]
            b[i] = b[i] - lam*b[k]
    x=[0]*n
    for k in range(n-1, -1, -1):
      x[k] = (b[k] - np.dot(a[k,k+1:n], x[k+1:n]))/a[k,k]
    return x

for i in guass(A,b):
    print(i)
from matmul import readm, matmul

afile = 'A.csv'
bfiel = 'b.csv'
print(matmul(readm(afile), readm(bfiel)))
import matmul

A = matmul.readm('A.csv')
b = matmul.readn('b.csv')


for i in matmul.matmul(A,b):
    print(i)
from matmul import readm, matmul

#1. read matrix A from 'A.csv'
A = readm('A.csv')

#2. read matrix A from 'A.csv
A = readm('b.csv')


#3. find the result of C = A x b
def matmul(A, b):
    m, n = len(A), len(b[0])
    J = len(A[0])  # A-mxJ #b -Jxn
    if len(A[0]) == len(b):
        #C = [ [0]*n for i in range(n) ]
        C = [[0] * n] * m
        # A[0][0]*b[0][0] + A[0][1]*b[1][0] + A[0][2]*b[2][0]
        for r in range(m):
            for c in range(n):
                C[r][c] = sum(
                    [float(A[c][j]) * float(b[j][c]) for j in range(J)])
        return C
    return []  #  ไม่สามารถดูได้


#4. print C
print(matmul(A, b))
C = matmul(A, b)
for row in C:
    print(row)
print(".....")