24 extern "C" int LAPACKE_dposv(
int matrix_layout,
char uplo,
int n,
int nrhs,
double* A,
int LDA,
double* B,
int LDB);
42 x_new[idx] = x[idx] + s*
v[idx];
62 for (
int idx=0;idx<100;idx++){
79 int nIter = (
int)std::ceil(-2.078087*std::log(tol/std::fabs(b-a)));
80 double R = 0.618033989;
82 double x1 = R*a + C*b;
83 double x2 = C*a + R*b;
86 for (
int iter=0; iter<nIter;iter++){
119 u[var_idx*variable_num + var_idx] = 1.0;
122 memset(df.
get_data(), 0.0, variable_num*
sizeof(double) );
129 for (
int iter=0;iter<max_iter;iter++){
136 df[var_idx] = fOld - fMin;
139 x[idx] = x[idx] + s*
v[idx];
143 v[idx] = x[idx] - xOld[idx];
146 search(a,b,s,fLast,tol,x);
149 x[idx] = x[idx] + s*
v[idx];
150 dot = dot + (x[idx] - xOld[idx])*(x[idx] - xOld[idx]);
155 Imax = (df[idx]>df[Imax]) ? idx:Imax;
157 for (
int idx = Imax;idx<variable_num-1;idx++){
160 memcpy(
u.
get_data()+(variable_num-1)*variable_num,
v.
get_data(),
sizeof(double)*variable_num);
Matrix dot(Matrix &A, Matrix &B)
Call to calculate the product of two complex matrices by calling method zgemm3m from the CBLAS librar...
void search(double a, double b, double &s, double &f_val, double tol, Matrix_real x)
double(* costfnc)(Matrix_real x, void *params)
function pointer to evaluate the cost function and its gradient vector
Matrix_real copy() const
Call to create a copy of the matrix.
int LAPACKE_dposv(int matrix_layout, char uplo, int n, int nrhs, double *A, int LDA, double *B, int LDB)
Powells_method(double(*f_pointer)(Matrix_real, void *), void *meta_data_in)
Constructor of the class.
void bracket(double x1, double h, double &a, double &b, Matrix_real x)
scalar * get_data() const
Call to get the pointer to the stored data.
double Start_Optimization(Matrix_real &x, long max_iter)
~Powells_method()
Destructor of the class.
int size() const
Call to get the number of the allocated elements.
A class representing a U3 gate.
double direction(double s, Matrix_real x)
void * meta_data
additional data needed to evaluate the cost function
int variable_num
number of independent variables in the problem
Class to store data of complex arrays and its properties.