mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 14:29:11 +00:00
Initial commit
This commit is contained in:
26
example/example7.py
Executable file
26
example/example7.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
from example import Matrix
|
||||
import numpy as np
|
||||
|
||||
m = Matrix(5, 5)
|
||||
|
||||
print(m[2, 3])
|
||||
m[2, 3] = 4
|
||||
print(m[2, 3])
|
||||
|
||||
m2 = np.array(m, copy=False)
|
||||
print(m2)
|
||||
print(m2[2, 3])
|
||||
m2[2, 3] = 5
|
||||
print(m[2, 3])
|
||||
|
||||
m3 = np.array([[1,2,3],[4,5,6]]).astype(np.float32)
|
||||
print(m3)
|
||||
m4 = Matrix(m3)
|
||||
for i in range(m4.rows()):
|
||||
for j in range(m4.cols()):
|
||||
print(m4[i, j], end = ' ')
|
||||
print()
|
||||
Reference in New Issue
Block a user