diff --git a/src/xrt/auxiliary/util/u_pretty_print.c b/src/xrt/auxiliary/util/u_pretty_print.c index 6faa152cf..69e5213f7 100644 --- a/src/xrt/auxiliary/util/u_pretty_print.c +++ b/src/xrt/auxiliary/util/u_pretty_print.c @@ -10,6 +10,7 @@ #include "util/u_misc.h" #include "util/u_pretty_print.h" +#include #include #include #include @@ -359,6 +360,27 @@ u_pp_small_matrix_4x4_f64(u_pp_delegate_t dg, const struct xrt_matrix_4x4_f64 *m m->v[3], m->v[7], m->v[11], m->v[15]); // } +void +u_pp_small_array_f64(struct u_pp_delegate dg, const double *arr, size_t n) +{ + assert(n != 0); + DG("["); + for (size_t i = 0; i < n - 1; i++) { + u_pp(dg, "%lf, ", arr[i]); + } + u_pp(dg, "%lf]", arr[n - 1]); +} + +void +u_pp_small_array2d_f64(struct u_pp_delegate dg, const double *arr, size_t n, size_t m) +{ + DG("[\n"); + for (size_t i = 0; i < n; i++) { + u_pp_small_array_f64(dg, &arr[i], m); + } + DG("\n]"); +} + void u_pp_vec3(u_pp_delegate_t dg, const struct xrt_vec3 *vec, const char *name, const char *indent) { @@ -425,6 +447,20 @@ u_pp_matrix_4x4_f64(u_pp_delegate_t dg, const struct xrt_matrix_4x4_f64 *m, cons indent); // } +void +u_pp_array_f64(u_pp_delegate_t dg, const double *arr, size_t n, const char *name, const char *indent) +{ + u_pp(dg, "\n%s%s = ", indent, name); + u_pp_small_array_f64(dg, arr, n); +} + +void +u_pp_array2d_f64(u_pp_delegate_t dg, const double *arr, size_t n, size_t m, const char *name, const char *indent) +{ + u_pp(dg, "\n%s%s = ", indent, name); + u_pp_small_array2d_f64(dg, arr, n, m); +} + /* * diff --git a/src/xrt/auxiliary/util/u_pretty_print.h b/src/xrt/auxiliary/util/u_pretty_print.h index c489fc552..343aef2ad 100644 --- a/src/xrt/auxiliary/util/u_pretty_print.h +++ b/src/xrt/auxiliary/util/u_pretty_print.h @@ -98,6 +98,8 @@ u_pp_xrt_result(struct u_pp_delegate dg, xrt_result_t xret); * the other functions does. This is so that you can easily chain print * functions to print a struct. * + * @note xrt_matrix_* parameters assumed to be column major. + * * @ingroup aux_pretty * @{ */ @@ -116,6 +118,12 @@ u_pp_small_matrix_4x4(u_pp_delegate_t dg, const struct xrt_matrix_4x4 *m); void u_pp_small_matrix_4x4_f64(u_pp_delegate_t dg, const struct xrt_matrix_4x4_f64 *m); +void +u_pp_small_array_f64(struct u_pp_delegate dg, const double *arr, size_t n); + +void +u_pp_small_array2d_f64(struct u_pp_delegate dg, const double *arr, size_t n, size_t m); + void u_pp_vec3(u_pp_delegate_t dg, const struct xrt_vec3 *vec, const char *name, const char *indent); @@ -130,6 +138,15 @@ u_pp_matrix_4x4(u_pp_delegate_t dg, const struct xrt_matrix_4x4 *m, const char * void u_pp_matrix_4x4_f64(u_pp_delegate_t dg, const struct xrt_matrix_4x4_f64 *m, const char *name, const char *indent); + +//! Pretty prints `double arr[n]` +void +u_pp_array_f64(u_pp_delegate_t dg, const double *arr, size_t n, const char *name, const char *indent); + +//! Pretty prints `double arr[n][m]` +void +u_pp_array2d_f64(u_pp_delegate_t dg, const double *arr, size_t n, size_t m, const char *name, const char *indent); + /*! * @} */