38 tbb::combinable<double> priv_partial_cost_functions{[](){
return 0;}};
51 double cost_function = 0;
52 priv_partial_cost_functions.combine_each([&cost_function](
double a) {
53 cost_function = cost_function + a;
87 for (
size_t row_idx = r.begin(); row_idx != r.end(); row_idx++) {
90 printf(
"Error: row idx should be less than the number of roes in the matrix\n");
99 double partial_cost_function = 0;
101 size_t idx_max = idx_offset + row_idx;
102 for (
size_t idx=idx_offset; idx<idx_max; idx++ ) {
106 size_t diag_element_idx = row_idx*
matrix_size + row_idx;
107 double diag_real =
data[diag_element_idx].
real - corner_element.
real;
108 double diag_imag =
data[diag_element_idx].
imag - corner_element.
imag;
109 partial_cost_function = partial_cost_function + diag_real*diag_real + diag_imag*diag_imag;
112 idx_offset = idx_max + 1;
114 for (
size_t idx=idx_offset; idx<idx_max; idx++ ) {
119 cost_function_priv = cost_function_priv + partial_cost_function;
size_t rows
The number of rows.
QGD_Complex16 * data
Pointer to the data stored in the matrix.
scalar * get_data()
Call to get the pointer to the stored data.
void operator()(tbb::blocked_range< size_t > r) const
Operator to calculate the partial cost function derived from the row of the matrix labeled by row_idx...
Function operator class to calculate the partial cost function of the final optimization process.
Matrix matrix
Array stroing the matrix.
functor_cost_fnc(Matrix matrix_in, tbb::combinable< double > *partial_cost_functions_in)
Constructor of the class.
Structure type representing complex numbers in the QGD package.
Class to store data of complex arrays and its properties.
double get_cost_function(Matrix matrix)
Call co calculate the cost function during the final optimization process.
Header file for the paralleized calculation of the cost function of the final optimization problem (s...
double real
the real part of a complex number
tbb::combinable< double > * partial_cost_functions
array storing the partial cost functions
double imag
the imaginary part of a complex number