Dot and Cross

Sort by

recency

|

338 Discussions

|

  • + 0 comments
    import numpy as np 
    N = int(input())
    input_list_A = np.array([list(map(int, input().split())) for i in range(N)])
    input_list_B = np.array([list(map(int, input().split())) for i in range(N)])
    print(np.dot(input_list_A,input_list_B))
    
  • + 0 comments
    import numpy as np
    
    N = int(input())
    
    A = np.array([list(map(int, input().split()))for _ in range(N)])
    B = np.array([list(map(int, input().split()))for _ in range(N)])
    
    result = np.dot(A,B)
    
    print(result)
    
  • + 0 comments

    import numpy n=int(input()) arr_a=[] for _ in range(n): arr_a.append(list(map(int,input().split()))) arr_b=[] for _ in range(n): arr_b.append(list(map(int,input().split())))

    print(numpy.dot(arr_a,arr_b))

  • [deleted]Challenge Author
    + 0 comments

    For Python3

    Use Dot Product to do matrix multiplication for multiple dimensions

    import numpy
    
    n = int(input())
    A = numpy.array([input().split() for _ in range(n)], dtype=int)
    B = numpy.array([input().split() for _ in range(n)], dtype=int)
    
    print(numpy.dot(A, B))
    
  • + 0 comments

    Just use this easy code

    import numpy

    n=int(input()) A=[] B=[] for _ in range(n): A.append(list(map(int,input().split()))) for _ in range(n): B.append(list(map(int,input().split())))

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

    C=numpy.dot(A,B)

    print(C)