Dot and Cross

Sort by

recency

|

333 Discussions

|

  • + 0 comments

    import numpy N = int(input()) array_A = numpy.array([input().strip().split()[:N] for _ in range(N)], dtype=numpy.int_) array_B = numpy.array([input().strip().split()[:N] for _ in range(N)], dtype=numpy.int_) print(numpy.dot(array_A,array_B))

  • + 0 comments

    import numpy as np

    n = int(input()) a,b= [],[] for i in range(n): a.append(list(map(int, input().split()))) for j in range(n): b.append(list(map(int, input().split()))) print(np.dot(a,b))

  • + 0 comments

    import numpy as np

    n = int(input())

    a = np.array([list(map(int,(input().strip().split()))) for _ in range(n)]) b = np.array([list(map(int,(input().strip().split()))) for _ in range(n)])

    print(a @ b)

  • + 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("]")