Python | sympy.ones() method
With the help of sympy.ones() method, we can create a matrix having dimension nxm and filled with ones by using sympy.ones() method.
Syntax :
sympy.ones()
Return : Return a ones matrix.
Example #1 :
In this example, we can see that by using sympy.ones() method, we are able to create the ones matrix having dimension nxn all filled with ones, where nxm will be pass as a parameter.
# import sympy from sympy import * # Use sympy.ones() method mat = ones(3, 4) print(mat) |
Output :
Matrix([
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]])
Example #2 :
# import sympy from sympy import * # Use sympy.ones() method mat = ones(3, 2) print(mat) |
Output :
Matrix([
[1, 1],
[1, 1],
[1, 1]])
Recommended Posts:
- class method vs static method in Python
- Python | set() method
- Python | os.dup() method
- Python | next() method
- Python | Tensorflow sin() method
- Python | os.fsync() method
- Python | os.symlink() method
- Python | os.lchflags() method
- Python | os.mknod() method
- Python | os.sched_get_priority_min() method
- Python | os.sched_setaffinity() method
- Python | os.sched_getaffinity() method
- Python | sympy.det() method
- Python | sympy.div() method
- Python | os.sched_get_priority_max() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

