1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2012 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
26 #include "hkl/hkl-matrix-private.h"
27 #include "hkl/hkl-macros-private.h"
28 #include "hkl/hkl-pseudoaxis-private.h"
30 void is_quaternion(const HklQuaternion
*wanted
, const HklQuaternion
*seen
, const char *format
, ...)
34 va_start(args
, format
);
36 if(TRUE
== hkl_quaternion_cmp(wanted
, seen
))
39 printf("# wanted: %g %g %g %g\n",
40 wanted
->data
[0], wanted
->data
[1], wanted
->data
[2], wanted
->data
[3]);
41 printf("# seen: %g %g %g %g\n",
42 seen
->data
[0], seen
->data
[1], seen
->data
[2], wanted
->data
[3]);
47 void is_matrix(const HklMatrix
*wanted
, const HklMatrix
*seen
, const char *format
, ...)
51 va_start(args
, format
);
53 if(TRUE
== hkl_matrix_cmp(wanted
, seen
))
56 printf("# wanted: %g %g %g\n# : %g %g %g\n# : %g %g %g\n",
57 wanted
->data
[0][0], wanted
->data
[0][1], wanted
->data
[0][2],
58 wanted
->data
[1][0], wanted
->data
[1][1], wanted
->data
[1][2],
59 wanted
->data
[2][0], wanted
->data
[2][1], wanted
->data
[2][2]);
60 printf("# seen: %g %g %g\n# : %g %g %g\n# : %g %g %g\n",
61 seen
->data
[0][0], seen
->data
[0][1], seen
->data
[0][2],
62 seen
->data
[1][0], seen
->data
[1][1], seen
->data
[1][2],
63 seen
->data
[2][0], seen
->data
[2][1], seen
->data
[2][2]);
68 int check_pseudoaxes_v(HklEngine
*engine
, ...)
72 unsigned int len
= hkl_engine_len(engine
);
75 /* extract the variable part of the method */
78 values
[i
] = va_arg(ap
, double);
81 return check_pseudoaxes(engine
, values
, len
);
84 int check_pseudoaxes(HklEngine
*engine
,
85 double expected
[], uint len
)
91 hkl_assert(hkl_engine_len(engine
) == len
);
93 if(hkl_engine_pseudo_axis_values_get(engine
, currents
, len
, HKL_UNIT_DEFAULT
, NULL
)){
95 res
&= fabs(currents
[i
] - expected
[i
]) <= HKL_EPSILON
;
97 fprintf(stderr
, "current: %f, expected: %f, epsilon: %f\n",
98 currents
[i
], expected
[i
], HKL_EPSILON
);
108 * hkl_engine_set_values_v: (skip)
110 * @values: the values to set
112 * set the values of the PseudoAxes with the given values. This method
113 * is only available for test as it is sort of brittle.
115 HklGeometryList
*hkl_engine_set_values_v(HklEngine
*self
, ...)
119 unsigned int len
= hkl_engine_len(self
);
124 values
[i
] = va_arg(ap
, double);
127 return hkl_engine_pseudo_axis_values_set(self
, values
, len
,
128 HKL_UNIT_DEFAULT
, NULL
);
132 * hkl_tap_engine_pseudo_axes_randomize: (skip)
133 * @self: the this ptr
135 * randomize all the parameters of the #HklEngine
137 void hkl_tap_engine_pseudo_axes_randomize(HklEngine
*self
,
138 double values
[], size_t n_values
,
139 HklUnitEnum unit_type
)
143 for(i
=0; i
<n_values
; ++i
){
144 HklParameter
*parameter
= darray_item(self
->pseudo_axes
, i
);
145 hkl_parameter_randomize(parameter
);
146 values
[i
] = hkl_parameter_value_get(parameter
, unit_type
);
151 * hkl_tap_engine_parameters_randomize: (skip)
152 * @self: the this ptr
154 * randomize all the parameters of the #HklEngine
156 void hkl_tap_engine_parameters_randomize(HklEngine
*self
)
158 HklParameter
**parameter
;
160 darray_foreach(parameter
, self
->mode
->parameters
){
161 hkl_parameter_randomize(*parameter
);