Cải thiện bài viết
Lưu bài viết
Cải thiện bài viết
Lưu bài viết
ĐọcThis mathematical function helps user to calculate square value of each element in the array.
Bàn luận
arr : [array_like] Input array or object whose elements, we need to square.
numpy.square [mảng, out = none, ufunc ‘vuông]: Hàm toán học này giúp người dùng tính toán giá trị vuông của mỗi phần tử trong mảng.
An array with square value of each array.
Thông số :
Code #1 : Working
Trở về :
& nbsp; mã số 1: làm việc
import
numpy as np
arr1
=
An array with square value of each array.0
An array with square value of each array.1
An array with square value of each array.2
An array with square value of each array.3
An array with square value of each array.4
An array with square value of each array.2
An array with square value of each array.6
An array with square value of each array.2
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]3
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]4
Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
5=
An array with square value of each array.
0Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
8 Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
9An array with square value of each array.
3Square[4 + 3j] : [7+24j]
Square value[16 + 13j] : [87+416j]
1Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
0
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
Square[4 + 3j] : [7+24j] Square value[16 + 13j] : [87+416j]5
Square[4 + 3j] : [7+24j] Square value[16 + 13j] : [87+416j]6
Code #2 : Working with complex numbers
Trở về :
& nbsp; mã số 1: làm việc
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
Graphical Representation : [ 25. 9. 1. 1. 9. 25.]6
Graphical Representation : [ 25. 9. 1. 1. 9. 25.]7
import
numpy as np
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
>>> np.square[[-1j, 1]] array[[-1.-0.j, 1.+0.j]]5
>>> np.square[[-1j, 1]] array[[-1.-0.j, 1.+0.j]]6
Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
5=
An array with square value of each array.
0Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
8 Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
9An array with square value of each array.
3Square[4 + 3j] : [7+24j]
Square value[16 + 13j] : [87+416j]
1Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
0
Square[4 + 3j] : [7+24j] Square value[16 + 13j] : [87+416j]
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
Square[4 + 3j] : [7+24j] Square value[16 + 13j] : [87+416j]5
Square[4 + 3j] : [7+24j] Square value[16 + 13j] : [87+416j]6
Code #3 : Graphical Representation of numpy.square[]
Trở về :
& nbsp; mã số 1: làm việc
import
numpy as np
arr1
=
An array with square value of each array.0
An array with square value of each array.1
An array with square value of each array.2
An array with square value of each array.3
An array with square value of each array.4
An array with square value of each array.2
An array with square value of each array.6
An array with square value of each array.2
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
arr1
1Graphical Representation : [ 25. 9. 1. 1. 9. 25.]7
arr1
3arr1
4numpy as np
8
arr1
6
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]3
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]4
=
1
Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
5=
An array with square value of each array.
0Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
8 Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
9An array with square value of each array.
3Square[4 + 3j] : [7+24j]
Square value[16 + 13j] : [87+416j]
1Square Value of arr1 :
[ 1 9 225 217156]
Square Value of arr2 : [ 529 3136]
0
Graphical Representation : [ 25. 9. 1. 1. 9. 25.]
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]1
Square Value of arr1 : [ 1 9 225 217156] Square Value of arr2 : [ 529 3136]2
Square[4 + 3j] : [7+24j] Square value[16 + 13j] : [87+416j]5
Square[4 + 3j] : [7+24j] Square value[16 + 13j] : [87+416j]6
//docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.absolute.html
.
Trả về bình phương phần tử khôn ngoan của đầu vào.
Tham sốxarray_likexarray_likeDữ liệu đầu vào.
outndarray, không có, hoặc tuple của ndarray và không có, tùy chọnndarray, None, or tuple of ndarray and None, optionalMột vị trí mà kết quả được lưu trữ. Nếu được cung cấp, nó phải có một hình dạng mà các đầu vào phát sóng. Nếu không được cung cấp hoặc không có, một mảng mới được phân bổ được trả lại. Một tuple [chỉ có thể là đối số từ khóa] phải có độ dài bằng số lượng đầu ra.
wherearray_like, tùy chọnarray_like, optionalĐiều kiện này được phát trên đầu vào. Tại các vị trí mà điều kiện là đúng, mảng ra sẽ được đặt thành kết quả UFUNC. Ở những nơi khác, mảng ra sẽ giữ lại giá trị ban đầu của nó. Lưu ý rằng nếu một mảng ra không được tạo ra được tạo thông qua =
2 mặc định, các vị trí trong đó điều kiện là sai sẽ vẫn không được cung cấp.
Đối với các đối số chỉ từ khóa khác, hãy xem các tài liệu UFUNC.ufunc docs.
ReturnSoutNDarray hoặc vô hướngoutndarray or scalarPhần tử khôn ngoan x*x, có cùng hình dạng và dtype như x. Đây là vô hướng nếu X là vô hướng.
Ví dụ
>>> np.square[[-1j, 1]] array[[-1.-0.j, 1.+0.j]]