-3
\$\begingroup\$

I need to convert data from float to integer in the following code and in the "num"

command

import numpy as np
import scipy.integrate as it
 from scipy import linalg
from numpy.linalg import matrix_power
        
    ##############################

# Constants
tmax = 10
t = np.arange(0.0, tmax, 0.1)
m=len(t)
print(m)
e=np.matrix([[0,1,2 ,3,4,5,6,7,8,9],
             [0,1,1, 1,1,1, 1,1,1, 1]])
e1=e[0]
e2=e[1]
a=np.power(e1,2)
b=np.power(e2,2)
nrm2e=(a+b)

tnow=t
num=10*tnow
print(num)

I have tried these methods such as floor() and int() but I did not get a matrix with integer members.

here is the float matrix

[ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 14. 15. 16. 17.
 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35.
 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53.
 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71.
 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89.
 90. 91. 92. 93. 94. 95. 96. 97. 98. 99.]
New contributor
SaraMCollins is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
6
  • 1
    \$\begingroup\$ Specify dtype=int in your matrix constructor. But this is off topic for Code Review. \$\endgroup\$ – Reinderien yesterday
  • \$\begingroup\$ Thank you so much for your reply matrix constructor is num? num=np.array(num,dtype=int)? \$\endgroup\$ – SaraMCollins yesterday
  • \$\begingroup\$ Uh what? The matrix constructor is e=np.matrix \$\endgroup\$ – Reinderien yesterday
  • 1
    \$\begingroup\$ I really appreciate your help. \$\endgroup\$ – SaraMCollins yesterday
  • 1
    \$\begingroup\$ Thanks. Again, since this code is not working it's not on topic for this site. Once you do get it working you can post here to ask how it can be made better. \$\endgroup\$ – Reinderien yesterday

Browse other questions tagged or ask your own question.