Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.85 KB | None | 0 0
  1. import java.util.*
  2. import kotlin.math.abs
  3. import kotlin.math.max
  4.  
  5. val currentApprox = doubleArrayOf(0.5, 0.5, 1.5, -1.0, -0.5, 1.5, 0.5, -0.5, 1.5, -1.5)
  6. fun main(args:Array<String>){
  7. var startTime:Long
  8. var timeSpent:Long
  9. //testSimpleNewtonMethod()
  10. //val numbers=findBestModHybridNewtonMethod().first
  11. //println(numbers)
  12. testModHybridNewtonMethod(1)
  13. println(NewtonMethod.numberOfCall)
  14. //println(Arrays.toString(modHybridNewtonMethod(currentApprox,2).first))
  15. //println(modHybridNewtonMethod(currentApprox,2).second)
  16. //testModNewtonMethod()
  17. //testModHybridNewtonMethod()
  18. //print("${findBestModHybridNewtonMethod().first} ${findBestModHybridNewtonMethod().second}")
  19. /*
  20. startTime=System.nanoTime()
  21. val ourModApprox=modNewtonMethod(currentApprox)
  22. println(Arrays.toString(ourModApprox))
  23. timeSpent = System.nanoTime()- startTime
  24. println(timeSpent)
  25. */
  26. /*
  27. startTime=System.nanoTime()
  28. val ourModHybridApprox=modHybridNewtonMethod(currentApprox,1)
  29. println(Arrays.toString(ourModHybridApprox))
  30. timeSpent = System.nanoTime() - startTime
  31. println(timeSpent)
  32. */
  33. }
  34.  
  35. fun simpleNewtonMethod(currentApprox: DoubleArray):Pair<DoubleArray,Int>{
  36. var numberOfIteration=0
  37. var nextApprox=currentApprox
  38. var currentApprox=DoubleArray(currentApprox.size,{0.0})
  39. while (getNorm(currentApprox,nextApprox)>1E-15){
  40. numberOfIteration++
  41. currentApprox=nextApprox
  42. nextApprox=simpleNewtonMethodIteration(currentApprox)
  43.  
  44. }
  45. return Pair(nextApprox,numberOfIteration)
  46. }
  47.  
  48. fun modNewtonMethod(currentApprox: DoubleArray):Pair<DoubleArray,Int>{
  49. val jacobiMatrix=NewtonMethod.getJacobiMatrix(currentApprox)
  50. var numberOfIteration=0
  51. var nextApprox=currentApprox
  52. var currentApprox=DoubleArray(currentApprox.size,{0.0})
  53. while (getNorm(currentApprox,nextApprox)>1E-15){
  54. numberOfIteration++
  55. currentApprox=nextApprox
  56. nextApprox=modNewtonMethodIteration(currentApprox,jacobiMatrix)
  57.  
  58.  
  59. }
  60. return Pair(nextApprox,numberOfIteration)
  61. }
  62. fun simpleNewtonMethodIteration(currentApprox:DoubleArray):DoubleArray{
  63. val equationSystem = NewtonMethod.getEquationSystem(currentApprox)
  64. val jacobiMatrix = NewtonMethod.getJacobiMatrix(currentApprox)
  65. val FF=inverseMatrix(jacobiMatrix)*equationSystem
  66. val nextApprox=DoubleArray(currentApprox.size,{0.0})
  67. for (i in 0 until currentApprox.size) {
  68. nextApprox[i] = currentApprox[i] - FF.masive[i][0]
  69. }
  70.  
  71. return nextApprox
  72. }
  73. fun modNewtonMethodIteration(currentApprox:DoubleArray,jacobiMatrix: Matrix):DoubleArray{
  74. var approximation=solutionMatrix(jacobiMatrix,-NewtonMethod.getEquationSystem(currentApprox)).matrixCollumbtoArray()
  75. var nextApprox=DoubleArray(currentApprox.size,{0.0})
  76. for(i in 0 until currentApprox.size)
  77. nextApprox[i]=currentApprox[i]+approximation[i]
  78. return nextApprox
  79. }
  80.  
  81.  
  82. fun modHybridNewtonMethod(currentApprox: DoubleArray,iter:Int):Pair<DoubleArray,Int>{
  83. var nextApprox=currentApprox
  84. var currentApprox=DoubleArray(currentApprox.size,{0.0})
  85. for (i in 0..iter){
  86. currentApprox=nextApprox
  87. nextApprox=simpleNewtonMethodIteration(currentApprox)
  88.  
  89. }
  90. val (nextApprox2,numberOfIteration)=modNewtonMethod(nextApprox)
  91. return Pair(nextApprox2,numberOfIteration)
  92.  
  93. }
  94. fun modHybridNewtonMethod2(currentApprox: DoubleArray,iter:Int):Pair<DoubleArray,Int>{
  95. val jacobiMatrix=NewtonMethod.getJacobiMatrix(currentApprox)
  96. var numberOfIteration=0
  97. var nextApprox=currentApprox
  98. var currentApprox=DoubleArray(currentApprox.size,{0.0})
  99. while (getNorm(currentApprox,nextApprox)>1E-15){
  100. numberOfIteration++
  101. currentApprox=nextApprox
  102. nextApprox=modNewtonMethodIteration(currentApprox,jacobiMatrix)
  103.  
  104.  
  105. }
  106. return Pair(nextApprox,numberOfIteration)
  107.  
  108. }
  109. fun getNorm(currentApprox: DoubleArray,nextApprox:DoubleArray):Double{
  110. var maxelem = 0.0
  111. for(i in 0 until currentApprox.size)
  112. maxelem = max(abs(nextApprox[i]-currentApprox[i]), (maxelem))
  113. return maxelem
  114. }
  115.  
  116.  
  117. fun testSimpleNewtonMethod(){
  118. var ourApprox=simpleNewtonMethod(currentApprox)
  119.  
  120. var startTime = System.nanoTime()
  121. ourApprox=simpleNewtonMethod(currentApprox)
  122. var timeSpent = System.nanoTime() - startTime
  123. println(Arrays.toString(ourApprox.first))
  124. println("число итераций ${ourApprox.second}")
  125.  
  126. println("warn $timeSpent")
  127. }
  128.  
  129. fun testModNewtonMethod(){
  130. var ourModApprox=modNewtonMethod(currentApprox)
  131.  
  132. var startTime = System.nanoTime()
  133. ourModApprox=modNewtonMethod(currentApprox)
  134. var timeSpent = System.nanoTime() - startTime
  135. println(Arrays.toString(ourModApprox.first))
  136. println("число итераций ${ourModApprox.second}")
  137.  
  138. println("warn $timeSpent")
  139. }
  140.  
  141. fun testModHybridNewtonMethod(iter:Int){
  142. var ourModHybridApprox=modHybridNewtonMethod(currentApprox,iter)
  143.  
  144. var startTime = System.nanoTime()
  145. ourModHybridApprox=modHybridNewtonMethod(currentApprox,iter)
  146. var timeSpent = System.nanoTime() - startTime
  147. println(Arrays.toString(ourModHybridApprox.first))
  148. println("число итераций ${ourModHybridApprox.second}")
  149.  
  150. println("warn $timeSpent")
  151. }
  152.  
  153. fun findBestModHybridNewtonMethod():Pair<Int,Long>{
  154. var ourModHybridApprox=modHybridNewtonMethod(currentApprox,1)
  155. var numberOfTheBest=0
  156. var minimum:Long=Long.MAX_VALUE
  157. for(i in 0 until 100) {
  158. ourModHybridApprox = modHybridNewtonMethod(currentApprox, i)
  159. var startTime = System.nanoTime()
  160. ourModHybridApprox = modHybridNewtonMethod(currentApprox, i)
  161. var timeSpent = System.nanoTime() - startTime
  162. if(timeSpent<minimum){
  163. minimum=timeSpent
  164. numberOfTheBest=i
  165. }
  166. }
  167. return Pair(numberOfTheBest,minimum)
  168. }
  169. /*
  170. fun modNewtonMethod2(currentApprox: DoubleArray):Pair<DoubleArray,Int>{
  171. var numberOfIteration=0
  172. var approximation=solutionMatrix(NewtonMethod.getJacobiMatrix(currentApprox),-NewtonMethod.getEquationSystem(currentApprox)).matrixCollumbtoArray()
  173. var nextApprox=currentApprox
  174. var currentApprox=DoubleArray(currentApprox.size,{0.0})
  175. while (getNorm(approximation)>1E-15){
  176. numberOfIteration++
  177. println(numberOfIteration)
  178. currentApprox=nextApprox
  179. for(i in 0 until currentApprox.size)
  180. nextApprox[i]=currentApprox[i]+approximation[i]
  181.  
  182. approximation=solutionMatrix(NewtonMethod.getJacobiMatrix(currentApprox),-NewtonMethod.getEquationSystem(currentApprox)).matrixCollumbtoArray()
  183.  
  184.  
  185. }
  186. return Pair(nextApprox,numberOfIteration)
  187. }
  188. fun getNorm(currentApprox: DoubleArray):Double{
  189. var maxelem = 0.0
  190. for(i in 0 until currentApprox.size)
  191. maxelem = max(abs(currentApprox[i]), (maxelem))
  192. return maxelem
  193. }
  194. */
  195.  
  196.  
  197. class NewtonMethod {
  198. companion object {
  199. var numberOfCall=0
  200. fun getJacobiMatrix(currentApprox: DoubleArray): Matrix {
  201. numberOfCall++
  202. val jacobiMatrix = Matrix(Array(10, { Array(10, { 0.0 }) }))
  203. jacobiMatrix.masive[0][0] = Allfunc.cg00(currentApprox).toDouble()
  204. jacobiMatrix.masive[0][1] = Allfunc.cg01(currentApprox).toDouble()
  205. jacobiMatrix.masive[0][2] = Allfunc.cg02(currentApprox).toDouble()
  206. jacobiMatrix.masive[0][3] = Allfunc.cg03(currentApprox).toDouble()
  207. jacobiMatrix.masive[0][4] = Allfunc.cg04(currentApprox).toDouble()
  208. jacobiMatrix.masive[0][5] = Allfunc.cg05(currentApprox).toDouble()
  209. jacobiMatrix.masive[0][6] = Allfunc.cg06(currentApprox).toDouble()
  210. jacobiMatrix.masive[0][7] = Allfunc.cg07(currentApprox).toDouble()
  211. jacobiMatrix.masive[0][8] = Allfunc.cg08(currentApprox).toDouble()
  212. jacobiMatrix.masive[0][9] = Allfunc.cg09(currentApprox).toDouble()
  213. jacobiMatrix.masive[1][0] = Allfunc.cg10(currentApprox).toDouble()
  214. jacobiMatrix.masive[1][1] = Allfunc.cg11(currentApprox).toDouble()
  215. jacobiMatrix.masive[1][2] = Allfunc.cg12(currentApprox).toDouble()
  216. jacobiMatrix.masive[1][3] = Allfunc.cg13(currentApprox).toDouble()
  217. jacobiMatrix.masive[1][4] = Allfunc.cg14(currentApprox).toDouble()
  218. jacobiMatrix.masive[1][5] = Allfunc.cg15(currentApprox).toDouble()
  219. jacobiMatrix.masive[1][6] = Allfunc.cg16(currentApprox).toDouble()
  220. jacobiMatrix.masive[1][7] = Allfunc.cg17(currentApprox).toDouble()
  221. jacobiMatrix.masive[1][8] = Allfunc.cg18(currentApprox).toDouble()
  222. jacobiMatrix.masive[1][9] = Allfunc.cg19(currentApprox).toDouble()
  223. jacobiMatrix.masive[2][0] = Allfunc.cg20(currentApprox).toDouble()
  224. jacobiMatrix.masive[2][1] = Allfunc.cg21(currentApprox).toDouble()
  225. jacobiMatrix.masive[2][2] = Allfunc.cg22(currentApprox).toDouble()
  226. jacobiMatrix.masive[2][3] = Allfunc.cg23(currentApprox).toDouble()
  227. jacobiMatrix.masive[2][4] = Allfunc.cg24(currentApprox).toDouble()
  228. jacobiMatrix.masive[2][5] = Allfunc.cg25(currentApprox).toDouble()
  229. jacobiMatrix.masive[2][6] = Allfunc.cg26(currentApprox).toDouble()
  230. jacobiMatrix.masive[2][7] = Allfunc.cg27(currentApprox).toDouble()
  231. jacobiMatrix.masive[2][8] = Allfunc.cg28(currentApprox).toDouble()
  232. jacobiMatrix.masive[2][9] = Allfunc.cg29(currentApprox).toDouble()
  233. jacobiMatrix.masive[3][0] = Allfunc.cg30(currentApprox).toDouble()
  234. jacobiMatrix.masive[3][1] = Allfunc.cg31(currentApprox).toDouble()
  235. jacobiMatrix.masive[3][2] = Allfunc.cg32(currentApprox).toDouble()
  236. jacobiMatrix.masive[3][3] = Allfunc.cg33(currentApprox).toDouble()
  237. jacobiMatrix.masive[3][4] = Allfunc.cg34(currentApprox).toDouble()
  238. jacobiMatrix.masive[3][5] = Allfunc.cg35(currentApprox).toDouble()
  239. jacobiMatrix.masive[3][6] = Allfunc.cg36(currentApprox).toDouble()
  240. jacobiMatrix.masive[3][7] = Allfunc.cg37(currentApprox).toDouble()
  241. jacobiMatrix.masive[3][8] = Allfunc.cg38(currentApprox).toDouble()
  242. jacobiMatrix.masive[3][9] = Allfunc.cg39(currentApprox).toDouble()
  243. jacobiMatrix.masive[4][0] = Allfunc.cg40(currentApprox).toDouble()
  244. jacobiMatrix.masive[4][1] = Allfunc.cg41(currentApprox).toDouble()
  245. jacobiMatrix.masive[4][2] = Allfunc.cg42(currentApprox).toDouble()
  246. jacobiMatrix.masive[4][3] = Allfunc.cg43(currentApprox).toDouble()
  247. jacobiMatrix.masive[4][4] = Allfunc.cg44(currentApprox).toDouble()
  248. jacobiMatrix.masive[4][5] = Allfunc.cg45(currentApprox).toDouble()
  249. jacobiMatrix.masive[4][6] = Allfunc.cg46(currentApprox).toDouble()
  250. jacobiMatrix.masive[4][7] = Allfunc.cg47(currentApprox).toDouble()
  251. jacobiMatrix.masive[4][8] = Allfunc.cg48(currentApprox).toDouble()
  252. jacobiMatrix.masive[4][9] = Allfunc.cg49(currentApprox).toDouble()
  253. jacobiMatrix.masive[5][0] = Allfunc.cg50(currentApprox).toDouble()
  254. jacobiMatrix.masive[5][1] = Allfunc.cg51(currentApprox).toDouble()
  255. jacobiMatrix.masive[5][2] = Allfunc.cg52(currentApprox).toDouble()
  256. jacobiMatrix.masive[5][3] = Allfunc.cg53(currentApprox).toDouble()
  257. jacobiMatrix.masive[5][4] = Allfunc.cg54(currentApprox).toDouble()
  258. jacobiMatrix.masive[5][5] = Allfunc.cg55(currentApprox).toDouble()
  259. jacobiMatrix.masive[5][6] = Allfunc.cg56(currentApprox).toDouble()
  260. jacobiMatrix.masive[5][7] = Allfunc.cg57(currentApprox).toDouble()
  261. jacobiMatrix.masive[5][8] = Allfunc.cg58(currentApprox).toDouble()
  262. jacobiMatrix.masive[5][9] = Allfunc.cg59(currentApprox).toDouble()
  263. jacobiMatrix.masive[6][0] = Allfunc.cg60(currentApprox).toDouble()
  264. jacobiMatrix.masive[6][1] = Allfunc.cg61(currentApprox).toDouble()
  265. jacobiMatrix.masive[6][2] = Allfunc.cg62(currentApprox).toDouble()
  266. jacobiMatrix.masive[6][3] = Allfunc.cg63(currentApprox).toDouble()
  267. jacobiMatrix.masive[6][4] = Allfunc.cg64(currentApprox).toDouble()
  268. jacobiMatrix.masive[6][5] = Allfunc.cg65(currentApprox).toDouble()
  269. jacobiMatrix.masive[6][6] = Allfunc.cg66(currentApprox).toDouble()
  270. jacobiMatrix.masive[6][7] = Allfunc.cg67(currentApprox).toDouble()
  271. jacobiMatrix.masive[6][8] = Allfunc.cg68(currentApprox).toDouble()
  272. jacobiMatrix.masive[6][9] = Allfunc.cg69(currentApprox).toDouble()
  273. jacobiMatrix.masive[7][0] = Allfunc.cg70(currentApprox).toDouble()
  274. jacobiMatrix.masive[7][1] = Allfunc.cg71(currentApprox).toDouble()
  275. jacobiMatrix.masive[7][2] = Allfunc.cg72(currentApprox).toDouble()
  276. jacobiMatrix.masive[7][3] = Allfunc.cg73(currentApprox).toDouble()
  277. jacobiMatrix.masive[7][4] = Allfunc.cg74(currentApprox).toDouble()
  278. jacobiMatrix.masive[7][5] = Allfunc.cg75(currentApprox).toDouble()
  279. jacobiMatrix.masive[7][6] = Allfunc.cg76(currentApprox).toDouble()
  280. jacobiMatrix.masive[7][7] = Allfunc.cg77(currentApprox).toDouble()
  281. jacobiMatrix.masive[7][8] = Allfunc.cg78(currentApprox).toDouble()
  282. jacobiMatrix.masive[7][9] = Allfunc.cg79(currentApprox).toDouble()
  283. jacobiMatrix.masive[8][0] = Allfunc.cg80(currentApprox).toDouble()
  284. jacobiMatrix.masive[8][1] = Allfunc.cg81(currentApprox).toDouble()
  285. jacobiMatrix.masive[8][2] = Allfunc.cg82(currentApprox).toDouble()
  286. jacobiMatrix.masive[8][3] = Allfunc.cg83(currentApprox).toDouble()
  287. jacobiMatrix.masive[8][4] = Allfunc.cg84(currentApprox).toDouble()
  288. jacobiMatrix.masive[8][5] = Allfunc.cg85(currentApprox).toDouble()
  289. jacobiMatrix.masive[8][6] = Allfunc.cg86(currentApprox).toDouble()
  290. jacobiMatrix.masive[8][7] = Allfunc.cg87(currentApprox).toDouble()
  291. jacobiMatrix.masive[8][8] = Allfunc.cg88(currentApprox).toDouble()
  292. jacobiMatrix.masive[8][9] = Allfunc.cg89(currentApprox).toDouble()
  293. jacobiMatrix.masive[9][0] = Allfunc.cg90(currentApprox).toDouble()
  294. jacobiMatrix.masive[9][1] = Allfunc.cg91(currentApprox).toDouble()
  295. jacobiMatrix.masive[9][2] = Allfunc.cg92(currentApprox).toDouble()
  296. jacobiMatrix.masive[9][3] = Allfunc.cg93(currentApprox).toDouble()
  297. jacobiMatrix.masive[9][4] = Allfunc.cg94(currentApprox).toDouble()
  298. jacobiMatrix.masive[9][5] = Allfunc.cg95(currentApprox).toDouble()
  299. jacobiMatrix.masive[9][6] = Allfunc.cg96(currentApprox).toDouble()
  300. jacobiMatrix.masive[9][7] = Allfunc.cg97(currentApprox).toDouble()
  301. jacobiMatrix.masive[9][8] = Allfunc.cg98(currentApprox).toDouble()
  302. jacobiMatrix.masive[9][9] = Allfunc.cg99(currentApprox).toDouble()
  303. return jacobiMatrix
  304. }
  305.  
  306. fun getEquationSystem(currentApprox: DoubleArray): Matrix {
  307. val equationSystem = Matrix(Array(10, { Array(1, { 0.0 }) }))
  308. equationSystem.masive[0][0] = Allfunc.eq0(currentApprox)
  309. equationSystem.masive[1][0] = Allfunc.eq1(currentApprox)
  310. equationSystem.masive[2][0] = Allfunc.eq2(currentApprox)
  311. equationSystem.masive[3][0] = Allfunc.eq3(currentApprox)
  312. equationSystem.masive[4][0] = Allfunc.eq4(currentApprox)
  313. equationSystem.masive[5][0] = Allfunc.eq5(currentApprox)
  314. equationSystem.masive[6][0] = Allfunc.eq6(currentApprox)
  315. equationSystem.masive[7][0] = Allfunc.eq7(currentApprox)
  316. equationSystem.masive[8][0] = Allfunc.eq8(currentApprox)
  317. equationSystem.masive[9][0] = Allfunc.eq9(currentApprox)
  318. return equationSystem
  319. }
  320. }
  321. }
  322.  
  323.  
  324. import kotlin.math.*
  325.  
  326. class Allfunc {
  327. companion object {
  328. fun eq0(x: DoubleArray) = Math.cos(x[0] * x[1]) - Math.exp(-3 * x[2]) + x[3] * x[4] * x[4] - x[5] - Math.sinh(2 * x[7]) * x[8] + 2 * x[9] + 2.0004339741653854440
  329. fun eq1(x: DoubleArray) = Math.sin(x[0] * x[1]) + x[2] * x[8] * x[6] - Math.exp(-x[9] + x[5]) + 3.0 * x[4] * x[4] - x[5] * (x[7] + 1) + 10.886272036407019994
  330. fun eq2(x: DoubleArray) = x[0] - x[1] + x[2] - x[3] + x[4] - x[5] + x[6] - x[7] + x[8] - x[9] - 3.1361904761904761904
  331. fun eq3(x: DoubleArray) = 2 * Math.cos(-x[8] + x[3]) + x[4] / (x[2] + x[0]) - Math.sin(x[1] * x[1]) + Math.pow(Math.cos(x[6] * x[9]), 2.0) - x[7] - 0.1707472705022304757
  332. fun eq4(x: DoubleArray) = Math.sin(x[4]) + 2.0 * x[7] * (x[2] + x[0]) - Math.exp(-x[6] * (-x[9] + x[5])) + 2 * Math.cos(x[1]) - 1 / (x[3] - x[8]) - 0.3685896273101277862
  333. fun eq5(x: DoubleArray) = Math.exp(x[0] - x[3] - x[8]) + x[4] * x[4] / x[7] + Math.cos(3.0 * x[9] * x[1]) / 2 - x[5] * x[2] + 2.0491086016771875115
  334. fun eq6(x: DoubleArray) = Math.pow(x[1], 3.0) * x[6] - Math.sin(x[9] / x[4] + x[7]) + (x[0] - x[5]) * Math.cos(x[3]) + x[2] - 0.7380430076202798014
  335. fun eq7(x: DoubleArray) = x[4] * Math.pow(x[0] - 2 * x[5], 2.0) - 2 * Math.sin(-x[8] + x[2]) + 1.5 * x[3] - Math.exp(x[1] * x[6] + x[9]) + 3.5668321989693809040
  336. fun eq8(x: DoubleArray) = 7 / x[5] + Math.exp(x[4] + x[3]) - 2.0 * x[1] * x[7] * x[9] * x[6] + 3 * x[8] - 3 * x[0] - 8.4394734508383257499
  337. fun eq9(x: DoubleArray) = x[9] * x[0] + x[8] * x[1] - x[7] * x[2] + Math.sin(x[3] + x[4] + x[5]) * x[6] - 0.78238095238095238096
  338. fun cg00(x: DoubleArray) = -sin(x[0] * x[1]) * x[1]
  339. fun cg01(x: DoubleArray) = -sin(x[0] * x[1]) * x[0]
  340. fun cg02(x: DoubleArray) = 3 * exp(-(3 * x[2]))
  341. fun cg03(x: DoubleArray) = x[4] * x[4]
  342. fun cg04(x: DoubleArray) = 2 * x[3] * x[4]
  343. fun cg05(x: DoubleArray) = -1
  344. fun cg06(x: DoubleArray) = 0
  345. fun cg07(x: DoubleArray) = -2 * cosh((2 * x[7])) * x[8]
  346. fun cg08(x: DoubleArray) = -sinh((2 * x[7]))
  347. fun cg09(x: DoubleArray) = 2
  348. fun cg10(x: DoubleArray) = cos(x[0] * x[1]) * x[1]
  349. fun cg11(x: DoubleArray) = cos(x[0] * x[1]) * x[0]
  350. fun cg12(x: DoubleArray) = x[8] * x[6]
  351. fun cg13(x: DoubleArray) = 0
  352. fun cg14(x: DoubleArray) = 6 * x[4]
  353. fun cg15(x: DoubleArray) = -exp(-x[9] + x[5]) - x[7] - 01e1
  354. fun cg16(x: DoubleArray) = x[2] * x[8]
  355. fun cg17(x: DoubleArray) = -x[5]
  356. fun cg18(x: DoubleArray) = x[2] * x[6]
  357. fun cg19(x: DoubleArray) = exp(-x[9] + x[5])
  358. fun cg20(x: DoubleArray) = 1
  359. fun cg21(x: DoubleArray) = -1
  360. fun cg22(x: DoubleArray) = 1
  361. fun cg23(x: DoubleArray) = -1
  362. fun cg24(x: DoubleArray) = 1
  363. fun cg25(x: DoubleArray) = -1
  364. fun cg26(x: DoubleArray) = 1
  365. fun cg27(x: DoubleArray) = -1
  366. fun cg28(x: DoubleArray) = 1
  367. fun cg29(x: DoubleArray) = -1
  368. fun cg30(x: DoubleArray) = -x[4] * Math.pow(x[2] + x[0], -2.0)
  369. fun cg31(x: DoubleArray) = -2 * cos(x[1] * x[1]) * x[1]
  370. fun cg32(x: DoubleArray) = -x[4] * Math.pow(x[2] + x[0], -2.0)
  371. fun cg33(x: DoubleArray) = -2 * sin(-x[8] + x[3])
  372. fun cg34(x: DoubleArray) = 1 / (x[2] + x[0])
  373. fun cg35(x: DoubleArray) = 0
  374. fun cg36(x: DoubleArray) = -2 * cos(x[6] * x[9]) * sin(x[6] * x[9]) * x[9]
  375. fun cg37(x: DoubleArray) = -1
  376. fun cg38(x: DoubleArray) = 2 * sin(-x[8] + x[3])
  377. fun cg39(x: DoubleArray) = -2 * cos(x[6] * x[9]) * sin(x[6] * x[9]) * x[6]
  378. fun cg40(x: DoubleArray) = 2 * x[7]
  379. fun cg41(x: DoubleArray) = -2 * sin(x[1])
  380. fun cg42(x: DoubleArray) = 2 * x[7]
  381. fun cg43(x: DoubleArray) = Math.pow(-x[8] + x[3], -2.0)
  382. fun cg44(x: DoubleArray) = cos(x[4])
  383. fun cg45(x: DoubleArray) = x[6] * exp(-x[6] * (-x[9] + x[5]))
  384. fun cg46(x: DoubleArray) = -(x[9] - x[5]) * exp(-x[6] * (-x[9] + x[5]))
  385. fun cg47(x: DoubleArray) = (2 * x[2]) + 2 * x[0]
  386. fun cg48(x: DoubleArray) = -Math.pow(-x[8] + x[3], -2.0)
  387. fun cg49(x: DoubleArray) = -x[6] * exp(-x[6] * (-x[9] + x[5]))
  388. fun cg50(x: DoubleArray) = exp(x[0] - x[3] - x[8])
  389. fun cg51(x: DoubleArray) = -3 / 2 * sin(3 * x[9] * x[1]) * x[9]
  390. fun cg52(x: DoubleArray) = -x[5]
  391. fun cg53(x: DoubleArray) = -exp(x[0] - x[3] - x[8])
  392. fun cg54(x: DoubleArray) = 2 * x[4] / x[7]
  393. fun cg55(x: DoubleArray) = -x[2]
  394. fun cg56(x: DoubleArray) = 0
  395. fun cg57(x: DoubleArray) = -x[4] * x[4] * Math.pow(x[7], (-2.0))
  396. fun cg58(x: DoubleArray) = -exp(x[0] - x[3] - x[8])
  397. fun cg59(x: DoubleArray) = -3 / 2 * sin(3 * x[9] * x[1]) * x[1]
  398. fun cg60(x: DoubleArray) = cos(x[3])
  399. fun cg61(x: DoubleArray) = 3 * x[1] * x[1] * x[6]
  400. fun cg62(x: DoubleArray) = 1
  401. fun cg63(x: DoubleArray) = -(x[0] - x[5]) * sin(x[3])
  402. fun cg64(x: DoubleArray) = cos(x[9] / x[4] + x[7]) * x[9] * Math.pow(x[4], (-2.0))
  403. fun cg65(x: DoubleArray) = -cos(x[3])
  404. fun cg66(x: DoubleArray) = Math.pow(x[1], 3.0)
  405. fun cg67(x: DoubleArray) = -cos(x[9] / x[4] + x[7])
  406. fun cg68(x: DoubleArray) = 0
  407. fun cg69(x: DoubleArray) = -cos(x[9] / x[4] + x[7]) / x[4]
  408. fun cg70(x: DoubleArray) = 2 * x[4] * (x[0] - 2 * x[5])
  409. fun cg71(x: DoubleArray) = -x[6] * exp(x[1] * x[6] + x[9])
  410. fun cg72(x: DoubleArray) = -2 * cos(-x[8] + x[2])
  411. fun cg73(x: DoubleArray) = 015e1
  412. fun cg74(x: DoubleArray) = Math.pow(x[0] - 2 * x[5], 2.0)
  413. fun cg75(x: DoubleArray) = -4 * x[4] * (x[0] - 2 * x[5])
  414. fun cg76(x: DoubleArray) = -x[1] * exp(x[1] * x[6] + x[9])
  415. fun cg77(x: DoubleArray) = 0
  416. fun cg78(x: DoubleArray) = 2 * cos(-x[8] + x[2])
  417. fun cg79(x: DoubleArray) = -exp(x[1] * x[6] + x[9])
  418. fun cg80(x: DoubleArray) = -3
  419. fun cg81(x: DoubleArray) = -2 * x[7] * x[9] * x[6]
  420. fun cg82(x: DoubleArray) = 0
  421. fun cg83(x: DoubleArray) = exp((x[4] + x[3]))
  422. fun cg84(x: DoubleArray) = exp((x[4] + x[3]))
  423. fun cg85(x: DoubleArray) = -07e1 * Math.pow(x[5], -2.0)
  424. fun cg86(x: DoubleArray) = -2 * x[1] * x[7] * x[9]
  425. fun cg87(x: DoubleArray) = -2 * x[1] * x[9] * x[6]
  426. fun cg88(x: DoubleArray) = 3
  427. fun cg89(x: DoubleArray) = -2 * x[1] * x[7] * x[6]
  428. fun cg90(x: DoubleArray) = x[9]
  429. fun cg91(x: DoubleArray) = x[8]
  430. fun cg92(x: DoubleArray) = -x[7]
  431. fun cg93(x: DoubleArray) = cos(x[3] + x[4] + x[5]) * x[6]
  432. fun cg94(x: DoubleArray) = cos(x[3] + x[4] + x[5]) * x[6]
  433. fun cg95(x: DoubleArray) = cos(x[3] + x[4] + x[5]) * x[6]
  434. fun cg96(x: DoubleArray) = sin(x[3] + x[4] + x[5])
  435. fun cg97(x: DoubleArray) = -x[2]
  436. fun cg98(x: DoubleArray) = x[1]
  437. fun cg99(x: DoubleArray) = x[0]
  438. }
  439. }
  440.  
  441. operator fun unaryMinus(): Matrix {
  442. var a = Array(this.numberOfRows(), { Array(this.numberOfCollumbs(), { 0.0 }) })
  443.  
  444. for (i in 0 until this.numberOfRows())
  445. for (j in 0 until this.numberOfCollumbs())
  446. a[i][j]=-this.masive[i][j]
  447. return Matrix(a)
  448.  
  449.  
  450. }
  451. fun matrixCollumbtoArray():DoubleArray{
  452. val a = DoubleArray(this.masive.size,{0.0})
  453. for(i in 0 until this.masive.size)
  454. a[i]=this.masive[i][0]
  455. return a
  456. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement