Found 33676 Articles for Programming

Return the outer product of two masked Three-Dimensional Numpy arrays

AmitDiwan
Updated on 22-Feb-2022 08:03:28

278 Views

To return the outer product of two 3D masked arrays, use the ma.outer() method in Python Numpy. The first parameter is the input vector. Input is flattened if not already 1-dimensional. The second parameter is the second input vector. Input is flattened if not already 1-dimensional.A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.StepsAt first, import the required library −import ... Read More

Compare and return True if an array is greater than another array in Numpy

AmitDiwan
Updated on 21-Feb-2022 10:18:47

596 Views

To compare and return True if an array is greater than another array, use the numpy.char.greater() method in Python Numpy.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.StepsAt first, import the required library −import numpy as npCreate two One-Dimensional arrays of string −arr1 = np.array(['Bella', 'Tom', 'John', 'Kate', 'Amy', 'Brad', 'aaa']) arr2 = np.array(['Cio', 'Tom', 'Cena', 'Kate', 'Adams', 'brad', 'aa'])Display the arrays −print("Array 1...", arr1) print("Array 2...", arr2)Get the type of the arrays −print("Our ... Read More

Java Program to Calculate Simple Interest

Manisha Chand
Updated on 05-Jun-2025 11:05:06

3K+ Views

In this article, we will understand how to write a Java program to calculate simple interest. But, before doing it, let's understand how we calculate simple interest mathematically. The simple interest is a way to determine the amount of interest gained on a principal amount at the specified interest rate for a given time. Unlike compound interest, its principal amount does not change over time. To calculate Simple Interest, we use the following formula− Simple Interest (S.I) = Principal * Time * Rate / 100 where, P is the principal amount T is the time R is the rate ... Read More

Compute the bit-wise OR of two One-Dimensional Numpy arrays element-wise

AmitDiwan
Updated on 21-Feb-2022 10:15:01

132 Views

To compute the bit-wise OR of two 1D arrays element-wise, use the numpy.bitwise_or() method in Python Numpy. Computes the bit-wise OR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator |.The 1st and 2nd parameter are the arrays, only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape.The where parameter is the condition broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original ... Read More

Java Program to Find Even Sum of Fibonacci Series till number N

Manisha Chand
Updated on 05-Jun-2025 10:22:18

3K+ Views

In this article, we will learn how to find the even sum of the Fibonacci series up to a given number N. A Fibonacci series is a series where the next term is the sum of the previous two terms. An even Fibonacci series is a group of all the even numbers in the Fibonacci series. The first two terms of the Fibonacci sequence are 0 and 1. Fn = Fn-1 + Fn-2 Hence, a Fibonacci series can look like this - F8 = 0 1 1 2 3 5 8 13 or, this F8 = 1 1 2 3 5 ... Read More

Return the underlying data as a view of the masked array in Numpy

AmitDiwan
Updated on 21-Feb-2022 10:11:18

229 Views

To return the underlying data, as a view of the masked array, use the ma.MaskedArray.data in Python Numpy.A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreating a 4x4 array with int elements using the numpy.arange() method −arr = np.arange(16).reshape((4, 4)) print("Array...", arr) print("Array type...", arr.dtype)Get the dimensions ... Read More

Return the mask of a masked array in Numpy

AmitDiwan
Updated on 21-Feb-2022 10:08:02

1K+ Views

To return the mask of a masked array, use the ma.getmask() method in Python Numpy. Returns the mask of a as an ndarray if a is a MaskedArray and the mask is not nomask, else return nomask. To guarantee a full array of booleans of the same shape as a, use getmaskarray.A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.StepsAt ... Read More

Java Program to Check whether the input number is a Neon Number

Shriansh Kumar
Updated on 01-Aug-2024 11:54:45

1K+ Views

In this article, we will understand how to check whether the given input number is a neon number. A neon number is such a number whose sum of digits of square of the number is equal to the number itself. Example Scenario: Input: num = 9; Output: The given input is a neon number How to Check Neon Number in Java? To check a given input is a neon number in Java, use the below approaches − Using for loop Using while loop Using recursion Using ... Read More

Count the number of masked elements along axis 1 in Numpy

AmitDiwan
Updated on 21-Feb-2022 10:04:47

157 Views

To count the number of masked elements along axis 1, use the ma.MaskedArray.count_masked() method. The axis is set using the "axis" parameter. The method returns the total number of masked elements (axis=None) or the number of masked elements along each slice of the given axis.The axis parameter is the axis along which to count. If None (default), a flattened version of the array is used.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreating a 4x4 array with int elements using the numpy.arange() method −arr = np.arange(16).reshape((4, 4)) print("Array...", arr) print("Array type...", arr.dtype)Get the dimensions of ... Read More

Compute the bit-wise OR of two Numpy arrays element-wise

AmitDiwan
Updated on 21-Feb-2022 10:00:54

176 Views

To compute the bit-wise OR of two arrays element-wise, use the numpy.bitwise_or() method in Python Numpy. Computes the bit-wise OR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator |.The 1st and 2nd parameter are the arrays, only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape.The where parameter is the condition broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. ... Read More

Advertisements