To generate a Vandermonde matrix of given degree and sample points (x, y, z)., use the polynomial.polyvander3d() in Python Numpy. The method returns the pseudo-Vandermonde matrix of degrees deg and sample points (x, y, z). The parameter, x, y, z are the arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. The parameter, deg is the list of maximum degrees of the form [x_deg, y_deg, z_deg].
Steps
At first, import the required libraries −
import numpy as np from numpy.polynomial.polynomial import polyvander3d
Create arrays of point coordinates, all of the same shape using the numpy.array() method −
x = np.array([-2.+2.j, -1.+2.j]) y = np.array([0.+2.j, 1.+2.j]) z = np.array([2.+2.j, 3. + 3.j])
Display the arrays −
print("Array1...\n",x) print("\nArray2...\n",y) print("\nArray3...\n",z)
Display the datatype −
print("\nArray1 datatype...\n",x.dtype) print("\nArray2 datatype...\n",y.dtype) print("\nArray3 datatype...\n",z.dtype)
Check the Dimensions −
print("\nDimensions of Array1...\n",x.ndim) print("\nDimensions of Array2...\n",y.ndim) print("\nDimensions of Array3...\n",z.ndim)
Check the Shape −
print("\nShape of Array1...\n",x.shape) print("\nShape of Array2...\n",y.shape) print("\nShape of Array3...\n",z.shape)
To generate a Vandermonde matrix of given degree and sample points (x, y, z)., use the polynomial.polyvander3d() in Python Numpy −
x_deg, y_deg, z_deg = 2, 3, 4 print("\nResult...\n",polyvander3d(x,y, z, [x_deg, y_deg, z_deg]))
Example
import numpy as np from numpy.polynomial.polynomial import polyvander3d # Create arrays of point coordinates, all of the same shape using the numpy.array() method x = np.array([-2.+2.j, -1.+2.j]) y = np.array([0.+2.j, 1.+2.j]) z = np.array([2.+2.j, 3. + 3.j]) # Display the arrays print("Array1...\n",x) print("\nArray2...\n",y) print("\nArray3...\n",z) # Display the datatype print("\nArray1 datatype...\n",x.dtype) print("\nArray2 datatype...\n",y.dtype) print("\nArray3 datatype...\n",z.dtype) # Check the Dimensions print("\nDimensions of Array1...\n",x.ndim) print("\nDimensions of Array2...\n",y.ndim) print("\nDimensions of Array3...\n",z.ndim) # Check the Shape print("\nShape of Array1...\n",x.shape) print("\nShape of Array2...\n",y.shape) print("\nShape of Array3...\n",z.shape) # To generate a Vandermonde matrix of given degree and sample points (x, y, z)., use the polynomial.polyvander3d() in Python Numpy x_deg, y_deg, z_deg = 2, 3, 4 print("\nResult...\n",polyvander3d(x,y, z, [x_deg, y_deg, z_deg]))
Output
Array1... [-2.+2.j -1.+2.j] Array2... [0.+2.j 1.+2.j] Array3... [2.+2.j 3.+3.j] Array1 datatype... complex128 Array2 datatype... complex128 Array3 datatype... complex128 Dimensions of Array1... 1 Dimensions of Array2... 1 Dimensions of Array3... 1 Shape of Array1... (2,) Shape of Array2... (2,) Shape of Array3... (2,) Result... [[ 1.000e+00+0.000e+00j 2.000e+00+2.000e+00j 0.000e+00+8.000e+00j -1.600e+01+1.600e+01j -6.400e+01+0.000e+00j 0.000e+00+2.000e+00j -4.000e+00+4.000e+00j -1.600e+01+0.000e+00j -3.200e+01-3.200e+01j -0.000e+00-1.280e+02j -4.000e+00+0.000e+00j -8.000e+00-8.000e+00j -0.000e+00-3.200e+01j 6.400e+01-6.400e+01j 2.560e+02-0.000e+00j 0.000e+00-8.000e+00j 1.600e+01-1.600e+01j 6.400e+01+0.000e+00j 1.280e+02+1.280e+02j 0.000e+00+5.120e+02j -2.000e+00+2.000e+00j -8.000e+00+0.000e+00j -1.600e+01-1.600e+01j 0.000e+00-6.400e+01j 1.280e+02-1.280e+02j -4.000e+00-4.000e+00j 0.000e+00-1.600e+01j 3.200e+01-3.200e+01j 1.280e+02+0.000e+00j 2.560e+02+2.560e+02j 8.000e+00-8.000e+00j 3.200e+01+0.000e+00j 6.400e+01+6.400e+01j 0.000e+00+2.560e+02j -5.120e+02+5.120e+02j 1.600e+01+1.600e+01j 0.000e+00+6.400e+01j -1.280e+02+1.280e+02j -5.120e+02+0.000e+00j -1.024e+03-1.024e+03j 0.000e+00-8.000e+00j 1.600e+01-1.600e+01j 6.400e+01+0.000e+00j 1.280e+02+1.280e+02j 0.000e+00+5.120e+02j 1.600e+01+0.000e+00j 3.200e+01+3.200e+01j 0.000e+00+1.280e+02j -2.560e+02+2.560e+02j -1.024e+03+0.000e+00j 0.000e+00+3.200e+01j -6.400e+01+6.400e+01j -2.560e+02+0.000e+00j -5.120e+02-5.120e+02j -0.000e+00-2.048e+03j -6.400e+01+0.000e+00j -1.280e+02-1.280e+02j -0.000e+00-5.120e+02j 1.024e+03-1.024e+03j 4.096e+03-0.000e+00j] [ 1.000e+00+0.000e+00j 3.000e+00+3.000e+00j 0.000e+00+1.800e+01j -5.400e+01+5.400e+01j -3.240e+02+0.000e+00j 1.000e+00+2.000e+00j -3.000e+00+9.000e+00j -3.600e+01+1.800e+01j -1.620e+02-5.400e+01j -3.240e+02-6.480e+02j -3.000e+00+4.000e+00j -2.100e+01+3.000e+00j -7.200e+01-5.400e+01j -5.400e+01-3.780e+02j 9.720e+02-1.296e+03j -1.100e+01-2.000e+00j -2.700e+01-3.900e+01j 3.600e+01-1.980e+02j 7.020e+02-4.860e+02j 3.564e+03+6.480e+02j -1.000e+00+2.000e+00j -9.000e+00+3.000e+00j -3.600e+01-1.800e+01j -5.400e+01-1.620e+02j 3.240e+02-6.480e+02j -5.000e+00+0.000e+00j -1.500e+01-1.500e+01j -0.000e+00-9.000e+01j 2.700e+02-2.700e+02j 1.620e+03-0.000e+00j -5.000e+00-1.000e+01j 1.500e+01-4.500e+01j 1.800e+02-9.000e+01j 8.100e+02+2.700e+02j 1.620e+03+3.240e+03j 1.500e+01-2.000e+01j 1.050e+02-1.500e+01j 3.600e+02+2.700e+02j 2.700e+02+1.890e+03j -4.860e+03+6.480e+03j -3.000e+00-4.000e+00j 3.000e+00-2.100e+01j 7.200e+01-5.400e+01j 3.780e+02+5.400e+01j 9.720e+02+1.296e+03j 5.000e+00-1.000e+01j 4.500e+01-1.500e+01j 1.800e+02+9.000e+01j 2.700e+02+8.100e+02j -1.620e+03+3.240e+03j 2.500e+01+0.000e+00j 7.500e+01+7.500e+01j 0.000e+00+4.500e+02j -1.350e+03+1.350e+03j -8.100e+03+0.000e+00j 2.500e+01+5.000e+01j -7.500e+01+2.250e+02j -9.000e+02+4.500e+02j -4.050e+03-1.350e+03j -8.100e+03-1.620e+04j]]