/*
 initialize all parameter for System model and cost function
*/ 
#include "../include/init.cuh"

void init_params( float *a )
{
    // params for simple nonlinear systems
    // for Simple Nonlinear System
    /*a[0] = 1.0f;
    a[1] = 1.0f;*/

    // FOR CART AND POLE
    a[0] = 0.1f;
    a[1] = 0.024f;
    a[2] = 0.2f;
    a[3] = a[1] * powf(a[2],2) /3;
    a[4] = 1.265f;
    a[5] = 0.0000001;
    a[6] = 9.81f;
}

void init_state( float *a )
{
    // initial state for simple nonlinear system
    // for Simple Nonlinear model
    /*a[0] = 2.0f;
    a[1] = 0.0f;*/
    
    // FOR CART AND POLE
    a[0] = 0.0f; //x
    a[1] = M_PI + 0.005; //theta
    a[2] = 0.0f; //dx
    a[3] = 0.0f; //dth
}

void init_constraint( float *a )
{
    // constraints for simple nonlinear system
    // For Simple Nonlinera System
    /*a[0] = 0.0f;
    a[1] = 0.0f;*/

    // FOR CONTROL CART AND POLE
    // For Quadric Fitting Superior Constraints parameters
    a[0] = -3.0f;
    a[1] = 3.0f;
    a[2] = -0.5f;
    a[3] = 0.5f;

    // For MC superior Parameter
    /*a[0] = -1.0f;
    a[1] = 1.0f;
    a[2] = -0.5f;
    a[3] = 0.5f;*/
}

void init_matrix( float *a )
{
    //matrix elements for simple nonlinear system
    // FOR SIMPLE NONLINEAR SYSTEM
    /*a[0] = 0.1f;
    a[1] = 1.0f;
    a[2] = 0.1f;*/

    // FOR CAONTROL CART AND POLE
    // For Quadric Fitting Superior Weight Parameter
    /*a[0] = 3.0f;
    a[1] = 3.5f;
    a[2] = 0.0f;
    a[3] = 0.0f;
    a[4] = 1.0f;*/

    // For MC superior Parameter
    a[0] = 3.0f;
    a[1] = 10.0f;
    a[2] = 0.05f;
    a[3] = 0.01f;
    a[4] = 0.5f;
}


void initialize_host_vector(float *get_params, float *get_state, float *get_constraints, float *get_matrix)
{
    init_params( get_params );
    init_state( get_state );
    init_constraint( get_constraints );
    init_matrix( get_matrix );
}

	.file	"tmpxft_002dc63a_00000000-6_init.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2015:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2015:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11init_paramsPf
	.type	_Z11init_paramsPf, @function
_Z11init_paramsPf:
.LFB2008:
	.cfi_startproc
	endbr64
	movabsq	$4378795876014673101, %rax
	movl	$0x411cf5c3, 24(%rdi)
	movq	%rax, (%rdi)
	movabsq	$4154506529137806541, %rax
	movq	%rax, 8(%rdi)
	movabsq	$3735383588689013637, %rax
	movq	%rax, 16(%rdi)
	ret
	.cfi_endproc
.LFE2008:
	.size	_Z11init_paramsPf, .-_Z11init_paramsPf
	.globl	_Z10init_statePf
	.type	_Z10init_statePf, @function
_Z10init_statePf:
.LFB2009:
	.cfi_startproc
	endbr64
	movl	$539275491, %eax
	salq	$33, %rax
	movq	%rax, (%rdi)
	xorl	%eax, %eax
	movq	%rax, 8(%rdi)
	ret
	.cfi_endproc
.LFE2009:
	.size	_Z10init_statePf, .-_Z10init_statePf
	.globl	_Z15init_constraintPf
	.type	_Z15init_constraintPf, @function
_Z15init_constraintPf:
.LFB2010:
	.cfi_startproc
	endbr64
	movabsq	$4629700420162289664, %rax
	movq	%rax, (%rdi)
	movabsq	$4539628427593908224, %rax
	movq	%rax, 8(%rdi)
	ret
	.cfi_endproc
.LFE2010:
	.size	_Z15init_constraintPf, .-_Z15init_constraintPf
	.globl	_Z11init_matrixPf
	.type	_Z11init_matrixPf, @function
_Z11init_matrixPf:
.LFB2011:
	.cfi_startproc
	endbr64
	movabsq	$4692750812797992960, %rax
	movl	$0x3f000000, 16(%rdi)
	movq	%rax, (%rdi)
	movabsq	$4333543705438637261, %rax
	movq	%rax, 8(%rdi)
	ret
	.cfi_endproc
.LFE2011:
	.size	_Z11init_matrixPf, .-_Z11init_matrixPf
	.globl	_Z22initialize_host_vectorPfS_S_S_
	.type	_Z22initialize_host_vectorPfS_S_S_, @function
_Z22initialize_host_vectorPfS_S_S_:
.LFB2012:
	.cfi_startproc
	endbr64
	call	_Z11init_paramsPf
	movl	$539275491, %eax
	movq	%rcx, %rdi
	salq	$33, %rax
	movq	%rax, (%rsi)
	xorl	%eax, %eax
	movq	%rax, 8(%rsi)
	movabsq	$4629700420162289664, %rax
	movq	%rax, (%rdx)
	movabsq	$4539628427593908224, %rax
	movq	%rax, 8(%rdx)
	jmp	_Z11init_matrixPf
	.cfi_endproc
.LFE2012:
	.size	_Z22initialize_host_vectorPfS_S_S_, .-_Z22initialize_host_vectorPfS_S_S_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2038:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2038:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

/*
 initialize all parameter for System model and cost function
*/ 

#include <hip/hip_runtime.h>
#include "../include/init.cuh"

void init_params( float *a )
{
    // params for simple nonlinear systems
    // for Simple Nonlinear System
    /*a[0] = 1.0f;
    a[1] = 1.0f;*/

    // FOR CART AND POLE
    a[0] = 0.1f;
    a[1] = 0.024f;
    a[2] = 0.2f;
    a[3] = a[1] * powf(a[2],2) /3;
    a[4] = 1.265f;
    a[5] = 0.0000001;
    a[6] = 9.81f;
}

void init_state( float *a )
{
    // initial state for simple nonlinear system
    // for Simple Nonlinear model
    /*a[0] = 2.0f;
    a[1] = 0.0f;*/
    
    // FOR CART AND POLE
    a[0] = 0.0f; //x
    a[1] = M_PI + 0.005; //theta
    a[2] = 0.0f; //dx
    a[3] = 0.0f; //dth
}

void init_constraint( float *a )
{
    // constraints for simple nonlinear system
    // For Simple Nonlinera System
    /*a[0] = 0.0f;
    a[1] = 0.0f;*/

    // FOR CONTROL CART AND POLE
    // For Quadric Fitting Superior Constraints parameters
    a[0] = -3.0f;
    a[1] = 3.0f;
    a[2] = -0.5f;
    a[3] = 0.5f;

    // For MC superior Parameter
    /*a[0] = -1.0f;
    a[1] = 1.0f;
    a[2] = -0.5f;
    a[3] = 0.5f;*/
}

void init_matrix( float *a )
{
    //matrix elements for simple nonlinear system
    // FOR SIMPLE NONLINEAR SYSTEM
    /*a[0] = 0.1f;
    a[1] = 1.0f;
    a[2] = 0.1f;*/

    // FOR CAONTROL CART AND POLE
    // For Quadric Fitting Superior Weight Parameter
    /*a[0] = 3.0f;
    a[1] = 3.5f;
    a[2] = 0.0f;
    a[3] = 0.0f;
    a[4] = 1.0f;*/

    // For MC superior Parameter
    a[0] = 3.0f;
    a[1] = 10.0f;
    a[2] = 0.05f;
    a[3] = 0.01f;
    a[4] = 0.5f;
}


void initialize_host_vector(float *get_params, float *get_state, float *get_constraints, float *get_matrix)
{
    init_params( get_params );
    init_state( get_state );
    init_constraint( get_constraints );
    init_matrix( get_matrix );
}

	.text
	.file	"init.hip"
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z11init_paramsPf
.LCPI0_0:
	.long	0x3dcccccd                      # float 0.100000001
	.long	0x3cc49ba6                      # float 0.0240000002
	.long	0x3e4ccccd                      # float 0.200000003
	.long	0x39a7c5ad                      # float 3.20000021E-4
	.text
	.globl	_Z11init_paramsPf
	.type	_Z11init_paramsPf,@function
_Z11init_paramsPf:                      # @_Z11init_paramsPf
	.cfi_startproc
# %bb.0:
	movaps	.LCPI0_0(%rip), %xmm0           # xmm0 = [1.00000001E-1,2.40000002E-2,2.00000003E-1,3.20000021E-4]
	movups	%xmm0, (%rdi)
	movabsq	$3735383588689013637, %rax      # imm = 0x33D6BF953FA1EB85
	movq	%rax, 16(%rdi)
	movl	$1092416963, 24(%rdi)           # imm = 0x411CF5C3
	retq
.Lfunc_end0:
	.size	_Z11init_paramsPf, .Lfunc_end0-_Z11init_paramsPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z10init_statePf
.LCPI1_0:
	.long	0x00000000                      # float 0
	.long	0x404961c6                      # float 3.14659262
	.long	0x00000000                      # float 0
	.long	0x00000000                      # float 0
	.text
	.globl	_Z10init_statePf
	.type	_Z10init_statePf,@function
_Z10init_statePf:                       # @_Z10init_statePf
	.cfi_startproc
# %bb.0:
	movaps	.LCPI1_0(%rip), %xmm0           # xmm0 = [0.0E+0,3.14659262E+0,0.0E+0,0.0E+0]
	movups	%xmm0, (%rdi)
	retq
.Lfunc_end1:
	.size	_Z10init_statePf, .Lfunc_end1-_Z10init_statePf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z15init_constraintPf
.LCPI2_0:
	.long	0xc0400000                      # float -3
	.long	0x40400000                      # float 3
	.long	0xbf000000                      # float -0.5
	.long	0x3f000000                      # float 0.5
	.text
	.globl	_Z15init_constraintPf
	.type	_Z15init_constraintPf,@function
_Z15init_constraintPf:                  # @_Z15init_constraintPf
	.cfi_startproc
# %bb.0:
	movaps	.LCPI2_0(%rip), %xmm0           # xmm0 = [-3.0E+0,3.0E+0,-5.0E-1,5.0E-1]
	movups	%xmm0, (%rdi)
	retq
.Lfunc_end2:
	.size	_Z15init_constraintPf, .Lfunc_end2-_Z15init_constraintPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z11init_matrixPf
.LCPI3_0:
	.long	0x40400000                      # float 3
	.long	0x41200000                      # float 10
	.long	0x3d4ccccd                      # float 0.0500000007
	.long	0x3c23d70a                      # float 0.00999999977
	.text
	.globl	_Z11init_matrixPf
	.type	_Z11init_matrixPf,@function
_Z11init_matrixPf:                      # @_Z11init_matrixPf
	.cfi_startproc
# %bb.0:
	movaps	.LCPI3_0(%rip), %xmm0           # xmm0 = [3.0E+0,1.0E+1,5.00000007E-2,9.99999977E-3]
	movups	%xmm0, (%rdi)
	movl	$1056964608, 16(%rdi)           # imm = 0x3F000000
	retq
.Lfunc_end3:
	.size	_Z11init_matrixPf, .Lfunc_end3-_Z11init_matrixPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z22initialize_host_vectorPfS_S_S_
.LCPI4_0:
	.long	0x3dcccccd                      # float 0.100000001
	.long	0x3cc49ba6                      # float 0.0240000002
	.long	0x3e4ccccd                      # float 0.200000003
	.long	0x39a7c5ad                      # float 3.20000021E-4
.LCPI4_1:
	.long	0x00000000                      # float 0
	.long	0x404961c6                      # float 3.14659262
	.long	0x00000000                      # float 0
	.long	0x00000000                      # float 0
.LCPI4_2:
	.long	0xc0400000                      # float -3
	.long	0x40400000                      # float 3
	.long	0xbf000000                      # float -0.5
	.long	0x3f000000                      # float 0.5
.LCPI4_3:
	.long	0x40400000                      # float 3
	.long	0x41200000                      # float 10
	.long	0x3d4ccccd                      # float 0.0500000007
	.long	0x3c23d70a                      # float 0.00999999977
	.text
	.globl	_Z22initialize_host_vectorPfS_S_S_
	.type	_Z22initialize_host_vectorPfS_S_S_,@function
_Z22initialize_host_vectorPfS_S_S_:     # @_Z22initialize_host_vectorPfS_S_S_
	.cfi_startproc
# %bb.0:
	movaps	.LCPI4_0(%rip), %xmm0           # xmm0 = [1.00000001E-1,2.40000002E-2,2.00000003E-1,3.20000021E-4]
	movups	%xmm0, (%rdi)
	movabsq	$3735383588689013637, %rax      # imm = 0x33D6BF953FA1EB85
	movq	%rax, 16(%rdi)
	movl	$1092416963, 24(%rdi)           # imm = 0x411CF5C3
	movaps	.LCPI4_1(%rip), %xmm0           # xmm0 = [0.0E+0,3.14659262E+0,0.0E+0,0.0E+0]
	movups	%xmm0, (%rsi)
	movaps	.LCPI4_2(%rip), %xmm0           # xmm0 = [-3.0E+0,3.0E+0,-5.0E-1,5.0E-1]
	movups	%xmm0, (%rdx)
	movaps	.LCPI4_3(%rip), %xmm0           # xmm0 = [3.0E+0,1.0E+1,5.00000007E-2,9.99999977E-3]
	movups	%xmm0, (%rcx)
	movl	$1056964608, 16(%rcx)           # imm = 0x3F000000
	retq
.Lfunc_end4:
	.size	_Z22initialize_host_vectorPfS_S_S_, .Lfunc_end4-_Z22initialize_host_vectorPfS_S_S_
	.cfi_endproc
                                        # -- End function
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
