Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
numpy
python
communitycreator

What is the numpy.conjugate() function in NumPy?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The conjugate() function in NumPy is used to return, element-wise, the complex conjugate of an input array that is passed to it. This is done by simply changing the sign of the imaginary part of the input value.

Syntax

numpy.conjugate(x1, /, out=None, *, where=True)
Syntax for the "conjugate()" function in NumPy

Parameter values

The conj() function takes the following parameter values:

  • x: This represents the input array of complex values. This is a required parameter value.
  • out: This represents the location where the result is stored. This is an optional parameter value. 
  • where: This is the condition over which the input is broadcast. At a given location where this condition is True, the resulting array is set to the ufunc result. Otherwise, the resulting array retains its original value. This is an optional parameter value. 
  • kwargs: This represents the other keyword arguments. This is an optional parameter value. 

Return value

The conjugate() function returns a complex conjugate of the input value that has the same data type as the input value.

Example

import numpy as np
# creating an input array of complex values
x = np.array([1+2j, 2-3j, 1+5j])
# implementing the conjugate() function
myarray = np.conjugate(x)
print(x)
print(myarray)
Implementing the conjugate() function

Explanation

  • Line 1: We import the numpy module.
  • Line 4: We create an array x with complex values, using the array() function.
  • Line 7: We implement the conjugate() function on the input array. We assign the result to a variable called myarray.
  • Line 9: We print the variable x.
  • Line 10: We print the variable myarray.

RELATED TAGS

function
numpy
python
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring