Loading...
Searching...
No Matches
JointObservation.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5#ifndef GPR_ML_JOINTOBSERVATION_H_
6#define GPR_ML_JOINTOBSERVATION_H_
7
8#include <stdexcept>
9#include <string>
10
12
13namespace gpr {
14namespace detail {
15
16inline void requireJointTrainingObservation(const Observation& observation,
17 const char* context,
18 bool allow_empty = false)
19{
20 const bool empty = observation.R.size() == 0 && observation.E.size() == 0 &&
21 observation.G.size() == 0;
22 if (empty && allow_empty) return;
23
24 const bool complete_shape =
25 observation.R.rows() > 0 && observation.R.cols() > 0 &&
26 observation.E.size() == observation.R.rows() &&
27 (observation.E.rows() == 1 || observation.E.cols() == 1) &&
28 observation.G.rows() == observation.R.rows() &&
29 observation.G.cols() == observation.R.cols();
30 if (!complete_shape) {
31 throw std::invalid_argument(
32 std::string(context) +
33 " requires joint R(n,D), E(n), G(n,D) training observations");
34 }
35 if (!observation.R.allFinite() || !observation.E.allFinite() ||
36 !observation.G.allFinite()) {
37 throw std::invalid_argument(std::string(context) +
38 " requires finite joint observations");
39 }
40}
41
42} // namespace detail
43} // namespace gpr
44
45#endif // GPR_ML_JOINTOBSERVATION_H_
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16