MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / XMtrustregion

Function XMtrustregion

XM/include/XM/trustregion.h:77–724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76
77void XMtrustregion(opt_var &C, const opt_var &R0, const opt_var &s0, opt_var &R_result, opt_var &s_result,const double lam, double &gradtol, double linesearch_step , opt_var &v , double* primal_value, const double maxtime){
78 // initialize
79 DeviceBlasHandle CUOPT_blas_handle;
80 CUOPT_blas_handle.activate();
81 // DeviceSolverDnHandle CUOPT_cuslover_handle;
82 // CUOPT_cuslover_handle.activate();
83
84 // size_s n = 5;
85 // std::vector<datatype> Q_h(9*n*n);
86 // for(size_l i = 0; i<9*n*n; ++i){
87 // Q_h[i] = static_cast<float>(rand()) / RAND_MAX;
88 // }
89 // opt_var A({3*n,3*n});
90 // A.SynchronizeHostToDevice(Q_h.data());
91 // opt_var C({3*n,3*n});
92 // DnMatDnMat(CUOPT_blas_handle,C,A,A,CUBLAS_OP_N,CUBLAS_OP_T);
93
94 // size_s n = 0;
95 // std::vector<datatype> Q_h;
96 // loadMatrixFromBin("../assets/matrix_data_20.bin", Q_h, n);
97 // opt_var C({3*n,3*n});
98 // C.SynchronizeHostToDevice(Q_h.data());
99
100
101
102 size_s o = R0.dimensions[1];
103 size_s n = C.dimensions[0]/3;
104 size_s dim = n * (3 * o - 6) + n - 1;
105 double delta_bar = sqrt(dim);
106 double delta = delta_bar / 8.0;
107
108 // copy R
109 opt_var R({3*n,o});
110 CHECK_CUDA(cudaMemcpy(R.vals, R0.vals, R.total_size * sizeof(datatype), cudaMemcpyDeviceToDevice));
111
112 // opt_var R({3*n,o});
113 // // generate r0
114 // std::vector<datatype> R_h(3*o*n,0);
115 // for(size_l i = 0; i<n; ++i){
116 // R_h[3*i] = 1.0;
117 // R_h[3*i+3*n+1] = 1.0;
118 // R_h[3*i+6*n+2] = 1.0;
119 // }
120
121 // R.SynchronizeHostToDevice(R_h.data());
122 //s = ones(n-1,1);
123 //s_ex = [1,s];
124 // SUPERRRRRRRRR UGLY!!!!!!!!!!
125 opt_var s_ex({n}); //because we reserve the first element to be 1
126 std::vector<datatype> s_ex_h(n,1);
127 s_ex.SynchronizeHostToDevice(s_ex_h.data());
128 opt_var s; //because we reserve the first element to be 1
129 s.vals = s_ex.vals+1;
130 s.num_dims = 1;
131 s.dimensions = new size_s[1];
132 s.dimensions[0] = n-1;
133 s.total_size = n-1;
134 // copy s

Callers

nothing calls this directly

Calls 13

dnmat_mul_spdiag_batchFunction · 0.85
DnMatDnMatFunction · 0.85
dnmat_Ddot_colomn_batchFunction · 0.85
DnMatDnMatBatchFunction · 0.85
symBatchedFunction · 0.85
DnMatDnMatDotFunction · 0.85
batchedQRFunction · 0.85
transposeFunction · 0.85
DnMatDnMatDivideFunction · 0.85
ProductManifoldInnerFunction · 0.85
setValueAtMethod · 0.80
activateMethod · 0.45

Tested by

no test coverage detected