w3resource logo
Python Exercises

Python NumPy: Multiply a matrix by another matrix of complex numbers and create a new matrix of complex numbers

Python NumPy Math, Statistics, Trigonometry and Linear algebra: Exercise-12 with Solution

Write a Python program to multiply a matrix by another matrix of complex numbers and create a new matrix of complex numbers.

Sample Solution:-

Python Code:

import numpy as np
x = np.array([1+2j,3+4j])
print("First array:")
print(x)
y = np.array([5+6j,7+8j])
print("Second array:")
print(y)
z = np.vdot(x, y)
print("Product of above two arrays:")
print(z)

Sample Output:

First array:                                                           
[ 1.+2.j  3.+4.j]                                                      
Second array:                                                          
[ 5.+6.j  7.+8.j]                                                      
Product of above two arrays:                                           
(70-8j)

Python Code Editor:

import numpy as np
x = np.array([1+2j,3+4j])
print("First array:")
print(x)
y = np.array([5+6j,7+8j])
print("Second array:")
print(y)
z = np.vdot(x, y)
print("Product of above two arrays:")
print(z)

Improve this sample solution and post your code through Disqus