# Tag: 2D

## Allocating and deallocating 2D arrays dynamically in C and C++

In this article we will see how to allocate and deallocateÂ 2D arrays dynamically using new / delete and malloc / free combinations. Suppose we want to create a 2D array using pointers on heap either using new or malloc. It should function like this, Advertisements int row = 2; int col = 3; int ** …

Allocating and deallocating 2D arrays dynamically in C and C++Read More

## Creating a Matrix using 2D vector in C++ â€“ Vector of Vectors

In this article will discuss how to create 2D Matrix using vector of vectors in c++. Requirement Advertisements Represent a 2D Matrix using vector in C++ i.e. 1 , 1 , 1 , 1 1 , 1 , 1 , 1 1 , 1 , 1 , 1 1 , 1 , 1 , 1 …

Creating a Matrix using 2D vector in C++ â€“ Vector of VectorsRead More

## Create a 1D / 2D Numpy Arrays of zeros or ones

In this article we will discuss how to create a Numpy array of different shapes and initialized with 0 & 1. numpy.zeros() Pythonâ€™s Numpy module provides a function to create a numpy array of given shape & type and all values in it initialized with 0â€™s i.e. numpy.zeros(shape, dtype=float, order=’C’) Arguments: Advertisements shape : Shape …

## Sorting 2D Numpy Array by column or row in Python

In this article we will discuss how to sort a 2D Numpy array by single or multiple rows or columns. Sorting 2D Numpy Array by a column First of all import numpy module i.e. Advertisements import numpy as np Now suppose we have a 2D Numpy array i.e. # Create a 2D Numpy array list …

## How to Reverse a 1D & 2D numpy array using np.flip() and [] operator in Python

In this article we will discuss different ways to reverse the contents of 1D and 2D numpy array ( columns & rows ) using np.flip() and [] operator. Reverse 1D Numpy array using [] operator trick First of all import numpy module i.e. Advertisements import numpy as np Now suppose we have a numpy array …

How to Reverse a 1D & 2D numpy array using np.flip() and [] operator in PythonRead More

## Create an empty 2D Numpy Array / matrix and append rows or columns in python

In this article we will discuss how to create an empty matrix or 2D numpy array first using numpy.empty() and then append individual rows or columns to this matrix using numpy.append(). Before moving forward, letâ€™s have a quick look at the two functions which we are going to use in this article, Advertisements numpy.empty() numpy.empty(shape, …

Create an empty 2D Numpy Array / matrix and append rows or columns in pythonRead More

## 6 Ways to check if all values in Numpy Array are zero (in both 1D & 2D arrays) â€“ Python

In this article we will discuss seven different ways to check if all values in a numpy array are 0. Then we will look how to find rows or columns with only zeros in a 2D array or matrix. Check if all values in a 1D Numpy Array are Zero First of all, we will …

6 Ways to check if all values in Numpy Array are zero (in both 1D & 2D arrays) â€“ PythonRead More

## Python: Check if all values are same in a Numpy Array (both 1D and 2D)

In this article we will discuss different ways to check if all values in a 1D or 2D numpy array are equal. Then we will see how to find rows or columns with the same values in a 2D array or matrix. Check if all elements are equal in a 1D Numpy Array using numpy.all() …

Python: Check if all values are same in a Numpy Array (both 1D and 2D)Read More

## Python: Convert Matrix / 2D Numpy Array to a 1D Numpy Array

In this article we will discuss different ways to convert a 2D numpy array or Matrix to a 1D Numpy Array. First, import the numpy module, Advertisements import numpy as np Convert 2D Numpy array / Matrix to a 1D Numpy array using flatten() Pythonâ€™s Numpy module provides a member function in ndarray to flatten …

Python: Convert Matrix / 2D Numpy Array to a 1D Numpy ArrayRead More

## Python: Convert a 1D array to a 2D Numpy array or Matrix

In this article we will discuss how to convert a 1D Numpy Array to a 2D numpy array or Matrix using reshape() function. We will also discuss how to construct the 2D array row wise and column wise, from a 1D array. Suppose we have a 1D numpy array of size 10, Advertisements # create …

Python: Convert a 1D array to a 2D Numpy array or MatrixRead More