Quantum Gate Decomposer  v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
Functor_Cost_Function_Gradient.h
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright (C) 2020 Peter Rakyta, Ph.D.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see http://www.gnu.org/licenses/.
17 
18 @author: Peter Rakyta, Ph.D.
19 */
24 #ifndef FUNCTOR_COST_FUNCTION_GRADIENT_H_INCLUDED
25 #define FUNCTOR_COST_FUNCTION_GRADIENT_H_INCLUDED
26 
27 #include <gsl/gsl_vector.h>
28 #include "qgd/common.h"
29 
33 template<typename decomp_class>
34 class functor_grad {
35 
36 protected:
37 
39  const gsl_vector* parameters;
41  decomp_class* instance;
43  gsl_vector* f;
45  double* f0;
47  double dparam;
48 
49 public:
50 
59 functor_grad( const gsl_vector* parameters_in, decomp_class* instance_in, gsl_vector* f_in, double* f0_in, double dparam_in );
60 
65 void operator()( int i ) const;
66 
67 };
68 
69 
70 
71 
72 #endif // FUNCTOR_COST_FUNCTION_GRADIENT_H_INCLUDED
gsl_vector * f
A GNU Scientific Library vector containing the calculated values of the cost function at displaced po...
decomp_class * instance
A pointer pointing to the instance of a class Sub_Matrix_Decomposition.
double dparam
the difference in one direction in the parameter for the gradient calculaiton
void operator()(int i) const
Operator to calculate a gradient component of a cost function labeled by index i.
functor_grad(const gsl_vector *parameters_in, decomp_class *instance_in, gsl_vector *f_in, double *f0_in, double dparam_in)
Constructor of the class.
Function operator class to calculate the gradient components of the cost function in parallel.
Header file for commonly used functions and wrappers to CBLAS functions.
const gsl_vector * parameters
A GNU Scientific Library vector containing the free parameters to be optimized.
double * f0
The value of the cost function at parameters_in.