Dot and Cross

Sort by

recency

|

330 Discussions

|

  • + 0 comments
    import numpy as np
    
    n = int(input())
    
    matrix_a = []
    
    matrix_b = []
    
    for i in range(n):
        matrix_a.append(list(map(int, input().split())))
        
    
    for i in range(n):
        matrix_b.append(list(map(int, input().split())))
    
    print(np.matmul(matrix_a,matrix_b))``
    
  • + 0 comments

    # def matrixmultiplicaton(A, B, N):

    result= [[0]*N for num in range(N)]

    for i in range(N):

    for j in range(N):

    for k in range(N):

    result[i][j] += A[i][k]*B[k][j]

    return result

    if name == 'main':

    N=int(input())

    A=[]

    for num in range(N):

    row=list(map(int, input(). strip(). split()))

    A.append(row)

    B=[]

    for num in range(N):

    row=list(map(int, input(). strip(). split()))

    B.append(row)

    result=matrixmultiplicaton(A, B, N)

    print("[", end="")

    for i, row in enumerate(result):

    print("[" + " ".join(map(str, row)) + "]", end="")

    if i==0:

    print()

    if i < len(result) - 1:

    print("", end="")

    print("]")

  • + 0 comments

    import numpy

    N = int(input())

    ListA = list() ListB = list()

    for i in range(N): ListA.append(list(map(int , input().split())))

    for j in range(N): ListB.append(list(map(int , input().split())))

    A = numpy.array(ListA) B = numpy.array(ListB)

    result = numpy.dot(A , B)

    print(result)

  • + 0 comments

    import numpy as np a = int(input()) element = [] element1= [] for z in range(a): b= input() c= b.split() element.append(c)

    for j in range(a): b= input() c= b.split() element1.append(c) element = np.array(element, dtype=int) element1 = np.array(element1, dtype=int) print(np.dot(element,element1))

  • + 0 comments

    This is understandable solution from my side

    import numpy
    matrices = []
    n = int(input())
    for i in range(2):
        matrix = []
        for i in range(n):
            matrix.append(list(map(int,input().split())))
        matrices.append(matrix)
    print(numpy.dot(matrices[0],matrices[1]))