numpy.ldexp() in Python Last Updated : 22 Jul, 2021 Comments Improve Suggest changes 1 Likes Like Report In Python, numpy.ldexp(arr1, arr2[, out]) function returns arr1 * (2**arr2), element-wise. This is also called as inverse of numpy.frexp() function. Syntax: numpy.ldexp()Parameters: arr1: [array_like] Array of multipliers. arr2: [array_like, int] Array of twos exponents. out: [ndarray, optional] Output array for the result.Returns: [ndarray, scalar] Return the result of arr1 * (2**arr2). This is a scalar if both arr1 and arr2 are scalars. Code #1: Python3 # Python program explaining # numpy.ldexp() method # importing numpy import numpy as geek # ldexp() Function on + ve nd -ve Numbers print(geek.ldexp(6, geek.arange(4))) print(geek.ldexp(-8, geek.arange(4))) # ldexp() Function on fractional Number print(geek.ldexp(5.2, geek.arange(3))) print(geek.ldexp(-3.2, geek.arange(3))) Output: [ 6. 12. 24. 48.] [ -8. -16. -32. -64.] [ 5.2 10.4 20.8] [ -3.2 -6.4 -12.8] Code #2: Complex data-types are not supported, they will raise a TypeError. Python3 # Python program explaining # numpy.ldexp() method # importing numpy import numpy as geek # ldexp() Function on complex dtypes print(geek.ldexp(-5 + 9J, geek.arange(4))) Output: TypeError: ufunc 'ldexp' not supported for the input types Create Quiz Comment S sanjoy_62 Follow 1 Improve S sanjoy_62 Follow 1 Improve Article Tags : Machine Learning Python-numpy python Explore Machine Learning BasicsIntroduction to Machine Learning8 min readTypes of Machine Learning7 min readWhat is Machine Learning Pipeline?6 min readApplications of Machine Learning3 min readPython for Machine LearningMachine Learning with Python Tutorial5 min readNumPy Tutorial - Python Library3 min readPandas Tutorial4 min readData Preprocessing in Python4 min readEDA - Exploratory Data Analysis in Python6 min readFeature EngineeringWhat is Feature Engineering?5 min readIntroduction to Dimensionality Reduction4 min readFeature Selection Techniques in Machine Learning4 min readSupervised LearningSupervised Machine Learning7 min readLinear Regression in Machine learning14 min readLogistic Regression in Machine Learning10 min readDecision Tree in Machine Learning8 min readRandom Forest Algorithm in Machine Learning5 min readK-Nearest Neighbor(KNN) Algorithm8 min readSupport Vector Machine (SVM) Algorithm9 min readNaive Bayes Classifiers6 min readUnsupervised LearningWhat is Unsupervised Learning5 min readK means Clustering â Introduction6 min readHierarchical Clustering in Machine Learning6 min readDBSCAN Clustering in ML - Density based clustering6 min readApriori Algorithm6 min readFrequent Pattern Growth Algorithm5 min readECLAT Algorithm - ML5 min readPrincipal Component Analysis (PCA)7 min readModel Evaluation and TuningEvaluation Metrics in Machine Learning9 min readRegularization in Machine Learning5 min readCross Validation in Machine Learning5 min readHyperparameter Tuning5 min readUnderfitting and Overfitting in ML3 min readBias and Variance in Machine Learning6 min readAdvanced TechniquesReinforcement Learning9 min readSemi-Supervised Learning in ML5 min readSelf-Supervised Learning (SSL)6 min readEnsemble Learning8 min readMachine Learning PracticeMachine Learning Interview Questions and Answers15+ min read100+ Machine Learning Projects with Source Code5 min read Like