Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*
- import kotlin.math.abs
- import kotlin.math.max
- val currentApprox = doubleArrayOf(0.5, 0.5, 1.5, -1.0, -0.5, 1.5, 0.5, -0.5, 1.5, -1.5)
- fun main(args:Array<String>){
- var startTime:Long
- var timeSpent:Long
- //testSimpleNewtonMethod()
- //val numbers=findBestModHybridNewtonMethod().first
- //println(numbers)
- testModHybridNewtonMethod(1)
- println(NewtonMethod.numberOfCall)
- //println(Arrays.toString(modHybridNewtonMethod(currentApprox,2).first))
- //println(modHybridNewtonMethod(currentApprox,2).second)
- //testModNewtonMethod()
- //testModHybridNewtonMethod()
- //print("${findBestModHybridNewtonMethod().first} ${findBestModHybridNewtonMethod().second}")
- /*
- startTime=System.nanoTime()
- val ourModApprox=modNewtonMethod(currentApprox)
- println(Arrays.toString(ourModApprox))
- timeSpent = System.nanoTime()- startTime
- println(timeSpent)
- */
- /*
- startTime=System.nanoTime()
- val ourModHybridApprox=modHybridNewtonMethod(currentApprox,1)
- println(Arrays.toString(ourModHybridApprox))
- timeSpent = System.nanoTime() - startTime
- println(timeSpent)
- */
- }
- fun simpleNewtonMethod(currentApprox: DoubleArray):Pair<DoubleArray,Int>{
- var numberOfIteration=0
- var nextApprox=currentApprox
- var currentApprox=DoubleArray(currentApprox.size,{0.0})
- while (getNorm(currentApprox,nextApprox)>1E-15){
- numberOfIteration++
- currentApprox=nextApprox
- nextApprox=simpleNewtonMethodIteration(currentApprox)
- }
- return Pair(nextApprox,numberOfIteration)
- }
- fun modNewtonMethod(currentApprox: DoubleArray):Pair<DoubleArray,Int>{
- val jacobiMatrix=NewtonMethod.getJacobiMatrix(currentApprox)
- var numberOfIteration=0
- var nextApprox=currentApprox
- var currentApprox=DoubleArray(currentApprox.size,{0.0})
- while (getNorm(currentApprox,nextApprox)>1E-15){
- numberOfIteration++
- currentApprox=nextApprox
- nextApprox=modNewtonMethodIteration(currentApprox,jacobiMatrix)
- }
- return Pair(nextApprox,numberOfIteration)
- }
- fun simpleNewtonMethodIteration(currentApprox:DoubleArray):DoubleArray{
- val equationSystem = NewtonMethod.getEquationSystem(currentApprox)
- val jacobiMatrix = NewtonMethod.getJacobiMatrix(currentApprox)
- val FF=inverseMatrix(jacobiMatrix)*equationSystem
- val nextApprox=DoubleArray(currentApprox.size,{0.0})
- for (i in 0 until currentApprox.size) {
- nextApprox[i] = currentApprox[i] - FF.masive[i][0]
- }
- return nextApprox
- }
- fun modNewtonMethodIteration(currentApprox:DoubleArray,jacobiMatrix: Matrix):DoubleArray{
- var approximation=solutionMatrix(jacobiMatrix,-NewtonMethod.getEquationSystem(currentApprox)).matrixCollumbtoArray()
- var nextApprox=DoubleArray(currentApprox.size,{0.0})
- for(i in 0 until currentApprox.size)
- nextApprox[i]=currentApprox[i]+approximation[i]
- return nextApprox
- }
- fun modHybridNewtonMethod(currentApprox: DoubleArray,iter:Int):Pair<DoubleArray,Int>{
- var nextApprox=currentApprox
- var currentApprox=DoubleArray(currentApprox.size,{0.0})
- for (i in 0..iter){
- currentApprox=nextApprox
- nextApprox=simpleNewtonMethodIteration(currentApprox)
- }
- val (nextApprox2,numberOfIteration)=modNewtonMethod(nextApprox)
- return Pair(nextApprox2,numberOfIteration)
- }
- fun modHybridNewtonMethod2(currentApprox: DoubleArray,iter:Int):Pair<DoubleArray,Int>{
- val jacobiMatrix=NewtonMethod.getJacobiMatrix(currentApprox)
- var numberOfIteration=0
- var nextApprox=currentApprox
- var currentApprox=DoubleArray(currentApprox.size,{0.0})
- while (getNorm(currentApprox,nextApprox)>1E-15){
- numberOfIteration++
- currentApprox=nextApprox
- nextApprox=modNewtonMethodIteration(currentApprox,jacobiMatrix)
- }
- return Pair(nextApprox,numberOfIteration)
- }
- fun getNorm(currentApprox: DoubleArray,nextApprox:DoubleArray):Double{
- var maxelem = 0.0
- for(i in 0 until currentApprox.size)
- maxelem = max(abs(nextApprox[i]-currentApprox[i]), (maxelem))
- return maxelem
- }
- fun testSimpleNewtonMethod(){
- var ourApprox=simpleNewtonMethod(currentApprox)
- var startTime = System.nanoTime()
- ourApprox=simpleNewtonMethod(currentApprox)
- var timeSpent = System.nanoTime() - startTime
- println(Arrays.toString(ourApprox.first))
- println("число итераций ${ourApprox.second}")
- println("warn $timeSpent")
- }
- fun testModNewtonMethod(){
- var ourModApprox=modNewtonMethod(currentApprox)
- var startTime = System.nanoTime()
- ourModApprox=modNewtonMethod(currentApprox)
- var timeSpent = System.nanoTime() - startTime
- println(Arrays.toString(ourModApprox.first))
- println("число итераций ${ourModApprox.second}")
- println("warn $timeSpent")
- }
- fun testModHybridNewtonMethod(iter:Int){
- var ourModHybridApprox=modHybridNewtonMethod(currentApprox,iter)
- var startTime = System.nanoTime()
- ourModHybridApprox=modHybridNewtonMethod(currentApprox,iter)
- var timeSpent = System.nanoTime() - startTime
- println(Arrays.toString(ourModHybridApprox.first))
- println("число итераций ${ourModHybridApprox.second}")
- println("warn $timeSpent")
- }
- fun findBestModHybridNewtonMethod():Pair<Int,Long>{
- var ourModHybridApprox=modHybridNewtonMethod(currentApprox,1)
- var numberOfTheBest=0
- var minimum:Long=Long.MAX_VALUE
- for(i in 0 until 100) {
- ourModHybridApprox = modHybridNewtonMethod(currentApprox, i)
- var startTime = System.nanoTime()
- ourModHybridApprox = modHybridNewtonMethod(currentApprox, i)
- var timeSpent = System.nanoTime() - startTime
- if(timeSpent<minimum){
- minimum=timeSpent
- numberOfTheBest=i
- }
- }
- return Pair(numberOfTheBest,minimum)
- }
- /*
- fun modNewtonMethod2(currentApprox: DoubleArray):Pair<DoubleArray,Int>{
- var numberOfIteration=0
- var approximation=solutionMatrix(NewtonMethod.getJacobiMatrix(currentApprox),-NewtonMethod.getEquationSystem(currentApprox)).matrixCollumbtoArray()
- var nextApprox=currentApprox
- var currentApprox=DoubleArray(currentApprox.size,{0.0})
- while (getNorm(approximation)>1E-15){
- numberOfIteration++
- println(numberOfIteration)
- currentApprox=nextApprox
- for(i in 0 until currentApprox.size)
- nextApprox[i]=currentApprox[i]+approximation[i]
- approximation=solutionMatrix(NewtonMethod.getJacobiMatrix(currentApprox),-NewtonMethod.getEquationSystem(currentApprox)).matrixCollumbtoArray()
- }
- return Pair(nextApprox,numberOfIteration)
- }
- fun getNorm(currentApprox: DoubleArray):Double{
- var maxelem = 0.0
- for(i in 0 until currentApprox.size)
- maxelem = max(abs(currentApprox[i]), (maxelem))
- return maxelem
- }
- */
- class NewtonMethod {
- companion object {
- var numberOfCall=0
- fun getJacobiMatrix(currentApprox: DoubleArray): Matrix {
- numberOfCall++
- val jacobiMatrix = Matrix(Array(10, { Array(10, { 0.0 }) }))
- jacobiMatrix.masive[0][0] = Allfunc.cg00(currentApprox).toDouble()
- jacobiMatrix.masive[0][1] = Allfunc.cg01(currentApprox).toDouble()
- jacobiMatrix.masive[0][2] = Allfunc.cg02(currentApprox).toDouble()
- jacobiMatrix.masive[0][3] = Allfunc.cg03(currentApprox).toDouble()
- jacobiMatrix.masive[0][4] = Allfunc.cg04(currentApprox).toDouble()
- jacobiMatrix.masive[0][5] = Allfunc.cg05(currentApprox).toDouble()
- jacobiMatrix.masive[0][6] = Allfunc.cg06(currentApprox).toDouble()
- jacobiMatrix.masive[0][7] = Allfunc.cg07(currentApprox).toDouble()
- jacobiMatrix.masive[0][8] = Allfunc.cg08(currentApprox).toDouble()
- jacobiMatrix.masive[0][9] = Allfunc.cg09(currentApprox).toDouble()
- jacobiMatrix.masive[1][0] = Allfunc.cg10(currentApprox).toDouble()
- jacobiMatrix.masive[1][1] = Allfunc.cg11(currentApprox).toDouble()
- jacobiMatrix.masive[1][2] = Allfunc.cg12(currentApprox).toDouble()
- jacobiMatrix.masive[1][3] = Allfunc.cg13(currentApprox).toDouble()
- jacobiMatrix.masive[1][4] = Allfunc.cg14(currentApprox).toDouble()
- jacobiMatrix.masive[1][5] = Allfunc.cg15(currentApprox).toDouble()
- jacobiMatrix.masive[1][6] = Allfunc.cg16(currentApprox).toDouble()
- jacobiMatrix.masive[1][7] = Allfunc.cg17(currentApprox).toDouble()
- jacobiMatrix.masive[1][8] = Allfunc.cg18(currentApprox).toDouble()
- jacobiMatrix.masive[1][9] = Allfunc.cg19(currentApprox).toDouble()
- jacobiMatrix.masive[2][0] = Allfunc.cg20(currentApprox).toDouble()
- jacobiMatrix.masive[2][1] = Allfunc.cg21(currentApprox).toDouble()
- jacobiMatrix.masive[2][2] = Allfunc.cg22(currentApprox).toDouble()
- jacobiMatrix.masive[2][3] = Allfunc.cg23(currentApprox).toDouble()
- jacobiMatrix.masive[2][4] = Allfunc.cg24(currentApprox).toDouble()
- jacobiMatrix.masive[2][5] = Allfunc.cg25(currentApprox).toDouble()
- jacobiMatrix.masive[2][6] = Allfunc.cg26(currentApprox).toDouble()
- jacobiMatrix.masive[2][7] = Allfunc.cg27(currentApprox).toDouble()
- jacobiMatrix.masive[2][8] = Allfunc.cg28(currentApprox).toDouble()
- jacobiMatrix.masive[2][9] = Allfunc.cg29(currentApprox).toDouble()
- jacobiMatrix.masive[3][0] = Allfunc.cg30(currentApprox).toDouble()
- jacobiMatrix.masive[3][1] = Allfunc.cg31(currentApprox).toDouble()
- jacobiMatrix.masive[3][2] = Allfunc.cg32(currentApprox).toDouble()
- jacobiMatrix.masive[3][3] = Allfunc.cg33(currentApprox).toDouble()
- jacobiMatrix.masive[3][4] = Allfunc.cg34(currentApprox).toDouble()
- jacobiMatrix.masive[3][5] = Allfunc.cg35(currentApprox).toDouble()
- jacobiMatrix.masive[3][6] = Allfunc.cg36(currentApprox).toDouble()
- jacobiMatrix.masive[3][7] = Allfunc.cg37(currentApprox).toDouble()
- jacobiMatrix.masive[3][8] = Allfunc.cg38(currentApprox).toDouble()
- jacobiMatrix.masive[3][9] = Allfunc.cg39(currentApprox).toDouble()
- jacobiMatrix.masive[4][0] = Allfunc.cg40(currentApprox).toDouble()
- jacobiMatrix.masive[4][1] = Allfunc.cg41(currentApprox).toDouble()
- jacobiMatrix.masive[4][2] = Allfunc.cg42(currentApprox).toDouble()
- jacobiMatrix.masive[4][3] = Allfunc.cg43(currentApprox).toDouble()
- jacobiMatrix.masive[4][4] = Allfunc.cg44(currentApprox).toDouble()
- jacobiMatrix.masive[4][5] = Allfunc.cg45(currentApprox).toDouble()
- jacobiMatrix.masive[4][6] = Allfunc.cg46(currentApprox).toDouble()
- jacobiMatrix.masive[4][7] = Allfunc.cg47(currentApprox).toDouble()
- jacobiMatrix.masive[4][8] = Allfunc.cg48(currentApprox).toDouble()
- jacobiMatrix.masive[4][9] = Allfunc.cg49(currentApprox).toDouble()
- jacobiMatrix.masive[5][0] = Allfunc.cg50(currentApprox).toDouble()
- jacobiMatrix.masive[5][1] = Allfunc.cg51(currentApprox).toDouble()
- jacobiMatrix.masive[5][2] = Allfunc.cg52(currentApprox).toDouble()
- jacobiMatrix.masive[5][3] = Allfunc.cg53(currentApprox).toDouble()
- jacobiMatrix.masive[5][4] = Allfunc.cg54(currentApprox).toDouble()
- jacobiMatrix.masive[5][5] = Allfunc.cg55(currentApprox).toDouble()
- jacobiMatrix.masive[5][6] = Allfunc.cg56(currentApprox).toDouble()
- jacobiMatrix.masive[5][7] = Allfunc.cg57(currentApprox).toDouble()
- jacobiMatrix.masive[5][8] = Allfunc.cg58(currentApprox).toDouble()
- jacobiMatrix.masive[5][9] = Allfunc.cg59(currentApprox).toDouble()
- jacobiMatrix.masive[6][0] = Allfunc.cg60(currentApprox).toDouble()
- jacobiMatrix.masive[6][1] = Allfunc.cg61(currentApprox).toDouble()
- jacobiMatrix.masive[6][2] = Allfunc.cg62(currentApprox).toDouble()
- jacobiMatrix.masive[6][3] = Allfunc.cg63(currentApprox).toDouble()
- jacobiMatrix.masive[6][4] = Allfunc.cg64(currentApprox).toDouble()
- jacobiMatrix.masive[6][5] = Allfunc.cg65(currentApprox).toDouble()
- jacobiMatrix.masive[6][6] = Allfunc.cg66(currentApprox).toDouble()
- jacobiMatrix.masive[6][7] = Allfunc.cg67(currentApprox).toDouble()
- jacobiMatrix.masive[6][8] = Allfunc.cg68(currentApprox).toDouble()
- jacobiMatrix.masive[6][9] = Allfunc.cg69(currentApprox).toDouble()
- jacobiMatrix.masive[7][0] = Allfunc.cg70(currentApprox).toDouble()
- jacobiMatrix.masive[7][1] = Allfunc.cg71(currentApprox).toDouble()
- jacobiMatrix.masive[7][2] = Allfunc.cg72(currentApprox).toDouble()
- jacobiMatrix.masive[7][3] = Allfunc.cg73(currentApprox).toDouble()
- jacobiMatrix.masive[7][4] = Allfunc.cg74(currentApprox).toDouble()
- jacobiMatrix.masive[7][5] = Allfunc.cg75(currentApprox).toDouble()
- jacobiMatrix.masive[7][6] = Allfunc.cg76(currentApprox).toDouble()
- jacobiMatrix.masive[7][7] = Allfunc.cg77(currentApprox).toDouble()
- jacobiMatrix.masive[7][8] = Allfunc.cg78(currentApprox).toDouble()
- jacobiMatrix.masive[7][9] = Allfunc.cg79(currentApprox).toDouble()
- jacobiMatrix.masive[8][0] = Allfunc.cg80(currentApprox).toDouble()
- jacobiMatrix.masive[8][1] = Allfunc.cg81(currentApprox).toDouble()
- jacobiMatrix.masive[8][2] = Allfunc.cg82(currentApprox).toDouble()
- jacobiMatrix.masive[8][3] = Allfunc.cg83(currentApprox).toDouble()
- jacobiMatrix.masive[8][4] = Allfunc.cg84(currentApprox).toDouble()
- jacobiMatrix.masive[8][5] = Allfunc.cg85(currentApprox).toDouble()
- jacobiMatrix.masive[8][6] = Allfunc.cg86(currentApprox).toDouble()
- jacobiMatrix.masive[8][7] = Allfunc.cg87(currentApprox).toDouble()
- jacobiMatrix.masive[8][8] = Allfunc.cg88(currentApprox).toDouble()
- jacobiMatrix.masive[8][9] = Allfunc.cg89(currentApprox).toDouble()
- jacobiMatrix.masive[9][0] = Allfunc.cg90(currentApprox).toDouble()
- jacobiMatrix.masive[9][1] = Allfunc.cg91(currentApprox).toDouble()
- jacobiMatrix.masive[9][2] = Allfunc.cg92(currentApprox).toDouble()
- jacobiMatrix.masive[9][3] = Allfunc.cg93(currentApprox).toDouble()
- jacobiMatrix.masive[9][4] = Allfunc.cg94(currentApprox).toDouble()
- jacobiMatrix.masive[9][5] = Allfunc.cg95(currentApprox).toDouble()
- jacobiMatrix.masive[9][6] = Allfunc.cg96(currentApprox).toDouble()
- jacobiMatrix.masive[9][7] = Allfunc.cg97(currentApprox).toDouble()
- jacobiMatrix.masive[9][8] = Allfunc.cg98(currentApprox).toDouble()
- jacobiMatrix.masive[9][9] = Allfunc.cg99(currentApprox).toDouble()
- return jacobiMatrix
- }
- fun getEquationSystem(currentApprox: DoubleArray): Matrix {
- val equationSystem = Matrix(Array(10, { Array(1, { 0.0 }) }))
- equationSystem.masive[0][0] = Allfunc.eq0(currentApprox)
- equationSystem.masive[1][0] = Allfunc.eq1(currentApprox)
- equationSystem.masive[2][0] = Allfunc.eq2(currentApprox)
- equationSystem.masive[3][0] = Allfunc.eq3(currentApprox)
- equationSystem.masive[4][0] = Allfunc.eq4(currentApprox)
- equationSystem.masive[5][0] = Allfunc.eq5(currentApprox)
- equationSystem.masive[6][0] = Allfunc.eq6(currentApprox)
- equationSystem.masive[7][0] = Allfunc.eq7(currentApprox)
- equationSystem.masive[8][0] = Allfunc.eq8(currentApprox)
- equationSystem.masive[9][0] = Allfunc.eq9(currentApprox)
- return equationSystem
- }
- }
- }
- import kotlin.math.*
- class Allfunc {
- companion object {
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- fun cg00(x: DoubleArray) = -sin(x[0] * x[1]) * x[1]
- fun cg01(x: DoubleArray) = -sin(x[0] * x[1]) * x[0]
- fun cg02(x: DoubleArray) = 3 * exp(-(3 * x[2]))
- fun cg03(x: DoubleArray) = x[4] * x[4]
- fun cg04(x: DoubleArray) = 2 * x[3] * x[4]
- fun cg05(x: DoubleArray) = -1
- fun cg06(x: DoubleArray) = 0
- fun cg07(x: DoubleArray) = -2 * cosh((2 * x[7])) * x[8]
- fun cg08(x: DoubleArray) = -sinh((2 * x[7]))
- fun cg09(x: DoubleArray) = 2
- fun cg10(x: DoubleArray) = cos(x[0] * x[1]) * x[1]
- fun cg11(x: DoubleArray) = cos(x[0] * x[1]) * x[0]
- fun cg12(x: DoubleArray) = x[8] * x[6]
- fun cg13(x: DoubleArray) = 0
- fun cg14(x: DoubleArray) = 6 * x[4]
- fun cg15(x: DoubleArray) = -exp(-x[9] + x[5]) - x[7] - 01e1
- fun cg16(x: DoubleArray) = x[2] * x[8]
- fun cg17(x: DoubleArray) = -x[5]
- fun cg18(x: DoubleArray) = x[2] * x[6]
- fun cg19(x: DoubleArray) = exp(-x[9] + x[5])
- fun cg20(x: DoubleArray) = 1
- fun cg21(x: DoubleArray) = -1
- fun cg22(x: DoubleArray) = 1
- fun cg23(x: DoubleArray) = -1
- fun cg24(x: DoubleArray) = 1
- fun cg25(x: DoubleArray) = -1
- fun cg26(x: DoubleArray) = 1
- fun cg27(x: DoubleArray) = -1
- fun cg28(x: DoubleArray) = 1
- fun cg29(x: DoubleArray) = -1
- fun cg30(x: DoubleArray) = -x[4] * Math.pow(x[2] + x[0], -2.0)
- fun cg31(x: DoubleArray) = -2 * cos(x[1] * x[1]) * x[1]
- fun cg32(x: DoubleArray) = -x[4] * Math.pow(x[2] + x[0], -2.0)
- fun cg33(x: DoubleArray) = -2 * sin(-x[8] + x[3])
- fun cg34(x: DoubleArray) = 1 / (x[2] + x[0])
- fun cg35(x: DoubleArray) = 0
- fun cg36(x: DoubleArray) = -2 * cos(x[6] * x[9]) * sin(x[6] * x[9]) * x[9]
- fun cg37(x: DoubleArray) = -1
- fun cg38(x: DoubleArray) = 2 * sin(-x[8] + x[3])
- fun cg39(x: DoubleArray) = -2 * cos(x[6] * x[9]) * sin(x[6] * x[9]) * x[6]
- fun cg40(x: DoubleArray) = 2 * x[7]
- fun cg41(x: DoubleArray) = -2 * sin(x[1])
- fun cg42(x: DoubleArray) = 2 * x[7]
- fun cg43(x: DoubleArray) = Math.pow(-x[8] + x[3], -2.0)
- fun cg44(x: DoubleArray) = cos(x[4])
- fun cg45(x: DoubleArray) = x[6] * exp(-x[6] * (-x[9] + x[5]))
- fun cg46(x: DoubleArray) = -(x[9] - x[5]) * exp(-x[6] * (-x[9] + x[5]))
- fun cg47(x: DoubleArray) = (2 * x[2]) + 2 * x[0]
- fun cg48(x: DoubleArray) = -Math.pow(-x[8] + x[3], -2.0)
- fun cg49(x: DoubleArray) = -x[6] * exp(-x[6] * (-x[9] + x[5]))
- fun cg50(x: DoubleArray) = exp(x[0] - x[3] - x[8])
- fun cg51(x: DoubleArray) = -3 / 2 * sin(3 * x[9] * x[1]) * x[9]
- fun cg52(x: DoubleArray) = -x[5]
- fun cg53(x: DoubleArray) = -exp(x[0] - x[3] - x[8])
- fun cg54(x: DoubleArray) = 2 * x[4] / x[7]
- fun cg55(x: DoubleArray) = -x[2]
- fun cg56(x: DoubleArray) = 0
- fun cg57(x: DoubleArray) = -x[4] * x[4] * Math.pow(x[7], (-2.0))
- fun cg58(x: DoubleArray) = -exp(x[0] - x[3] - x[8])
- fun cg59(x: DoubleArray) = -3 / 2 * sin(3 * x[9] * x[1]) * x[1]
- fun cg60(x: DoubleArray) = cos(x[3])
- fun cg61(x: DoubleArray) = 3 * x[1] * x[1] * x[6]
- fun cg62(x: DoubleArray) = 1
- fun cg63(x: DoubleArray) = -(x[0] - x[5]) * sin(x[3])
- fun cg64(x: DoubleArray) = cos(x[9] / x[4] + x[7]) * x[9] * Math.pow(x[4], (-2.0))
- fun cg65(x: DoubleArray) = -cos(x[3])
- fun cg66(x: DoubleArray) = Math.pow(x[1], 3.0)
- fun cg67(x: DoubleArray) = -cos(x[9] / x[4] + x[7])
- fun cg68(x: DoubleArray) = 0
- fun cg69(x: DoubleArray) = -cos(x[9] / x[4] + x[7]) / x[4]
- fun cg70(x: DoubleArray) = 2 * x[4] * (x[0] - 2 * x[5])
- fun cg71(x: DoubleArray) = -x[6] * exp(x[1] * x[6] + x[9])
- fun cg72(x: DoubleArray) = -2 * cos(-x[8] + x[2])
- fun cg73(x: DoubleArray) = 015e1
- fun cg74(x: DoubleArray) = Math.pow(x[0] - 2 * x[5], 2.0)
- fun cg75(x: DoubleArray) = -4 * x[4] * (x[0] - 2 * x[5])
- fun cg76(x: DoubleArray) = -x[1] * exp(x[1] * x[6] + x[9])
- fun cg77(x: DoubleArray) = 0
- fun cg78(x: DoubleArray) = 2 * cos(-x[8] + x[2])
- fun cg79(x: DoubleArray) = -exp(x[1] * x[6] + x[9])
- fun cg80(x: DoubleArray) = -3
- fun cg81(x: DoubleArray) = -2 * x[7] * x[9] * x[6]
- fun cg82(x: DoubleArray) = 0
- fun cg83(x: DoubleArray) = exp((x[4] + x[3]))
- fun cg84(x: DoubleArray) = exp((x[4] + x[3]))
- fun cg85(x: DoubleArray) = -07e1 * Math.pow(x[5], -2.0)
- fun cg86(x: DoubleArray) = -2 * x[1] * x[7] * x[9]
- fun cg87(x: DoubleArray) = -2 * x[1] * x[9] * x[6]
- fun cg88(x: DoubleArray) = 3
- fun cg89(x: DoubleArray) = -2 * x[1] * x[7] * x[6]
- fun cg90(x: DoubleArray) = x[9]
- fun cg91(x: DoubleArray) = x[8]
- fun cg92(x: DoubleArray) = -x[7]
- fun cg93(x: DoubleArray) = cos(x[3] + x[4] + x[5]) * x[6]
- fun cg94(x: DoubleArray) = cos(x[3] + x[4] + x[5]) * x[6]
- fun cg95(x: DoubleArray) = cos(x[3] + x[4] + x[5]) * x[6]
- fun cg96(x: DoubleArray) = sin(x[3] + x[4] + x[5])
- fun cg97(x: DoubleArray) = -x[2]
- fun cg98(x: DoubleArray) = x[1]
- fun cg99(x: DoubleArray) = x[0]
- }
- }
- operator fun unaryMinus(): Matrix {
- var a = Array(this.numberOfRows(), { Array(this.numberOfCollumbs(), { 0.0 }) })
- for (i in 0 until this.numberOfRows())
- for (j in 0 until this.numberOfCollumbs())
- a[i][j]=-this.masive[i][j]
- return Matrix(a)
- }
- fun matrixCollumbtoArray():DoubleArray{
- val a = DoubleArray(this.masive.size,{0.0})
- for(i in 0 until this.masive.size)
- a[i]=this.masive[i][0]
- return a
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement